code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) UpperCAmelCase__ : Any ...
313
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CL...
313
1
from __future__ import annotations import math def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" if len(_UpperCAmelCase ) != 2 or len(a[0] ) != 2 or len(_UpperCAmelCase ) != 2 or len(b[0] ) != 2: ...
715
def __snake_case ( _UpperCAmelCase = 10 ): """simple docstring""" if not isinstance(_UpperCAmelCase , _UpperCAmelCase ) or n < 0: raise ValueError('Invalid input' ) lowercase = 10**n lowercase = 2_84_33 * (pow(2 ...
314
0
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfAr...
623
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_ava...
623
1
import math class lowerCAmelCase__: '''simple docstring''' def UpperCamelCase_ ( self , __lowerCamelCase , __lowerCamelCase ) -> int: _SCREAMING_SNAKE_CASE : List[Any] = 0.0 _SCREAMING_SNAKE_CASE ...
713
import cmath import math def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): _SCREAMING_SNAKE_CASE : Any = math.radians(__lowerCamelCase ) _SCREAMING_SNAKE_CASE : Tuple = math.radians(__lo...
381
0
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling...
513
from __future__ import annotations import time import numpy as np lowerCamelCase_ = [8, 5, 9, 7] lowerCamelCase_ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] lowerCamelCase_ = [ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, 5, 3...
513
1
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> List[Any]: """simple docstring""" snake_case_ = analyze_text(__UpperCamelCase ) sn...
721
import requests def __lowerCAmelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )-> None: """simple docstring""" snake_case_ = {'''Content-Type''': '''application/json'''} snake_case_ = requests.post(SCREAMING_SNAKE_CASE , json={'''text''': messag...
531
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def UpperCamelCase_( _A :float , _A :float , _A :bool = False )-> Optional[Any]: if radian_mode: return [magnitude * cos(lowerCamelCase_ ), magnitude * ...
551
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( lowerCamelCase_: int , lowerCamelCase_: int ): """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def __SCREAMING_SNAKE_CASE ( ): """simple docstring""" ...
449
0
"""simple docstring""" import math def snake_case__ ( _snake_case : int ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, al...
304
"""simple docstring""" from collections.abc import Sequence def snake_case__ ( _snake_case : Sequence[float] , _snake_case : bool = False ): """simple docstring""" if not arr: return 0 UpperCamelCase__ = 0 if allow_empty_suba...
304
1
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import Tes...
644
"""simple docstring""" import math from datetime import datetime, timedelta def _UpperCAmelCase ( lowerCamelCase__ ): """simple docstring""" lowerCAmelCase__ = year % 19 lowerCAmelCase__ = year % 4 lowerCAmelCase__ = year % 7 lowerCAmelCase__ = math.floor(year / 100 ) ...
644
1
from PIL import Image def a ( SCREAMING_SNAKE_CASE_ : Image , SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" UpperCamelCase : Tuple = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(SCR...
713
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class UpperCAmelCase_ ( _a): '''simple docstring''' def _lowercase ( self , __SCREAMING_SNAKE_CASE ): """simple docstring...
643
0
'''simple docstring''' from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
350
'''simple docstring''' import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTeste...
350
1
'''simple docstring''' import colorsys from PIL import Image # type: ignore def __lowerCamelCase ( _lowercase , _lowercase , _lowercase ) -> float: UpperCAmelCase : List[Any] = x UpperCAmelCase : List[str] = y for step in range(_lower...
672
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : Any = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: ...
672
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = {"configuration_fnet": ["FNET_PRETR...
26
'''simple docstring''' import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, Mobile...
26
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a: str = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization_xlm": ["XLMTokenizer"], } try: if not ...
715
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _a: Dict = logging.get_logger(__name__) class __UpperCamelCase ( lowercase ): SCREAMING_SNAKE_CASE__ = ['input_ids...
268
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
557
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Union[str, Any] = logging.get_logger(__name__) lowercase : Union[str, Any] = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-r...
557
1
"""simple docstring""" from datetime import datetime import requests def _snake_case ( lowercase__ : Optional[Any] ) -> bytes: '''simple docstring''' lowerCAmelCase_ :List[Any] = """https://downloadgram.net/wp-json/wppress/video-down...
701
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __UpperCAmelCase = False clas...
256
0
import argparse _a : Any = 'docs/source/_static/js/custom.js' def a_ ( __magic_name__ ) -> List[Any]: """simple docstring""" with open(__magic_name__ , encoding='''utf-8''' , newline='''\n''' ) as f: snake_case :...
598
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large"...
532
0
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prep...
711
'''simple docstring''' import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _lowerCAmelCase = logging.get_logger(__name__) def UpperCamelCase ( a=None , a=None ) -> Union[str, ...
245
0
'''simple docstring''' import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging __lowerCAmelCase : List[str] = logging.get_logger(__name__) # pylint: disab...
262
'''simple docstring''' import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available __lowerCAmelCase : int ...
262
1
"""simple docstring""" import requests __a = "" # <-- Put your OpenWeatherMap appid here! __a = "https://api.openweathermap.org/data/2.5/" def A_ ( _lowercase = "Chicago", _lowercase = APPID ): '''simple docstring''' return requests.get(URL_...
717
"""simple docstring""" from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusion...
310
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
568
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import Au...
568
1
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import (...
186
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaIm...
186
1
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowercase__ : str = str(bin(UpperCAmelCase ) )[2:] # remove the leading "0b" lowercase__ : int ...
152
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_...
152
1
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenc...
514
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, to...
514
1
'''simple docstring''' from math import isqrt, loga def _lowerCAmelCase ( lowercase ) -> list[int]: __lowerCAmelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , lowercas...
689
'''simple docstring''' from argparse import ArgumentParser from .env import EnvironmentCommand def _lowerCAmelCase ( ) -> Union[str, Any]: __lowerCAmelCase = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args>]""" ) __lowerCAmelCase ...
689
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase : List[Any] = { "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], } tr...
57
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertToken...
57
1
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTok...
54
def __lowerCAmelCase ( A , A , A , A ): # Return True if there is node that has not iterated. UpperCAmelCase_ = [False] * len(A ) UpperCAmelCase_ = [] queue.append(A ) UpperCAmelCase_ = True while queue: UpperCAmelCase_ ...
162
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggi...
719
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Co...
246
0
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class a ( __lowerCAmelCase ): """simple docstring""" ...
401
import math def snake_case ( snake_case__ :int) -> list: _A = [True] * n _A = False _A = False _A = True for i in range(3 , int(n**0.5 + 1) , 2): _A = i * 2 while index < n: ...
401
1
def a__ ( _UpperCamelCase : list ): if len(_UpperCamelCase ) < 2: return collection def circle_sort_util(_UpperCamelCase : list ,_UpperCamelCase : int ,_UpperCamelCase : int ) -> bool: __lowerCamelCase = False if low == high: return s...
622
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.t...
622
1
'''simple docstring''' import math import flax.linen as nn import jax.numpy as jnp def __a(SCREAMING_SNAKE_CASE_ : jnp.ndarray , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : float = 1 , SCREAMING_SNAKE_CASE_ : float = 1 , SCREAMING_SNAKE_CASE...
18
'''simple docstring''' from __future__ import annotations import math def lowerCamelCase__ ( a , a ): __snake_case = u for i in range(1 , a ): __snake_case = temp * (u - i) return temp def lowerCamelCase__ ( ): __snake_c...
356
0
def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import doctest ...
710
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Optional[int] = { '...
206
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseM...
136
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenize...
556
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETR...
48
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokeni...
48
1
"""simple docstring""" import sys __UpperCamelCase = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '66896648...
247
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common imp...
334
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : List[Any] = logging.get_logger(__name__) lowerCamelCase__ : Tuple = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/...
720
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowerCamelCase__ : List...
18
0
def _lowerCAmelCase ( _lowerCAmelCase = 1_0_0_0 ): '''simple docstring''' A_ : int = 3 A_ : int = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: result -= a a += 1 return result if __name_...
569
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.t...
569
1
'''simple docstring''' from __future__ import annotations import math def __A ( lowerCAmelCase_ , lowerCAmelCase_ ): _UpperCAmelCase : int = u for i in range(1 , lowerCAmelCase_ ): _UpperCAmelCase : Optional[int] = temp...
704
'''simple docstring''' import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases ...
156
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): A_ : str = ['image_processor', 'tokenizer'] A_ : Optional[int] = 'ViTIma...
592
from math import isqrt, loga def lowerCAmelCase__ ( a__ ) ->list[int]: '''simple docstring''' _UpperCamelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , a__ , a__ ): _Upper...
547
0
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: ...
239
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_...
239
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ : List[Any] = { """configuration_autoformer""": [ """AUTOFORMER_PRETRA...
102
'''simple docstring''' def __A ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def __A ( ): """simple docstring""" ...
211
0
from itertools import count def __lowerCAmelCase ( _UpperCamelCase = 50 ) -> int: '''simple docstring''' lowerCamelCase__: List[Any] = [1] * min_block_length for n in count(_UpperCamelCase ): fill_count_functions.append(1...
242
import argparse import collections import json import os import re import string import sys import numpy as np _lowercase = re.compile(r'\b(a|an|the)\b', re.UNICODE) _lowercase = None def __lowerCAmelCase ( ) -> Optional[Any]: ...
242
1
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def __snake_case (__UpperCAmelCase ): """simple docstring""" lowerCamelCase_ : List[Any] = [] lowe...
501
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configu...
501
1
'''simple docstring''' from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward ...
331
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extracti...
331
1
"""simple docstring""" import qiskit def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): UpperCamelCase : Union[str, Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register ...
102
'''simple docstring''' import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin f...
467
0
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex snake_case : Any = logging.getLogger(__name__) class lowerCAmelCase__ : def __init__( self : ...
182
from __future__ import annotations snake_case : Optional[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def __init__( self : ...
182
1
'''simple docstring''' import math import sys def _lowercase ( UpperCamelCase__ : str ): __A : Optional[Any] = '' try: with open(UpperCamelCase__, 'rb' ) as binary_file: __A : str = binary_file.read() for dat in data: __A : Tuple = f"""{...
365
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { 'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/config.js...
365
1
'''simple docstring''' from __future__ import annotations from math import pi def lowerCamelCase_ ( lowercase__ , lowercase__ , lowercase__): if (inductance, frequency, reactance).count(0) != 1: raise ValueError("One and only one argument must be 0") if inductance < 0: ...
187
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class lowercase ( tf.keras.layers.Layer ): '''simple docstring''' def __init__( self : Union[str, Any] , __lowerCamelCase : str , __lowerCamelCase : in...
187
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "https://huggingface.c...
492
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor _UpperCamelCase = logging.get_logger(__name__) class __lowercase (_UpperCAmelCase ): def __init__( self , *A_ , **A_ ) ->None: '''simple docst...
492
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
718
from __future__ import annotations from collections import Counter from random import random class _a : """simple docstring""" def __init__( self ): _lowercase ={} def __lowerCAmelCase ( self , lowerCAmelCase_ ): _lowercase ={} def __lowerCAmelCase ( ...
594
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowercase : int ={"""configuration_vit_mae""": ["""VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTMAEConfi...
54
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE...
118
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
720
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase ={ "configuration_distilbert": [ "DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_...
405
0
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_availa...
48
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def A ( UpperCamelCase_ : List[Any] , UpperCamelCase_ : int , UpperCamelCase_ : List[Any] ) -> Dict: '''simple docstring''' lowerCAmelC...
48
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : List[str] = {'configuration_timm_backbone': ['TimmBackboneConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ex...
702
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer _a : str = logging.get_logger(__name__) ...
84
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __UpperCAmelCase = { '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config'''...
90
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def _snake_case ( A , A , A ) -> Union[str, Any]: lowerCAmelCase__ = OmegaConf.load(A ) ...
90
1
import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_checkpoint_callback, get_...
702
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwr...
590
0
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def __snake_case ( lowerCamelCase_ : int , lowerCamelCase_ : bool = True , lowerCamelCase_ : float = math.inf , lowerCamelCase_ : float = -math.in...
664
'''simple docstring''' import torch from transformers import AutoModel class UpperCamelCase_ ( torch.nn.Module ): """simple docstring""" def __init__( self : Any , _lowerCamelCase : Optional[int]="sayef/fsner-bert-base-uncased" ) -> List[An...
664
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase : List[Any] = { '''configuration_conditional_detr''': [ '''CONDITIONAL_DETR_...
709
"""simple docstring""" from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, ...
21
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image...
444
'''simple docstring''' from __future__ import annotations from math import gcd def lowercase (_A , _A = 2 , _A = 1 , _A = 3 , ): """simple docstring""" if num < 2: raise ValueError('The input value cann...
444
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) class a ( a_ ): def __init__( self , *_lowerCamelCase , **_lowerCam...
134
"""simple docstring""" import math import unittest def _SCREAMING_SNAKE_CASE ( __snake_case : int ): '''simple docstring''' assert isinstance(__snake_case , __snake_case ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: ...
134
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : int = { 'configuration_distilbert': [ 'DISTILBERT_PRETRA...
670
from manim import * class lowercase_ ( __snake_case ): def UpperCamelCase ( self ): _snake_case : Tuple = Rectangle(height=0.5 , width=0.5 ) _snake_case : List[str] = Rectangle(height=0.46 , width=0.46 ).se...
670
1
from typing import List import numpy as np def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : List[Any] = {key: len(SCREAMING_SNAKE_CASE__ ) for key, value in gen_kwargs.items() if isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ )} if len(set(lists_lengths.v...
230
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging lowercase_ = logging.get_logger(__name__) def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Union[str, Any] ...
230
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
413
import warnings from ..trainer import Trainer from ..utils import logging _SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) class A ( lowerCamelCase_ ): '''simple docstring''' def __init__( self : List[str] , _UpperCamelCase : ...
226
0
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( ...
713
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normaliz...
299
0
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_sched...
16
"""simple docstring""" import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py A = 'src/transformers' # This is to make sure the tra...
449
0
from math import factorial def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ = 1_0_0 ): return sum(int(UpperCamelCase__ ) for x in str(factorial(UpperCamelCase__ ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: ").strip())))
712
def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ = 5_0_0_0_0_0_0_0 ): UpperCamelCase__ : Any = set() UpperCamelCase__ : Any = int((limit - 2_4) ** (1 / 2) ) UpperCamelCase__ : Dict = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ...
462
0
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_tor...
75
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compressio...
701
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowerCAmelCase = logging.get_logger(__name__) # TODO: upload to AWS _lowerCAmelCase = { """yjernite/retribert-base-uncased""": ( """https://huggingface.co/yjernite/retribert-base-uncased/resolve/main...
481
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.uti...
26
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class SCREAMING_SNAKE_CASE_ ( nn.Module ): '''simple docstring''' def __init__( self : Union[str, Any] , SCREAMING_SNAKE_CASE__ : ...
305
0
from __future__ import annotations class a : def __init__( self , _lowerCAmelCase ): """simple docstring""" __SCREAMING_SNAKE_CASE: Optional[Any] = order # a_{0} ... a_{k} __SCREAMING_SNAKE_CASE: Any ...
713
from math import isclose, sqrt def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> tuple[float, float, float]: """simple docstring""" __SCREAMING_SNAKE_CASE: int = ...
146
0
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): if number < 0 or shift_amount < 0: raise ValueError('''both inputs must be positive integers''' ) snake_case_ = str(bin(SCREAMING_SNAKE_CASE__ ) ) binary_number += "0" * shi...
39
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class snake_case_ ( __A ): '''simple docstring''' def __init__( self : Dic...
39
1
import unittest from knapsack import knapsack as k class UpperCAmelCase( unittest.TestCase ): """simple docstring""" def __a ( self ) -> Union[str, Any]: """simple docstring""" lowercase__ : Optional[Any] ...
705
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers im...
298
0
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHeadsM...
20
from manim import * class lowercase_ (lowercase__ ): def __UpperCamelCase ( self) -> List[Any]: a__ =Rectangle(height=0.5 , width=0.5) a__ =Rectangle(height=0.46 , width=0.46).set_stroke(width=0) a__ =[mem.copy() for...
20
1
'''simple docstring''' __magic_name__ ={ '''Pillow''': '''Pillow<10.0.0''', '''accelerate''': '''accelerate>=0.20.3''', '''av''': '''av==9.2.0''', '''beautifulsoup4''': '''beautifulsoup4''', '''black''': '''black~=23.1''', '''codecarbon''': '''codecarbon==1.2.0''', '...
715
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__ =logging.get_logger(__name__) __magic_name__ =...
469
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow fr...
647
import math import unittest def lowerCAmelCase__ ( lowerCamelCase_ : int): '''simple docstring''' assert isinstance(lowerCamelCase_ ,lowerCamelCase_) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 a...
647
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a: List[Any] = logging.get_logger(__name__) _a: Union[str, Any] = { """andreasmadsen/efficient_mlm_m0.40""": (...
707
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_res...
268
0
import torch def snake_case ( ): '''simple docstring''' if torch.cuda.is_available(): __lowercase = torch.cuda.device_count() else: __lowercase = 0 print(F'Successfully ran on {num_gpus} GPUs' ) if __name__ == "__main__": main()
80
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
98
0
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) def lowerCAmelCase_ ( lowerCamelCase ): __mag...
367
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase_ : Dict = 637_8137.0 UpperCAmelCase_ : List[Any] = 635_6752.31_4245 UpperCAmelCase_ : List[str] = 6378137 def lowerCAmelCase_ ( l...
367
1
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> List[Any]: while a != 0: snake_case__ : Tuple = b % a, a return b def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> str: ...
374
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowercase_: Tuple = { 'tiny.en': 'https://openaipublic.azureedge.net/main/wh...
648
0
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingS...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : Any = logging.get_logger(__name__) _lowerCAmelCase : Tuple = {} class __snake_case ( SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ = 'llama' SCREAMING_SNAKE_CASE...
604
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _snake_case : str ...
81
def __lowerCamelCase ( __a :int ) -> Dict: """simple docstring""" A__ = len(__a ) A__ = sum(__a ) A__ = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n + 1 ): A__ ...
176
0
"""simple docstring""" import os import pytest from transformers.dynamic_module_utils import get_imports a__ : Optional[Any] = """ import os """ a__ : Optional[Any] = """ def foo(): import os return False """ a__ : Tuple = """ def foo(): def...
720
"""simple docstring""" import qiskit def A__ ( __lowerCamelCase, __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register _lowerCAmelCase = qiskit.QuantumCirc...
309
0
'''simple docstring''' from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class __snake_case ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ = CustomTokenizer pass
38
'''simple docstring''' from collections.abc import Callable class __snake_case : """simple docstring""" def __init__( self : Tuple , lowerCamelCase : Callable | None = None ) -> None: # Stores actual heap items. ...
275
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ : List[str] =logging.get_logger(__name__) snake_case_ : str ={ "facebook/xlm-roberta-xl"...
712
snake_case_ : str =[0, 2, 4, 6, 8] snake_case_ : List[str] =[1, 3, 5, 7, 9] def UpperCAmelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' if remaining_length == 0: if ...
205
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffus...
92
"""simple docstring""" import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedToke...
616
0
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLayer, ...
688
from argparse import ArgumentParser from .env import EnvironmentCommand def __SCREAMING_SNAKE_CASE ( ) -> List[str]: __lowercase = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) __lowercase = parser.add_subparsers(help='diffusers-cl...
688
1
"""simple docstring""" import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf ...
259
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __UpperCamelCase ( unittest.TestCase ): def __lowerCamelCase ( self ): '''simple docs...
259
1
'''simple docstring''' import math from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'facebook/data2vec-base-960h': 'https://huggingface.co/facebook/data2vec-audio-base-960...
710
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepIn...
388
0
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def UpperCamelCase ( _A ): """simple do...
324
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer __magic_name__: Optional[int] = logging.get_logger(__name__...
324
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCamelCase : Tuple ={'''tokenization_bertweet''': ['''BertweetTokenizer''']} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys ...
237
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowerCamelCase : Tuple =logging.get_logger(__name__) lowerCamelCase : Union[str, Any] ={ ...
237
1
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def a__ ( ...
98
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class _lowerCamelCase ( UpperCamelCase , UpperCamelCase ): """simple docstring""" @re...
590
0
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin A__ : Tuple= get_t...
20
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_mo...
20
1
import os def UpperCAmelCase__ ( __snake_case ) -> Dict: _A = len(grid[0] ) _A = len(snake_case_ ) _A = 0 _A = 0 _A = 0 # Check vertically, horizontally, diagonally at the same time (only works # for ...
317
"""simple docstring""" import numpy as np def A_ ( snake_case_ : Tuple ,snake_case_ : Any ,snake_case_ : str ,snake_case_ : Optional[int] ,snake_case_ : List[str] ): '''simple docstring''' UpperCamelCase : int = int(np...
499
0
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class SCREAMING_SNAKE_CASE ( datasets.BeamBasedBuilder ): """simple docstring""" def...
62
import math def __A ( _lowercase ): '''simple docstring''' _A = [] _A = 2 _A = int(math.sqrt(_lowercase ) ) # Size of every segment _A = [True] * (end + 1) _A = [] while start <= end: if temp[start] is True...
62
1
from typing import Any import numpy as np def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> Union[str, Any]: return np.array_equal(lowerCAmelCase__ , matrix.conjugate().T ) def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Optional[Any]: SCREAMING_...
345
def UpperCamelCase_ ( lowerCAmelCase__ , lowerCAmelCase__ ): """simple docstring""" if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _lowerCAmelCase : Optional[int] = str(bin(lowerCAmelCase__ ) )[2:] # remove the leading...
424
0
'''simple docstring''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ (lowerCamelCase__ ): """simple docstring""" SCREAMING_SNAKE_CASE : Tuple = (C...
713
'''simple docstring''' import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowercase_ (lowerCamelCase__ ): """simple docstring""" def __init__( self : Optional[Any] ...
624
0
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCAmelCase ( UpperCAmelCase__ : Optional[int] , UpperCAmelCase__ : List[str]): lowerCamelCase : int = list(U...
320
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def _SCREAMING_SNAKE_CASE ( UpperCamelCase="ro" , UpperCamelCase="en" , UpperCamelCase="wmt16" , UpperCamelCase=None ): """simple docstring""" try: import datasets ...
565
0
"""simple docstring""" from __future__ import annotations def lowerCAmelCase__ ( _UpperCamelCase : int | str ) -> bool: """simple docstring""" snake_case = str(_UpperCamelCase ) return n == n[::-1] def ...
704
"""simple docstring""" import math def lowerCAmelCase__ ( _UpperCamelCase : int ) -> bool: """simple docstring""" return math.sqrt(_UpperCamelCase ) * math.sqrt(_UpperCamelCase ) == num def lowerCAmelCase__ ( _UpperCa...
104
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem SCREAMING_SNAKE_CASE = importlib.util.find_spec('s3fs') is not None if _has_safs: from .s...
99
1
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _UpperCamelCase : int = False class _lowerCAmelCase( unittest.TestCase): """simple docstrin...
341
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_...
341
1