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
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property ...
16
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : Dict = { "configuration_roformer": ["ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "...
273
0
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_...
362
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer _A = logging.get_logger(__name__) _A = {"vocab_file": "vocab.txt", "...
137
0
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _SCREAMING_SNAK...
314
from functools import reduce _SCREAMING_SNAKE_CASE : Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' ...
314
1
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): A_ : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack A_ : set[int] = set() return any( node not in visited and depth_first_search(SCREAMING_SNAKE_CASE , SCREAMING...
65
from __future__ import annotations import math def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): if num <= 0: A_ : Optional[int] = f'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(SCREAMING_SNAKE_CASE ) A_ : Union[str, Any] = [True] * (...
65
1
import math def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = [True] * n snake_case_ = False snake_case_ = False snake_case_ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): s...
187
import functools def lowerCamelCase__ ( _A , _A ): '''simple docstring''' if not isinstance(_A , _A ) or not all(isinstance(_A , _A ) for day in days ): raise ValueError("The parameter days should be a list of integers" ) ...
187
1
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = [] snake_case_ = []...
200
def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: sna...
200
1
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers _lowerCAmelCase = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def _SCREAMING_SNAKE_CASE ( ): """simple docstring""" lowerCAmelCase__ : str = os.path.dirname(os.pa...
37
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _lowerCAmelCase = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems...
37
1
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertT...
288
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transform...
288
1
from __future__ import annotations class __lowercase : """simple docstring""" def __init__( self , A ) -> None: '''simple docstring''' lowerCamelCase = order # a_{0} ... a_{k} lowerCamelCase = [1.0] + [0.0] * order #...
252
'''simple docstring''' import json from typing import TYPE_CHECKING, 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 loggin...
4
0
'''simple docstring''' from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be check...
352
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = {"""configuration_sew""": ["""SEW_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SEWConfig"""]} try: if not is_torch_available(): raise OptionalDepend...
48
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 lowercase_ = logging.get_logger(__name__) lowercase_ = { 'facebook/le...
205
# 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 ...
205
1
'''simple docstring''' import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassifica...
357
'''simple docstring''' import inspect import re from transformers.utils import direct_transformers_import # 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 _lowercase = """src/transformers""" # This is to make...
229
0
__A ={str(digit): digit**5 for digit in range(1_0)} def a ( _UpperCAmelCase : int ): '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_UpperCAmelCase ) ) def a ( ): ''...
226
from collections import defaultdict def _snake_case ( lowerCAmelCase : int ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Any = 1 SCREAMING_SNAKE_CASE_ : Tuple = True for v in tree[start]: if v not in visited: ret += dfs(lowerCAmelCase ) if r...
18
0
'''simple docstring''' 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 ...
363
'''simple docstring''' def lowercase (): """simple docstring""" _lowerCAmelCase : Optional[int] = [3_1, 2_8, 3_1, 3_0, 3_1, 3_0, 3_1, 3_1, 3_0, 3_1, 3_0, 3_1] _lowerCAmelCase : int = 6 _...
25
0
from __future__ import annotations from collections.abc import Generator def SCREAMING_SNAKE_CASE_ ( ) -> Generator[int, None, None]: """simple docstring""" a_ : dict[int, int] = {} a_ : Tuple = 2 while True: ...
32
'''simple docstring''' def lowercase_ ( lowerCAmelCase__ : int ): """simple docstring""" __UpperCAmelCase : list[list[int]] = [[0 for _ in range(lowerCAmelCase__ )] for _ in range(m + 1 )] for i in range(m + 1 ): __UpperCAmelCa...
254
0
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 ( TFBaseModelOutputWithNoAttention, TFBaseModelOut...
342
import numpy as np import datasets _snake_case = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was introduced by Prof. P. C. Mah...
342
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ : Union[str, Any] = { """configuration_funnel""": ["""FUNNEL_PRETRAIN...
75
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.c...
72
0
"""simple docstring""" import argparse from collections import defaultdict import yaml lowercase__ = 'docs/source/en/_toctree.yml' def __a ( _SCREAMING_SNAKE_CASE ) ->List[Any]: a__: str = defaultdict(_SCREAMING_SNAKE_CASE ) for doc in model_doc: ...
203
"""simple docstring""" import math def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->Optional[int]: if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(_SCREAMING_SNAKE_CASE ) else: if x == 0: # 0 ...
203
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available A__: List[Any] = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xl...
149
import doctest from collections import deque import numpy as np class _a : """simple docstring""" def __init__( self: Union[str, Any] ): '''simple docstring''' UpperCamelCase__: int = [2, 1, 2, -1] UpperCa...
149
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Any = logging.get_logger(__name__) lowercase__ : List[Any] = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''', '''...
351
"""simple docstring""" from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
155
0
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase__ ( lowercase__ ): """simple docstring""" def __init__( self , snake_case , snake_case ...
311
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split a : int = datasets.load_iris() a : Union[str, Any] = np.array(data["data"]) a : Optional[Any] = np.array(data["target"]) a...
311
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """google/pix2struct-textcaps-base""": ( """https://huggingface.co/goog...
353
'''simple docstring''' from math import factorial def _A ( _lowerCAmelCase = 20 ): """simple docstring""" __lowercase =2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... __lowercase =n // 2 return int(facto...
48
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_M...
322
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTest...
67
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class UpperCamelCase : def __init__( self) -> Dict: snake_case_ = {} def a_ ( self, lowerCAmelCase__, lowerCAmelCase_...
351
"""simple docstring""" from math import pi def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> float: return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
312
0
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingface...
192
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def UpperCamelCase (lowercase_: Optional[int] , lowercase_: Union[str, Any] , lowercase_: Optional[Any] ) -> Tu...
192
1
'''simple docstring''' def snake_case_ ( lowerCAmelCase_ = 2000000 )-> int: '''simple docstring''' _UpperCAmelCase : int = [0 for i in range(n + 1 )] _UpperCAmelCase : int = 1 _UpperCAmelCase : Any = 1 f...
349
'''simple docstring''' def snake_case_ ( lowerCAmelCase_ )-> int: '''simple docstring''' if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): raise TypeError("""only integers accepted as input""" ) else: _UpperCAmelCase : Dict ...
349
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class a__ ( unittest.TestCase ): A = inspect.getfile(accelerate.test_...
18
"""simple docstring""" import copy 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 from ..auto import CONFIG_MAPPING A: List[str] = logging.get_l...
109
0
from __future__ import annotations from typing import Any class _snake_case ( SCREAMING_SNAKE_CASE__ ): pass class _snake_case : def __init__( self , _lowerCamelCase ): a :Any = data a :Node | None = None def __iter__( self ): ...
359
# 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...
281
0
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 __snake_case ( lowerCAmelCase , unittest.TestCase ): _a :...
20
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCamelCase_ ( _a : List[Any] ): '''simple docstring''' UpperCAmelCase_ : Optional[int] = [ """decoder.version""", ...
345
0
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A : Optional[int] = { '''RUCAIBox/mvp''': '''https://huggingface.co/RUCAIBox/mvp/resolve/main/co...
27
"""simple docstring""" import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
27
1
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging lowerCamelCase__ = logging.get_logger(__name__) class A__ : lowercase = None @experimental def lowerCAmelCase__ ( ...
212
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class A__ : @property def _lowerCamelCase ...
212
1
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torc...
213
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(F...
213
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowercase = {'''configuration_plbart''': ['''PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP'...
74
"""simple docstring""" import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextI...
96
0
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class __lowercase (tf.keras.layers.Layer ): """s...
162
from typing import Any def a__ ( A__, A__, A__, A__, A__, ): _validation( A__, A__, A__, A__, A__, ) # Creates data structures and fill initial step SCREAMING_SNAKE_CASE_ : dict = {} SCREAMING_SNAKE_CASE_ :...
162
1
"""simple docstring""" import inspect import unittest class UpperCAmelCase_ ( unittest.TestCase): def _UpperCAmelCase ( self ) -> List[str]: try: import diffusers # noqa: F401 except ImportError: assert F...
77
"""simple docstring""" import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def snake_case__ ( __lowerCamelCase : List[Any] , __lowerCam...
238
0
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def UpperCamelCase_ ( A__ : Union[str, Any] , A__ : Dict , A__ : Optional[int] ): '''simple docstring''' lowerCAmelCa...
354
'''simple docstring''' # 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/licen...
89
0
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, Juma...
8
def _a ( UpperCAmelCase ) -> bool: """simple docstring""" return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _A : ...
142
0
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtr...
361
"""simple docstring""" from __future__ import annotations lowerCAmelCase_ = '#' class __A : '''simple docstring''' def __init__( self : str ) -> None: """simple docstring""" lowercase__ : dict...
302
0
UpperCAmelCase : List[str] = 2_56 # Modulus to hash a string UpperCAmelCase : Optional[Any] = 1_00_00_03 def _SCREAMING_SNAKE_CASE ( a , a ) -> Any: __A : Optional[Any] = len(__UpperCamelCase ) __A : List[Any] = ...
280
import cva import numpy as np class _a : """simple docstring""" def __init__( self : Any , UpperCAmelCase : float , UpperCAmelCase : int ): if k in (0.04, 0.06): A_ = k A_ ...
312
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json', } class...
366
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # See all BioGPT models at http...
232
0
"""simple docstring""" import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' def __lowerCAmelCase ( self ) -> ...
263
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): '''simple docstring''' def __init__( self ...
263
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def __SCREAMING_SNAKE_CASE ( lowercase__ ): """simple docstring""" return np.dot(lowercase__ , lowercase__ ) class __UpperCamelCa...
354
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __SCREAMING_SNAKE_CASE ( lowercase__ , lowercase_...
57
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_C...
195
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): raise TypeError('Input value must be an \'int\' type' ) lowercase = 0 while number: position += 1 number >>= 1 return position if __name__ ==...
195
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class UpperCAmelCase ( unittest.TestCase ): ...
356
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailable() ...
192
0
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch_mi...
76
import os def lowerCamelCase__ ( ): with open(os.path.dirname(_a) + "/p022_names.txt") as file: SCREAMING_SNAKE_CASE : List[str] = str(file.readlines()[0]) SCREAMING_SNAKE_CASE : List[Any] = names.replace("\"" , "").split(",") names.sort() SCREAMING_SNAKE_...
76
1
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> bool: '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("Program to check whether a number is a Perfect number or...
361
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class snake_case__ : """simple docstring""" def __init__( self : Dict , UpperCamelCase__ : int , UpperCamelCase__ : MutableSeque...
83
0
"""simple docstring""" lowerCAmelCase__ : List[Any] = '''Input must be a string of 8 numbers plus letter''' lowerCAmelCase__ : Any = '''TRWAGMYFPDXBNJZSQVHLCKE''' def a_ ( lowerCamelCase ): if not isinstance(_lowercase , _lowercase ): UpperCAmel...
98
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokenize...
318
0
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_a...
368
'''simple docstring''' from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils import...
156
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : List[str] = { '''configuration_mobilebert''': [ '''MOBILEBERT_PR...
264
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def __lowercase ( lowerCamelCase : Any ): UpperCamelCase_ : Union[str, Any] = test_file.split(os.path.sep ...
175
0
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class UpperCAmelCase_ ( _lowercase): def _UpperCamelCase ( self : Optional[Any] , __UpperCamelCase : str ) -> List[str]: ...
351
"""simple docstring""" import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class UpperCAmelCase_ ( _lowercase): def __init__( self : Any , __UpperCamelCase : Optional...
54
0
def a ( _UpperCAmelCase : Optional[Any] , _UpperCAmelCase : int , _UpperCAmelCase : Tuple , _UpperCAmelCase : List[Any] , _UpperCAmelCase : List[str] ): '''simple docstring''' if index == number_of_item...
226
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 the reference code that wi...
337
0
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CASE ): _snake_case = AutoConfig.from_pretrained(_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAK...
359
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if not (isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )): raise ValueError("""longest_comm...
270
0
'''simple docstring''' # 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/license...
223
'''simple docstring''' 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 .toke...
223
1
import os 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 logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_C...
367
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_comm...
88
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCamelCase ( a ): """simple docstring""" UpperCAmelCase_ : Optional[Any] =["image_processor", "tokenizer"] UpperCAmelCase_ : i...
326
def lowerCAmelCase__( lowercase : List[Any] , lowercase : Optional[Any] , lowercase : Optional[int] , lowercase : str , lowercase : List[Any] , lowercase : List[str] ) -> int: if index == r: for j in range(lowercase ): prin...
326
1
import math class lowerCamelCase__ : def _lowerCamelCase ( self : Optional[Any] , _a : list[list[float]] , _a : list[int] ): a__: str =0.0 a__: Dict =0.0 for i in range(len(_a ) ): ...
42
import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel __UpperCAmelCase = logging.getLogger(__name...
42
1
"""simple docstring""" from collections import namedtuple __A : Dict = namedtuple("from_to", "from_ to") __A : Any = { "cubicmeter": from_to(1, 1), "litre": from_to(0.001, 1000), "kilolitre": from_to(1, 1), "gallon": from_to(0.0_0454, 264.172), ...
260
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def lowercase ( _SCREAMING_SNAKE_CASE : Any ): '''simple docstring''' _UpperCAmel...
260
1
"""simple docstring""" def a__ ( lowerCAmelCase = 60_08_51_47_51_43 ) -> int: try: UpperCAmelCase__ : List[Any] = int(lowerCAmelCase ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: ...
166
"""simple docstring""" def a__ ( lowerCAmelCase ) -> bool: if not isinstance(lowerCAmelCase , lowerCAmelCase ): UpperCAmelCase__ : Tuple = F"""Input value of [number={number}] must be an integer""" raise TypeError(lowerCAmelCase ) if number < 0: ...
166
1
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controln...
127
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class A__ ( unittest.TestCase ): ...
127
1
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _a : def __init__( self : int, lowerCAmelCase__ : Collection[float] | None = None ) -> None: ...
364
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelin...
128
0
from collections import deque from math import floor from random import random from time import time class _snake_case : def __init__( self ): a :Optional[int] = {} def SCREAMING_SNAKE_CASE__ ( self , _lowerCamelCase , _lowerCamelCase , _lowe...
94
'''simple docstring''' import logging import os from .state import PartialState class UpperCAmelCase__ ( logging.LoggerAdapter): @staticmethod def __lowerCamelCase ( lowercase ) -> Dict: __UpperCamelCase = PartialState() return not main_process_...
349
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging __UpperCAmelCase :List[str] = logging.get_logger(__name__) __UpperCAmelCase :int = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-c...
350
'''simple docstring''' import requests __UpperCAmelCase :Union[str, Any] = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def _a ( _lowercase : str ): '''simple docstring''' __UpperCAmelCase : Unio...
240
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCamelCase ( unit...
331
'''simple docstring''' import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMode...
331
1
"""simple docstring""" from collections.abc import Callable class lowercase : '''simple docstring''' def __init__( self , _snake_case = None ) -> None: """simple docstring""" UpperCAmelCase = [] ...
369
# Function to print upper half of diamond (pyramid) def _lowerCAmelCase ( A__: str ): '''simple docstring''' for i in range(0 , A__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end='''''' ) fo...
152
0
import os import re import shutil import sys import tempfile import unittest import black UpperCAmelCase_ = 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 the reference code...
12
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
0
'''simple docstring''' from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.c...
354
'''simple docstring''' from math import isqrt def lowercase (_A ): """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(_A ) + 1 ) ) def lowercase (_A = 1_0**6 ): ...
25
0
'''simple docstring''' from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils import load_im...
2
class _lowercase : """simple docstring""" def __init__( self : List[Any] , __lowerCamelCase : int ): '''simple docstring''' lowerCamelCase__ : Optional[Any] = size lowerCamelCase__ : Lis...
184
0
'''simple docstring''' def A__ ( UpperCAmelCase_ ): if num < 0: return False _UpperCamelCase : int = num _UpperCamelCase : int = 0 while num > 0: _UpperCamelCase : int = rev_num * 1_0 + (num % 1_0) num //...
350
'''simple docstring''' from datetime import datetime import requests def A__ ( UpperCAmelCase_ ): _UpperCamelCase : List[Any] = 'https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' _UpperCamelCase : Optional[int] = requests.get(base_url + ur...
236
0
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def _A ( _lowerCAmelCas...
166
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
0
'''simple docstring''' from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
349
'''simple docstring''' A_ : Optional[Any] = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from ...
349
1
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proce...
9
def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__=False ): if isinstance(lowercase__ , lowercase__ ) and isinstance(lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : List[str] = len(set_a.intersectio...
9
1
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever _lowerCAmelCase : Union[str, Any] = logging.getLogger(__name__) class __magic_name__ ( lowerCamelCase__ )...
355
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : int = logging.get_logger(__name__) _lowerCAmelCase : Dict = { '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/resol...
70
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowerCAmelCase = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } try: if not is_torch_availa...
341
'''simple docstring''' __lowerCAmelCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): # Make sure the supplied data is a bytes-like object if not isinstance(_SCREAMING_SNAKE_CASE , ...
341
1
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : list ) -> list: UpperCAmelCase_ = len(__UpperCamelCase ) for _ in range(__UpperCamelCase ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: U...
371
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 ) _lowerCamelCase = logging.getLogger(__name__) if __name__ == "__main...
177
0
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class lowerCamelCase ( unittest.TestCase ): '''simple docstring''' def lowerCAmelCase_ ( self: Optional[Any] ) -> Union[str, Any]...
66
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : List[str] = {"""configuration_vit_msn""": ["""VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTMSNConfig"""]} try: if not is_torch_available(): raise Opti...
14
0
'''simple docstring''' import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPM...
359
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipelin...
184
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A (unittest.TestCase ): '''...
274
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __lowerCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ) -> np.array: _a : Optional[int] = f"""{sampling_rate}""" _a ...
89
0
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class a ( a__ ): # to overwrite at feature extractactor specific tes...
370
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Dict = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctc...
309
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer snake_case_ = logging.get_logger(__name__) snake_case_ = {"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokeni...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : int = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): rai...
236
0
import cmath import math def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : List[Any] = math.radians(_lowerCamelCase ) _lowerCAmelCase : Optional[Any] ...
356
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvNextConfig", "ConvNextOnnxConfig"] }...
300
0
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import Conf...
70
"""simple docstring""" import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCAmelCase_ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): f...
16
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig,...
366
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common im...
55
0
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from ...
34
'''simple docstring''' import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, ...
34
1
"""simple docstring""" import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBer...
259
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase=() , _UpperCamelCase=None , _UpperCamelCa...
259
1
"""simple docstring""" from __future__ import annotations def _snake_case ( lowerCamelCase__ : int ) -> list[int]: lowerCamelCase_ : int =[True] * limit lowerCamelCase_ : List[str] =False lowerCamelCase_ : List[Any] ...
144
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.append(os.p...
227
0
"""simple docstring""" from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuron...
54
"""simple docstring""" # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils impor...
54
1
"""simple docstring""" from __future__ import annotations def _snake_case ( UpperCamelCase : list[int] , UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : int ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and ar...
109
"""simple docstring""" import copy 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 from ..auto import CONFIG_MAPPING A: List[str] = logging.get_l...
109
1
from __future__ import annotations lowercase : Dict = list[tuple[int, int]] lowercase : List[str] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, ...
350
lowercase : Optional[int] = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''': '''flax>=0.4.1''...
36
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils...
105
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar UpperCAmelCase : Dict =TypeVar("""T""") class _lowercase (Generic[T] ): '''simple docstring''' def __init__( self , snake_case__ ): ...
128
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/r...
370
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration lowercase_ = 5_0_0_0_0 lowercase_ = 5_0_0_0 lowercase_ ,lowercase_ = os.path.split(__file__) lowercase_ = os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace...
194
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import log...
56
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __snake_case = get_tes...
310
0
"""simple docstring""" import math import os import sys def lowercase__ ( snake_case_ :str ): __UpperCAmelCase = '''''' try: with open(snake_case_ , '''rb''' ) as binary_file: __UpperCAmelCase = binar...
353
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowercase : int = logging.get_logger(__name__) _lowercase : Tuple ...
86
0
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase (_UpperCAmelCase ): def UpperCamelCase ( self: Any , UpperCAmelCase_: Union[str, Any] ...
306
"""simple docstring""" from ..utils import DummyObject, requires_backends class _A ( metaclass=lowerCAmelCase ): snake_case__ : List[str] = ['onnx'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): ...
197
0
"""simple docstring""" import requests from bsa import BeautifulSoup def a__ ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : dict ): '''simple docstring''' lowerCAmelCase : Any = BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE , params=SC...
133
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : list[int] ): '''simple docstring''' lowerCAmelCase : str = len(SCREAMING_SNAKE_CASE ) for i in range(SCREAMING_SNAKE_CASE ): for j in range(i + 1 , SCREAMING_SNAKE_CASE ): if nu...
133
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json', } class SCREAMING_SNAKE_CASE...
24
from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils import load_...
24
1
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class __UpperCAmelCase : '''simple docstring''' __lo...
18
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normalize, ...
18
1
import logging from transformers.configuration_utils import PretrainedConfig __A = logging.getLogger(__name__) class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = "masked_bert" def __init__(self : Dict , UpperCAmelCase_ ...
10
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCamelCase_ ( unittest.TestCase): """s...
54
0
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(".") def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> Any: '''simple docstrin...
313
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> list: '''simple docstring''' if any(not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integ...
313
1
"""simple docstring""" from __future__ import annotations import math class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> int: '''simple docstring''' UpperCAmelCase : Optional[int] = size # approximate the overall size of segme...
109
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_ava...
156
0
"""simple docstring""" import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def lowerCamelCase ( _UpperCamelCase : str , _UpperCamelCase : str , _UpperCamelCase : int , _UpperCamelCase : Dict , _UpperCa...
360
"""simple docstring""" from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvaila...
320
0