code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def lowerCAmelCase ( lowerCAmelCase_ = 100 )-> int: lowerCAmelCase_ : Any = n * (n + 1) * (2 * n + 1) / 6 lowerCAmelCase_ : Any = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(f"""{soluti...
262
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Optional[Any] =logging.get_logger(__name__) _UpperCAmelCase : str ={ """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json""", # See all ViT MAE mo...
262
1
from __future__ import annotations import math def __lowercase ( a__ , a__ ) -> float: __SCREAMING_SNAKE_CASE = u for i in range(1 , a__ ): __SCREAMING_SNAKE_CASE = temp * (u - i) return temp def ...
363
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class UpperCAmelCase_ ( UpperCamelCase_ ): '''simple docstring''' ...
118
0
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging SCREAMING_SNAKE_CASE_: Optional[An...
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging SCREAMING_SNAKE_CASE__ : Optional[...
48
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( snake_case )-> Optional[Any]: '''simple docstring''' if length <= 0 or not isinstance(lowerCamelCase__ , lowerCamelCase__ ): raise ValueError("Length must be a positive integer." ) retur...
350
"""simple docstring""" import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def SCREAMING_SNAKE_CASE__ ( snake_case : Dataset , snake_case : Dict[str, s...
298
0
'''simple docstring''' def __snake_case( _lowerCAmelCase ) -> int: assert isinstance(_lowerCAmelCase , _lowerCAmelCase ), f"The input value of [n={number}] is not an integer" if number == 1: return 2 elif number < 1: snake_case__ : Optional[Any] ...
35
'''simple docstring''' 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, ...
41
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils ...
114
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transfor...
114
1
import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTe...
227
import cmath import math def a( A : float , A : float , A : float , A : float ) -> complex: """simple docstring""" a = math.radians(A ) a = math.radians(A ) # Convert voltage and c...
227
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testin...
355
"""simple docstring""" import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowerCamelCase (a_ :int) -> int: # picklable for...
172
0
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _UpperCAmelCase : Any = get_tests_dir("""fixture...
50
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configurati...
217
0
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 lowerCAmelCase_ ( UpperCamelCase__ ): ...
367
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def lowerCAmelCase__ ( _UpperCamelCase : int = 8 ) -> str: """simple docstring""" snake_case ...
149
0
'''simple docstring''' import os from pathlib import Path def lowercase__ ( ) -> str: """simple docstring""" from torch.utils.cpp_extension import load __UpperCamelCase = Path(__lowercase ).resolve().parent.parent.parent / 'kernels' / 'deformable_detr' ...
53
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_bac...
66
0
"""simple docstring""" import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging _lowerCamelCase : List[Any] = logging.get_logger(__name__) class UpperCamelCase_ (...
370
from __future__ import annotations import queue class UpperCamelCase_ : '''simple docstring''' def __init__( self : Optional[Any] , UpperCAmelCase__ : Dict) ->Any: '''simple docstring''' A__ = data A__ = None ...
231
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # s...
313
from abc import ABC, abstractmethod from typing import List, Optional class a_ ( a__ ): """simple docstring""" def __init__( self ) ->List[str]: # test for the above condition self.test() def __lowerCAmelCase ( self ...
313
1
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _lowerCamelCase ( lowercase : NDArray[floataa] , lowercase : NDArray[floataa] , lowercase : list[int] , ...
371
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'): lowerCAmelCase_ : str = { 'linear': PIL.Image.Resampling.BILINEAR, ...
346
0
__lowerCamelCase : Union[str, Any] = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottametr...
52
"""simple docstring""" def _A ( lowercase , lowercase ): """simple docstring""" while second != 0: a =first & second first ^= second a =c << 1 return first if __name__ == "__main__": import doctest ...
81
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, Data...
323
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : List[Any] = { '''configuration_xlm_roberta'''...
323
1
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class snake_case__ ( _SCREAMING_SNAKE_CASE , unittest.TestC...
277
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import Confi...
222
0
'''simple docstring''' import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): A : List[str] = yaml.safe_load( '''\ name: "" allow_empty: false allow_empty_text: true subs...
227
'''simple docstring''' def lowerCAmelCase__ ( lowerCamelCase : int ,lowerCamelCase : list[int] ,lowerCamelCase : int ): def count_of_possible_combinations(lowerCamelCase : int ) -> int: if target < 0: return 0 ...
227
1
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import Onn...
232
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowercase : Optional[int] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # ...
232
1
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreTra...
361
from math import sqrt def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00_00_00 ): __UpperCamelCase : int = 0 __UpperCamelCase : int = 0 __UpperCamelCase : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_si...
171
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "google/bigbird-roberta-base"...
241
def a__ ( __UpperCamelCase ): if not head: return True # split the list to two parts SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = head.next, head while fast and fast.next: SCREAMING_SNAKE_CASE_ = fast.next.next SCREAM...
118
0
"""simple docstring""" 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 ( ...
57
"""simple docstring""" import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger __A : Union[str, Any] = get_logger(__name__) class __UpperCamelCase ( enum.Enum ): SCREAMING_SNAKE_CASE = "all_c...
57
1
'''simple docstring''' # DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configur...
67
'''simple docstring''' 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 A ( SCREA...
298
0
"""simple docstring""" import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def __UpperCAmelCase...
30
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( Bi...
30
1
from __future__ import annotations from functools import lru_cache from math import ceil a : int = 100 a : Union[str, Any] = set(range(3, NUM_PRIMES, 2)) primes.add(2) a : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes:...
114
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a : L...
114
1
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency SCREAMING_SNAKE_CASE_ : Any = { 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, '...
69
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets SCREAMING_SNAKE_CASE_ : List[str] = '\\n@inproceedings{snover-etal-2006-study,\n title = "A Study of Translation Edit Rate with Targeted Human Annotation",\n a...
69
1
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def...
317
"""simple docstring""" _a : Tuple= 8.3_1_4_4_5_9_8 def __UpperCAmelCase ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ) -> float: '''simple docstring''' if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) if...
172
0
"""simple docstring""" import re def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' _a : Union[str, Any] = re.compile( R"""^(?:0|94|\+94|0{2}94)""" R"""7(0|1|2|4|5|6|7|8)""" R"""(-| |)""" R"""\d{7}$""" ) return bool(re.search(...
324
"""simple docstring""" import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD...
324
1
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Optional[int] = { "en": "Machine learning is great, isn't it?"...
36
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES A__: List[Any] = logging.get_logger(__name__) A__: Any = OrderedDict...
149
0
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowerCAmelCase__ : List[str] =logging.get_logger(__name__) def __lowercase ( a__ ) -> List[int]: if isinstance(a__ , np.ndarray ): ...
118
from __future__ import annotations from collections.abc import Generator def __lowercase ( ) -> Generator[int, None, None]: __SCREAMING_SNAKE_CASE = {} __SCREAMING_SNAKE_CASE = 2 while True: __SCREAMING_SNAKE_CASE = factor_map.pop(a...
118
1
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : List[str] = { """huggingface/time-series-tran...
102
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lowerCAmelCase ( __a , unittest.TestCase ): _lo...
231
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
83
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from di...
83
1
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> List[str]: _enforce_args(lowerCamelCase_ , lowerCamelCase_ ) if n == 0: return 0 _lowercase : Union[str, Any] = float('-inf' ) for i in range(1 , n + 1 ): _lowercase ...
21
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/con...
346
0
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def SCREAMING_SNAKE_CASE_ ( )-> Generator[int, None, None]: _lowerCamelCase = {} _lowerCamelCase = 2 while True: _lowerCamelCase = factor_map.pop(lowe...
367
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : list )-> list: def merge(snake_case : list , snake_case : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0...
80
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoi...
323
'''simple docstring''' from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class UpperCamelCase__ ( lowercase_ ): """simple docst...
323
1
import argparse import os import re a_ = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ = re.compile(R"""[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict""") # re pattern that mat...
357
"""simple docstring""" import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( SCREAMING_SNAKE_CASE__ ...
291
0
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm imp...
227
import random def a( A : Optional[Any] , A : Optional[Any] , A : str ) -> List[Any]: """simple docstring""" a = a[left_index] a = left_index + 1 for j in range(left_index + 1 , A ): if a...
227
1
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if __...
109
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...
109
1
def a ( snake_case__: str , snake_case__: str ): '''simple docstring''' lowercase_ = len(snake_case__ ) lowercase_ = len(snake_case__ ) lowercase_ = ( first_str_length if first_str_length > second_str_length else ...
30
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _A = { """sample_size""": 32, """in_channels""": 3, """out_channels""": 3, """layers_per_block""": 2, """num_class_...
171
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int ) ->list[list[int]]: '''simple docstring''' a : List[Any] = [] if len(_lowerCamelCase ) == 1: return [nums.copy()] for _ in range(len(_lowerCamelCase ) ): a : i...
363
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig a : Optional[int] = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/m...
79
0
"""simple docstring""" import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Any =(DDPMParallelScheduler,) def snake_cas...
57
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Union[str, Any] =["""image_processor""", """t...
57
1
"""simple docstring""" from torch import nn class __snake_case ( nn.Module): def __init__( self : Optional[Any] , __lowerCAmelCase : Dict , __lowerCAmelCase : str ): """simple docstring""" super().__init__() _lower...
175
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetFor...
175
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __a = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} try: if n...
30
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, requir...
30
1
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from t...
71
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
71
1
"""simple docstring""" from collections import deque def UpperCAmelCase ( UpperCAmelCase ) -> int: snake_case_ = len(UpperCAmelCase ) snake_case_ = deque() snake_case_ = [False for _ in range(UpperCAmelCase )] snake_c...
69
"""simple docstring""" 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 __UpperCamelCase = logging.get_logger(__name__) __Up...
69
1
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class SCREAMING_SNAKE_CASE_ ( __lowerCAmelCase ): ...
354
import argparse _SCREAMING_SNAKE_CASE = """docs/source/_static/js/custom.js""" def lowercase( UpperCamelCase_ ) -> Union[str, Any]: '''simple docstring''' with open(UpperCamelCase_ , encoding="""utf-8""" , newline="""\n""" ) as f: UpperCamelCase = f....
165
0
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers....
302
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 if is_torch_available(): import torch ...
302
1
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def lowercase ( _snake_case : str ) ->Optional[Any]: """simple docstring""" def decorator(_snake_case : List[str] ): __snake_case : str = getattr(_snake_ca...
24
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
24
1
from collections import defaultdict from math import gcd def a__ ( __UpperCamelCase = 1_5_0_0_0_0_0 ): SCREAMING_SNAKE_CASE_ = defaultdict(__UpperCamelCase ) SCREAMING_SNAKE_CASE_ = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euc...
118
def a__ ( __UpperCamelCase = 1_0_0_0 ): SCREAMING_SNAKE_CASE_ = -1 SCREAMING_SNAKE_CASE_ = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c SCREAMING_SNAKE_CASE_ = (n * n - 2 * a *...
118
1
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers,...
9
'''simple docstring''' import argparse import datetime def __magic_name__( lowerCamelCase): __lowerCAmelCase = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', '''3''': '''Wednesday''', '''4''': '''Thur...
9
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Union[str, ...
83
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class lowercase__ ( lowercase ): @require_torch def UpperCamelCase_ ( self : Dict ): ...
83
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_com...
361
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase : List[str] = { """configuration_clip""": [ ...
225
0
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _UpperCAmelCase ( snake_case , snake_case , snake_case=None ): ...
82
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _UpperCamelCase ...
80
0
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutp...
207
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def a_ ( lowerCAmelCase_ : Optional[Any] ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.or...
207
1
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def UpperCAmelCase__ (snake_case__ : List[Any] ): """simple docstring""" if not is_accelerate_available...
64
'''simple docstring''' import os import numpy import onnx def a__ ( lowercase : List[str], lowercase : str ) -> List[Any]: """simple docstring""" _UpperCamelCase = a.name _UpperCamelCase = b.name _UpperCamelCase ...
324
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """sayakpaul/vit-msn-base""": """https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json""", # See all ViT MSN models at https://h...
224
from pathlib import Path import fire def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) dest_dir.mkdir(exist_ok=SCREAMING_SNAK...
224
1
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging A: Union[str, Any] = logging.get_logger(__name__) A: str = { "huggingface/informer-tourism-monthly": ( "https://huggingface.co/huggingf...
109
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def _snake_case ( UpperCamelCase : int = 1000000 , UpperCamelCase : int = 10 ): UpperCAmelCase : defaultdict = defaultdict(UpperCamelCase ) for outer_width in range(3 , (t_limit...
109
1
"""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 : int __UpperCAmelCase : int _...
112
"""simple docstring""" 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 __snake_case = logging.getLogger() @unittest.skip('''Temporarily...
112
1
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thin...
11
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets lowerCamelCase_ = datasets.logging.get_logger(__name__) lowerCamelCase_ = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C an...
79
0
"""simple docstring""" from collections.abc import Sequence from queue import Queue class lowerCAmelCase : '''simple docstring''' def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__=None , lowerCAme...
38
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> bool: SCREAMING_SNAKE_CASE = int(number**0.5 ) return number == sq * sq def ...
38
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_bigbird_pegasus': [ 'BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BigBirdPegasusConfig', 'BigBirdPegasusOnnxConfig', ], } try:...
175
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _lowercase ( snake_case_ , unittest.TestCase ): low...
175
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech...
352
"""simple docstring""" import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowercase__ ( l...
310
0
from __future__ import annotations A_ :int = tuple[int, int, int] A_ :Tuple = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase A_ :int = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' # ------------------------...
71
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCO...
71
1
'''simple docstring''' from __future__ import annotations lowerCamelCase : Optional[Any] = "Muhammad Umer Farooq" lowerCamelCase : List[Any] = "MIT" lowerCamelCase : str = "1.0.0" lowerCamelCase : str = "Muhammad Umer Farooq" lowerCamelCase : Union[str, Any] = ...
114
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase : Tuple = { "configuration_blenderbot": [ "BL...
114
1
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def snake_case_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : bool = Fals...
23
"""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 FeatureExtractionMix...
165
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, ) lowerCAmelCase_ = { 'configu...
302
"""simple docstring""" # Copyright 2023 The HuggingFace 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/l...
302
1
import math def lowerCamelCase__ ( snake_case_ : int ) -> int: if not isinstance(snake_case_ , snake_case_ ): __snake_case = f"""Input value of [number={number}] must be an integer""" raise TypeError(snake_case_ )...
24
import os import pytest from transformers.dynamic_module_utils import get_imports snake_case_ = '\nimport os\n' snake_case_ = '\ndef foo():\n import os\n return False\n' snake_case_ = '\ndef foo():\n def bar():\n if True:\n import os\n return...
24
1
from torch import nn class snake_case_ ( nn.Module ): def __init__( self : List[Any] , lowercase_ : Optional[int] , lowercase_ : Tuple ) -> str: super().__init__() lowercase__ : List[str] = class_size lowerca...
333
def lowercase_ ( _lowerCamelCase : int = 10 , _lowerCamelCase : int = 1000 , _lowerCamelCase : bool = True): assert ( isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerC...
333
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow, ) from tr...
9
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _lowercase ( A__ ): '''simple docstring''' def __init__( ...
9
1
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowercase (SCREAMING_SNAKE_CASE_ : List[str] ) -> str: SCREAMING_SNAKE_CASE = os.path.join(a...
359
"""simple docstring""" import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __UpperCamelCase = models.Se...
38
0
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand _lowerCamelCase : Optional[int] = ( "4S 3H 2C 7S 5H", "9D 8H 2C 6S 7H", "2D 6D 9D TH 7D", "TC 8C 2S JH 6C", "JH 8S TH ...
28
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ : List[Any] = logging.get_logger(__name__) lowerCamelCase__ : List[str] = { 'vocab_file': 'vocab.json', 'toke...
225
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ = { '''configuration_rembert''': ['''REMBERT_PRETRAINED_CONFIG_ARCHIVE...
350
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES snake_case_ = logging.get_logger(__name__) snake_case_ = OrderedDict( [ # Base mod...
216
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available A__ : Optional[int] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pas...
207
def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = [1] lowercase__ , lowercase__ , lowercase__ = 0, 0, 0 lowercase__ = ugly_nums[ia] * 2 lowercase__ = ugly_nums[ia] * 3 lowercase__ = ugly_nums[ia] * 5 for _ in range(1...
207
1
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion import...
300
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def A ( _lowerCamelCase = 8 ): '''simple docstring''' _lowerCAmelCase : Optional[int] = ascii_letters + digits + punctuation ...
300
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Any = { """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConf...
224
"""simple docstring""" from __future__ import annotations def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : int ) -> bool: """simple docstring""" if len(lowerCAmelCase__ ) == 0: return False lowerCAme...
224
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def UpperCAmelCase_( ): """simple docstring""" SCREAMING_SNAKE_CASE : List[str] = ArgumentParser( ...
359
import math from collections.abc import Iterator from itertools import takewhile def UpperCAmelCase_( a__ ): """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, all ...
19
0
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: str ): if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __SCREAMING_SNAKE_CASE : Tuple = sorted(string.lower() ) return len(_lowerC...
112
'''simple docstring''' import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DP...
112
1
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
96
'''simple docstring''' import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class a__( tf.keras.optimizers.schedules.LearningRateSchedu...
96
1
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 accelerate.test_uti...
38
# Copyright 2021 The HuggingFace 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 ap...
38
1
snake_case : str = { "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.", "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-", "V": "...-", "W"...
41
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, ...
41
1
from manim import * class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): def a (self : List[str] ): """simple docstring""" __snake_case = Rectangle(height=0.5 , width=0.5 ) __snake_case ...
24
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __snake_case = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def _A ( _lowercase = "mumbai" ) -> Generator[tuple[str, s...
310
0
'''simple docstring''' 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 i...
359
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE( __lowercase = 4 ) -> list[list[int]]: A: Tuple = abs(__lowercase ) or 4 return [[1 + x + y * row_size for x in range(__lowercase )] for y in range(__lowercase )] de...
334
0
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 : List[Any] = logging.get_logger(__name__) ...
114
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase__ ) class a ( lowercase__ ): """simple docstring""" a : str ...
114
1
from __future__ import annotations def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> list[str]: '''simple docstring''' if partitions <= 0: raise ValueError('partitions must be a positive number!' ) if partitions > number_of_bytes: raise Valu...
169
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _lowercase ( UpperCamelCase_ ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE__ = int(number**0.5 ) return number == sq * sq def _lowercase ...
169
1
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowerCamelCase__ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE ( lowerCamelCase__ ): def __init__( self : Dict , *__lowercase :...
302
from __future__ import annotations lowerCamelCase__ = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"""], } class...
302
1
import argparse import hashlib # hashlib is only used inside the Test class import struct class __SCREAMING_SNAKE_CASE : def __init__( self , SCREAMING_SNAKE_CASE__ ): lowercase : int = data lowercase : Optional[int] = ...
371
from math import pi, sqrt, tan def __lowercase ( _UpperCamelCase ) ->float: """simple docstring""" if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __lowercase ( ...
173
0
from torch import nn class A_ ( nn.Module ): '''simple docstring''' def __init__(self , lowercase__ , lowercase__ ) -> List[str]: super().__init__() __UpperCAmelCase = class_size __UpperCAmelCase = embed_size ...
333
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokeni...
333
1
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter, ...
118
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __lowercase ( a__ ) -> List[Any]: # picklable for multiprocessing...
118
1
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
30
import re import string import numpy as np import datasets UpperCAmelCase_ : Dict = ''' Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. ''' UpperCAmelCase_ : Any = ''' Args: ...
38
0
from PIL import Image def snake_case_ ( lowerCAmelCase_ : Image , lowerCAmelCase_ : float ): def brightness(lowerCAmelCase_ : int ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError("""level must be...
306
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel @requi...
306
1
"""simple docstring""" from __future__ import annotations def _A ( UpperCamelCase_ : list[int | str]) -> None: '''simple docstring''' create_state_space_tree(UpperCamelCase_, [], 0, [0 for i in range(len(UpperCamelCase_))]) def _A ( UpperCamelCase_ : list[in...
17
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
216
0
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) ...
311
'''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 i...
311
1
from __future__ import annotations _lowerCAmelCase : Dict = tuple[int, int, int] _lowerCAmelCase : Optional[Any] = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase _lowerCAmelCase : Union[str, Any] = '''ABCDEFGHIJKLMNO...
300
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, W...
300
1
"""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 __A : Tuple = ...
367
"""simple docstring""" 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_uti...
27
0
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, ) fr...
257
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.configuration_utils import FrozenDict fro...
19
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { ...
221
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCamelCase = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight', 'time_embedding.linea...
221
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor lowercase__ = logging.get_logger(__name__) class lowerCAmelCase__ ( lowercase ): '''simple docstring''' d...
96
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedu...
96
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_forw...
366
"""simple docstring""" UpperCAmelCase_ : List[Any] = 9.8_0_6_6_5 def _A (__a , __a , __a = g ) -> float: """simple docstring""" if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) if volume < 0: ra...
318
0
'''simple docstring''' from heapq import heappop, heappush import numpy as np def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase , ) -> tuple[float | int, list[tuple[int, int]]]: lowerCamel...
41
'''simple docstring''' 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, ...
41
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase : Dict = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Mask2FormerConfig", ],...
308
def UpperCamelCase_( _snake_case : str , _snake_case : int ): """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(_snake_case ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod ...
308
1