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
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 10, """max_num_...
5
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( A__ , A__ , A__ , ) -> tuple[str, float]: """simple docstring""" if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('Y...
430
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from ...
10
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Any = logging.get_logger(__name__) _a : int = { "facebook/s2t-wav2vec2-large-en-de": ( "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main...
10
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE = { '''configuration_layoutlmv2''': ['...
502
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( lowerCamelCase_ : list[int | str] ): create_state_space_tree(lowerCamelCase_ , [] , 0 , [0 for i in range(len(lowerCamelCase_ ) )] ) def _lowerCAmel...
502
1
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( lowercase_ ): '''simple docstring''' SCREAMING_SNAKE_CASE = ["image_processor", "tokenizer"] SCREAMING_SNAKE_CASE = ...
702
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> list[list[int]]: """simple docstring""" __A = [] __A = [] __A = 0 __A = sum(__lowercase ) create_st...
199
0
'''simple docstring''' import random from typing import Any def __a(SCREAMING_SNAKE_CASE_ : list ): '''simple docstring''' for _ in range(len(SCREAMING_SNAKE_CASE_ ) ): _lowerCAmelCase = random.randint(0 , len(SCREAMING_SNAKE_CASE_ ) - 1 ...
18
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeTowerConfi...
296
0
def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' lowerCamelCase_ : Optional[Any] = 0 lowerCamelCase_ : Dict = len(lowerCAmelCase_) - 1 while left <= right: # avoid divided by 0 during interpolation if...
73
from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', # See all Cvt models at https://hug...
73
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase, UpperCAmelCase = "x", UpperCAmelCase = 10**-10, UpperCAmelCase = 1, )-> complex: """simple docstring""" lower...
604
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMSchedul...
604
1
'''simple docstring''' def _lowerCAmelCase ( __a , __a ) -> list: '''simple docstring''' _UpperCamelCase :List[Any] =word.split() def justify(__a , __a , __a ) -> str: _UpperCamelCase :Any =max_width - width _Upper...
512
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCamelCase : Optional[int] = HfApi() _lowerCamelCase : Union[str, Any] = {} # fmt: off _lowerCamelCase : List[Any] ...
512
1
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase__ : List[str] ...
312
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline...
56
0
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ...t...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase: Any = { '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
225
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase__ ) class snake_case__ ( UpperCamelCase__ ): # `task` is not a ClassVar since we want it to ...
666
from collections.abc import Sequence def lowerCAmelCase_ ( lowerCamelCase = None ): if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) __magic_name__ : str =nums[0] for i in range(1 , len(lowerCamelCase ) ...
21
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE : Tuple = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvNextC...
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
def __lowerCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> Any: assert x is not None assert y is not None _UpperCAmelCase = len(_lowerCAmelCase ) _UpperCAmelCase = len(_lowerCAmelCase ) # declaring the array for storing the dp values _UpperCAme...
684
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __lowerCAmelCase = { ...
684
1
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_d...
713
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def _lowerCAmelCase (_lowercase ): """simple docstring""" if "model" in orig_key: a__ = orig_key.replace("model." , "" ) ...
394
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block ...
386
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''roberta-base''': '''https://huggingface.co/roberta-b...
282
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, ) UpperCAmelCase__ : List[Any] = { 'conf...
545
"""simple docstring""" UpperCAmelCase__ : Dict = [ (1_0_0_0, 'M'), (9_0_0, 'CM'), (5_0_0, 'D'), (4_0_0, 'CD'), (1_0_0, 'C'), (9_0, 'XC'), (5_0, 'L'), (4_0, 'XL'), (1_0, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I'), ] d...
545
1
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging __a :int = logging.get_logger(__name__) def __snake...
86
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) UpperCAmelCase : Union[str, Any] = logging.getLogger(__n...
563
0
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import log...
712
import random from typing import Any def SCREAMING_SNAKE_CASE_ ( __magic_name__ : list ) -> list[Any]: """simple docstring""" for _ in range(len(__magic_name__ ) ): UpperCamelCase :Dict = random.randint(0 , len(__magic_name__ ) - 1 )...
590
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) __A = {'vocab_file': 'spiece.model'} __A = { ...
484
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __A ( _lowercase ): '''simple docstring''' return sum(param.float().sum() if '''en...
484
1
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_ava...
265
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILIma...
265
1
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.huggingface i...
162
from copy import deepcopy class __UpperCamelCase : def __init__( self : List[str] , lowerCAmelCase : list[int] | None = None , lowerCAmelCase : int | None = None ): '''simple docstring''' if arr is None and size is not None: UpperCAmelCase_ ...
162
1
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCAmelCase__ : list[int...
721
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCas...
545
0
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets _UpperCamelCase : str = "\\n@inproceedings{popovic-2015-chrf,\n title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",\n author = \"Popovi{\'...
284
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCamelCase : str = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeo...
284
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment,...
719
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _lowercase ...
4
0
"""simple docstring""" from __future__ import annotations class lowercase__ : """simple docstring""" def __init__( self , _A ): '''simple docstring''' UpperCamelCase : Union[str, Any] = ...
102
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : int = 10 , _lowerCamelCase : int = 1000 , _lowerCamelCase : bool = True ) -> int: assert ( isinstance(_lowerCamelCase , _lowerCamelCase ) an...
549
0
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ...
700
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu...
95
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : str =logging.get_logger(__name__) class snake_case ( _UpperCAmelCase , _UpperC...
399
"""simple docstring""" # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position __lowercase : Optional[Any] = "2.13.1" import platform import pyarrow from packaging import version if version.parse(platform.python...
564
0
from __future__ import annotations from dataclasses import dataclass @dataclass class _lowerCamelCase: lowercase_ : float lowercase_ : TreeNode | None = None lowercase_ : TreeNode | None = None def UpperCamelCase_( lowerCamelCase_ ) ...
354
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _lowerCamelCase( unittest.TestCa...
354
1
from __future__ import annotations def _UpperCAmelCase ( A , A = None , A = None ): '''simple docstring''' if start is None: UpperCAmelCase__ =0 if end is None: UpperCAmelCase__ =len(snake_case__ ) - 1 if s...
625
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cache...
180
0
'''simple docstring''' from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyN...
27
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = {} try: if not is_sentencepiece_available(): raise Op...
27
1
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np lowerCAmelCase_ : str = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 lowerCAmelCase_ : List[str] = typing.Union[n...
692
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __A ( SCREAMING_SNAKE_CASE_ ): ...
213
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( SCREAMING_SNAKE_CASE_ ): UpperCAmelCase__ = "ClapFeatureExtractor" UpperCAmelCase__ = ("RobertaTokenizer", "Rob...
213
1
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline __lowercase : Any =datasets.utils....
54
from importlib import import_module from .logging import get_logger UpperCAmelCase : Union[str, Any] = get_logger(__name__) class _A: """simple docstring""" def __init__( self , _A , _A=None ): __A : Union[str, Any] = attrs or [] if mod...
239
0
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : str ): return "".join(chr(ord(_lowerCAmelCase ) - 32 ) if """a""" <= char <= """z""" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
173
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAt...
173
1
from collections import defaultdict from math import ceil, sqrt def UpperCAmelCase__ ( lowerCamelCase_ : int = 1_0_0_0_0_0_0 , lowerCamelCase_ : int = 1_0 ): __a : Optional[Any] = defaultdict(a__ ) for outer_width in range(3 ,...
47
"""simple docstring""" from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase = 6_37_81_37.0 UpperCAmelCase = 6_35_67_52.31_42_45 UpperCAmelCase = 6_378_137 def lowercase ( a__ : float , a__ : float ...
420
0
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch A : Tuple = "sshleifer/bart-tiny-random" A : List...
719
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging A : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name class _UpperCame...
282
0
'''simple docstring''' _lowerCAmelCase :List[Any] = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git...
251
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @requi...
251
1
'''simple docstring''' import os import sys import transformers _SCREAMING_SNAKE_CASE = "3" print("Python version:", sys.version) print("transformers version:", transformers.__version__) try: import torch print("Torch version:", torch.__version__) print("Cuda available:", ...
706
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lower...
517
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple def _snake_case ( __snake_case : float , __snake_case : float , __snake_case : float ): """simple docstring""" _lowerCamelCase :...
88
import os import sys import unittest __UpperCamelCase : List[str] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_f...
328
0
import numpy as np from PIL import Image def _UpperCAmelCase ( _SCREAMING_SNAKE_CASE : np.ndarray , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): """simple docstring""" SCREAMING_SNAKE_CASE_ = np.array(_SCREAMING_SNAKE_CASE ) ...
620
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __snake_case ( lower...
620
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { """s-JoL/Open-Llama-V1""": """https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json""", } class UpperCAmelCase (...
583
def lowerCamelCase_ ( UpperCAmelCase_ : list[int] ): lowercase : Union[str, Any] = len(UpperCAmelCase_ ) for i in range(UpperCAmelCase_ ): for j in range(i + 1 , UpperCAmelCase_ ): if numbers[j] < numb...
583
1
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """microsoft/xprophetnet-large-wiki100-cased""": ( """https://huggingface.co/microsoft/...
70
def UpperCamelCase ( __lowercase : int ): '''simple docstring''' if length <= 0 or not isinstance(__lowercase ,__lowercase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowercase )] if __name__ == "__main__": print(h...
70
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": __a : Any = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """))) print("""Googlin...
534
def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" __lowercase = len(lowercase ) __lowercase = len(lowercase ) __lowercase = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] __lowercase ...
534
1
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/...
28
"""simple docstring""" import os import sys import unittest A_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files...
28
1
"""simple docstring""" def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return x if y == 0 else greatest_common_divisor(lowerCAmelCase__ , x % y ) def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return (x * y) // greatest_common_divisor(lowerCA...
82
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : Tuple = logging.get_logger(__name__) UpperCamelCase : Union[str, Any] = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-...
50
0
from math import sqrt def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): 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, all even numbers, all multiples of 3 are not primes return False # All primes number are in forma...
230
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {'configuration_opt': ['OPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'OPTConfig']} try: ...
230
1
def __snake_case ( _UpperCamelCase=2_81_23 ) -> Optional[Any]: _a = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_divs[k * i] += k + i _a = set() _a = 0 for n in ra...
487
def __snake_case ( _UpperCamelCase ) -> int: _a = len(_UpperCamelCase ) _a = sum(_UpperCamelCase ) _a = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n + 1 ): _a = True for i in range(1 , s + 1 ): _a = F...
487
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : Dict = { 'configuration_electra': ['ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP'...
709
import requests snake_case : int = '' # <-- Put your OpenWeatherMap appid here! snake_case : int = 'https://api.openweathermap.org/data/2.5/' def snake_case__ ( __lowercase = "Chicago" , __lowercase = APPID ) -> dict: """simple docstring""" ...
182
0
import math import sys def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: int ): if number != int(UpperCamelCase__ ): raise ValueError("""the value of input must be a natural number""" ) if number < 0: raise ValueError("""the value of input must not be a negative number"...
6
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since the...
233
0
import baseaa def __UpperCAmelCase ( __a : str ) -> bytes: """simple docstring""" return baseaa.aaaencode(string.encode('''utf-8''' ) ) def __UpperCAmelCase ( __a : bytes ) -> str: """simple docstring""" return baseaa.aaadec...
715
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlitea ...
578
0
class _A ( __UpperCamelCase ): pass class _A ( __UpperCamelCase ): pass class _A : def __init__(self ) -> Optional[Any]: '''simple docstring''' UpperCamelCase__ = [ [], [], ...
415
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __magic_name__ =True ...
415
1
def A_ ( __a : int , __a : int ): """simple docstring""" return "\n".join( F'''{number} * {i} = {number * i}''' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10))
351
import os from datetime import datetime as dt from github import Github UpperCAmelCase = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ] def ...
351
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils impo...
27
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer __ma...
276
0
"""simple docstring""" import argparse 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_dummies.py __lowercase = '''src/diffusers''' # Matches is_xxx_available() __lowercase = re...
296
"""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 def...
296
1
import math def a ( ): '''simple docstring''' lowercase_ = input('''Enter message: ''' ) lowercase_ = int(input(F'''Enter key [2-{len(snake_case__ ) - 1}]: ''' ) ) lowercase_ = input('''Encryption/Decryption [e/d]: ''' ) if mode.lower().st...
97
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
1
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def SCREAMING_SNAKE_CASE__( a__): _SCREAMING_SNAKE_CASE ={} _SCREAMING_SNAKE_CASE =tokenizer(example['''content...
721
# 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 a...
191
0
"""simple docstring""" import os import re import shutil import sys import tempfile import unittest import black A = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_copies # noqa: E402 # This is...
77
def _lowercase ( UpperCAmelCase_=28_123): """simple docstring""" snake_case__ : Dict = [1] * (limit + 1) for i in range(2 , int(limit**0.5) + 1): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1): sum_divs[k * i] += k + i sn...
648
0
'''simple docstring''' def __lowercase (_lowercase = 10 ) -> int: """simple docstring""" if not isinstance(__snake_case, __snake_case ) or n < 0: raise ValueError("""Invalid input""" ) __lowerCamelCase : int = 10**n __lowerCamelCase...
705
'''simple docstring''' UpperCAmelCase__ :List[Any] = 256 # Modulus to hash a string UpperCAmelCase__ :str = 1_000_003 def __lowercase (_lowercase, _lowercase ) -> bool: """simple docstring""" __lowerCamelCase : str = len(_lowerc...
483
0
'''simple docstring''' import re def _snake_case ( _SCREAMING_SNAKE_CASE : str ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , __UpperCamelCase ) ) != len(__UpperCamelCase ): raise ValueError("""Invalid Strand""" ...
433
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCAmelCase_ ( nn.Module ): __UpperCAmelCase =42 __Uppe...
292
0
def _A( UpperCamelCase__ : int = 6008_5147_5143 ) -> int: '''simple docstring''' try: __lowercase = int(UpperCamelCase__ ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ) ...
721
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassifi...
362
0
from ..utils import DummyObject, requires_backends class __lowercase ( metaclass=A ): '''simple docstring''' _A : Union[str, Any] = ['''note_seq'''] def __init__( self : str , *_a : int , **_a : Any ): ...
240
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.ut...
240
1
class __lowerCAmelCase : # Public class to implement a graph """simple docstring""" def __init__( self , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> None: '''simple docstring''' __lowerCamelCase = row ...
705
__A = "Input must be a string of 8 numbers plus letter" __A = "TRWAGMYFPDXBNJZSQVHLCKE" def lowerCamelCase_ ( UpperCamelCase__ : str ) -> bool: """simple docstring""" if not isinstance(UpperCamelCase__ , UpperCamelCase__ ): ...
167
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : str = logging.get_logger(__name__) _lowerCAmelCase : List[Any] = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } c...
246
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def __snake_case ( __A ) -> Any: def wrapper(*__A ,**__A ): lowercase : Tuple ...
607
0
"""simple docstring""" import sys def snake_case__ ( _lowerCamelCase ) ->Union[str, Any]: """simple docstring""" __lowercase : Tuple = len(_lowerCamelCase ) __lowercase : str = [[0 for x in range(_lowerCamelCase )] for x in range(...
718
"""simple docstring""" from __future__ import annotations def snake_case__ ( _lowerCamelCase, _lowerCamelCase = None ) ->list[list[str]]: """simple docstring""" __lowercase : List[Any] = word_bank or [] # create a table __lowercase : int ...
281
0
from __future__ import annotations def __lowerCAmelCase( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Dict: """simple docstring""" if len(_SCREAMING_SNAKE_CASE ) <= 1 or n <= 1: return insert_next(_SCREAMING_SNAKE_CAS...
27
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _SCREAMING_SNAKE_CASE : str = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwiftFormerConfig''', ...
493
0
def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> list: lowercase__ : Optional[Any] = [0] * len(SCREAMING_SNAKE_CASE_ ) for i in range(1 ,len(SCREAMING_SNAKE_CASE_ ) ): # use last results for better performance - dynamic p...
703
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
298
0
from __future__ import annotations import math def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" if depth < 0: raise ValueError('''Depth cannot be less ...
43
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __lowerCAmelCase ( UpperCAmelCase__ : str , UpperCAmelCase__ : str , **UpperCAmelCase__ : List[str] ) -> Tuple: lowerCamelCase_ = AutoConfig.from_...
272
0
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __A ( a ): __A = [""...
269
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase__ : List[Any] ={'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: ...
269
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See all CANINE models at http...
11
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy a...
250
0
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _A = [ # tf -> hf ("/", "."), ("layer_", "layers."), ("kernel", "weight"), ("bet...
294
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_tensor,...
294
1
import baseaa def lowercase ( __A : str ) -> bytes: '''simple docstring''' return baseaa.baaencode(string.encode("""utf-8""" ) ) def lowercase ( __A : bytes ) -> str: '''simple docstring''' return baseaa.baadecode(__A ).decode(...
36
"""simple docstring""" from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( lowercase ): """simple docstring""" a : int ="SpeechT5FeatureExtractor" a : Any ="SpeechT5Tokenizer" def __init__( self , snake_case...
645
0
"""simple docstring""" from __future__ import annotations import math def _a ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' _UpperCAmelCase = u for i in range(1 , _SCREA...
700
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu...
95
0
from __future__ import annotations from typing import TypedDict class a ( lowercase__ ): """simple docstring""" a : str a : int def lowerCamelCase__ ( __lowerCamelCase : str ): if not isinstance(__lowe...
63
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampl...
631
0
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def __magic_name__( lowerCamelCase ): if "cls_token" in name: __lowerCAmelCase =...
710
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetectio...
474
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extra...
125
'''simple docstring''' import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_N...
125
1
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impo...
719
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamp...
649
0
from __future__ import annotations from statistics import mean def __lowerCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: _UpperCAmelCase = [0] * no_of_processes _UpperCAmelCase = [0] * no_of_processes # Initialize r...
684
import argparse import math import traceback import dateutil.parser as date_parser import requests def __lowerCamelCase ( _lowerCAmelCase ) -> Any: _UpperCAmelCase = {} _UpperCAmelCase = job["started_at"] _UpperCAmelCase = job["completed_at"]...
684
1
'''simple docstring''' class __SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Optional[int] ): _a = 0 _a = 0 _a = {} def UpperCamelCase__ ( self : Op...
521
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import ta...
521
1
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class _snake_case ( _snake_case , unittest.TestCase ):...
445
import qiskit def __lowerCamelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ): """simple docstring""" a :Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register a :str = qi...
445
1
import os from collections.abc import Iterator def __lowerCamelCase ( __a :str = "." ) -> str: """simple docstring""" for dir_path, dir_names, filenames in os.walk(_SCREAMING_SNAKE_CASE ): A__ = [d for d in dir_names if d...
707
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class A (datasets.BuilderConfig ): '''simple docstring''' __lowerCamelCase :...
247
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_ = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], ...
34
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging A__ = logging.get_logger(__name__) class a : __lowerCAmelCase : Optional[Any] = None @experimental def _lowerCAmelCas...
252
0
from typing import Dict, List, Optional, Tuple, 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, resize, to_channel_dimensio...
469
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging __magic_name__ =logging.get_logger(__name__) # pylint: disable=invalid-name class _A ( __UpperCamelCase ...
469
1
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) class _lo...
89
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common i...
484
0
'''simple docstring''' import operator def A__ ( A : list , A : bool = False , A : list | None = None): '''simple docstring''' UpperCamelCase : List[Any] = operator.lt if reverse else operator.gt UpperCamelCase : Union[str, Any...
435
'''simple docstring''' from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures...
435
1
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_torch_available, is_visio...
477
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 class snake_case ( en...
477
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase__ = { '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxConfig'''], ...
720
"""simple docstring""" def UpperCAmelCase ( snake_case : int , snake_case : int ): return x if y == 0 else greatest_common_divisor(snake_case , x % y ) def UpperCAmelCase ( snake_case : int , snake_case : int ): ...
439
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/ma...
507
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 _snake_case ( datasets.BeamBasedBuilder ): def SCREAMING_SNAKE_CASE__ ( self ...
445
0
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
461
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from ac...
461
1
"""simple docstring""" _lowerCAmelCase : Union[str, Any] = "Input must be a string of 8 numbers plus letter" _lowerCAmelCase : List[str] = "TRWAGMYFPDXBNJZSQVHLCKE" def __snake_case ( SCREAMING_SNAKE_CASE__ : str ) -> bool: '''simple docstring''' i...
289
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class UpperCAmelCase_ ( _UpperCamelCase ): def __lt__( self : int , A : Dict ): return ...
289
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
678
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available a_ : Union[str, Any] = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: if not is_to...
678
1
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def lowercase (_lowerCAmelCase ): def decorator(_lowerCAmelCase ): __lowerCAmelCase = getattr(_lowerCAmelCase , """handle_key""" , [] ) handle += [key] ...
465
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''alibaba-damo/mgp-str-base''': '''https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/conf...
465
1
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __SCREAMING_SNAKE_CASE ( ) -> Optional[Any]: """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename ...
721
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor...
375
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer lowerCAmelCase : str = {"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokeniz...
202
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) ...
202
1
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common ...
226
from __future__ import annotations from functools import lru_cache from math import ceil lowerCamelCase__ = 1_00 lowerCamelCase__ = set(range(3, NUM_PRIMES, 2)) primes.add(2) lowerCamelCase__ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: ...
226
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowercase : Any = logging.get_logger(__name__) __lowercase : List[Any...
422
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTest...
179
0
"""simple docstring""" def lowercase_ ( _snake_case ): if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""" ) for cell_n in range(1 ,len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] ...
545
"""simple docstring""" import baseaa def lowercase_ ( _snake_case ): return baseaa.baaencode(string.encode("""utf-8""" ) ) def lowercase_ ( _snake_case ): return baseaa.baadecode(_snake_case ).decode("""utf-8""" ) if __name__ == "__main__": UpperCAmelC...
545
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose...
173
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ = { 'configuration_nezha': ['NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NezhaConfig'], } try: if not is_torch_availabl...
173
1
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 lowerCamelCase__ = """src/transformers""" # This is to make sure the transformers...
709
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' lowerCamelCase : int lowerCamelCase : int ...
291
0
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow _lowerCAmelCase: List[str] = logging.getLogger() @unittest.skip('Temporarily disable the d...
20
"""simple docstring""" from ...configuration_utils import PretrainedConfig class a ( lowercase ): UpperCamelCase : Union[str, Any] = """bert-generation""" def __init__( self , UpperCamelCase_=50_358 , UpperCamelCase_=1_024 , UpperCamelCase_=24 ...
110
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_mo...
706
"""simple docstring""" class lowerCAmelCase : '''simple docstring''' def __init__( self :Optional[Any] , lowerCamelCase_ :list ) -> None: """simple docstring""" UpperCamelCase__ = set_counts Upper...
304
0