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''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowerCamelCase :List[Any] = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_ver...
206
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _lowerCAmelCase ( unittest.TestCase ): def _a (self ): A_ : Optional[Any] = 10 def _...
206
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __A =logging.get_logger(__name__) __A ='''▁''' __A ...
359
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class _SCREAMING_SNAKE_CASE ( nn.Module ): def __init__( self , lowercase = 16 , lowercase = 88 , lowercase = None , lowercase = 1 , lowerca...
47
0
import torch from ..models.speechta import SpeechTaForTextToSpeech, SpeechTaHifiGan, SpeechTaProcessor from ..utils import is_datasets_available from .base import PipelineTool if is_datasets_available(): from datasets import load_dataset class lowerCamelCase (_SCREAMING_SNAKE_CASE ): """simple d...
118
"""simple docstring""" def _A ( lowercase = "The quick brown fox jumps over the lazy dog" , ): """simple docstring""" a =set() # Replace all the whitespace in our sentence a =input_str.replace(''' ''' , '''''' ) for alpha in ...
81
0
"""simple docstring""" import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def UpperCAmelCase ( UpperCamelCase__ ): ...
367
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( ...
154
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
68
from __future__ import annotations import collections import pprint from pathlib import Path def __A ( __lowerCAmelCase )-> str: """simple docstring""" return "".join(sorted(__lowerCAmelCase ) ) def __A ( __lowerCAmelCase )-> list[str]: ...
39
0
"""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/licenses/LICENSE-2.0 ...
365
"""simple docstring""" def snake_case (A_ :int ): '''simple docstring''' if isinstance(A_ , A_ ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(A_ , A_ ): raise TypeError('\'str\' object cannot be interpreted...
186
0
'''simple docstring''' from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def a_ ( ) -> tuple[list[int], int]: """simple docstring""" lowerCamelCase_ =[randint(-1000 , 1000 ...
75
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = ...
166
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule A_ : Optional[Any] ={"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: ...
80
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoF...
80
1
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def UpperCamelCase( __UpperCamelCase : int ): lowerCAmelCase_ : Tuple = prime_factors(__UpperCamelCase ) if is_square_free(__UpperCamelCase ): return -1 if len(__UpperCamelCase ) % 2 else...
103
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 A__ : int = logging.get_logger(__name__) A__ : Optional[int] = { '''facebook...
103
1
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
309
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a : def __init__( self ): """simple docstring""" lowerCAmelCase = '' lowerCAmelCase = '' lowerCAmelCase = [] l...
309
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :Dict = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/reso...
22
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from ...
22
1
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenceCl...
268
"""simple docstring""" import math def _lowerCamelCase( a ): __a = [] __a = 2 __a = int(math.sqrt(a ) ) # Size of every segment __a = [True] * (end + 1) __a = [] while start <= end: if...
268
1
from collections.abc import Sequence def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = False ) -> float: if not arr: return 0 lowercase : Any = 0 if allow_empty_subarrays else float("""-inf""" ) lowercase : ...
20
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
20
1
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCAmelCase_ ( unittest.TestCase ): '''...
352
'''simple docstring''' import os from distutils.util import strtobool def SCREAMING_SNAKE_CASE( __lowercase , __lowercase ) -> List[Any]: for e in env_keys: A: Dict = int(os.environ.get(__lowercase , -1 ) ) if val ...
334
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTest...
81
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_ve...
291
"""simple docstring""" from math import factorial def __lowercase ( snake_case_ : int ,snake_case_ : int ) ->int: '''simple docstring''' if n < k or k < 0: raise ValueError('''Please enter positive integers for n and k where n >= k''' ) re...
291
1
def __lowercase ( _UpperCamelCase = 100 ) ->int: """simple docstring""" lowercase : List[Any] = (n * (n + 1) // 2) ** 2 lowercase : Any = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F''...
337
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __a = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': operator.gt, } def __lo...
337
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, trans...
156
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers impor...
156
1
'''simple docstring''' def __snake_case ( ): lowerCamelCase_ = [] lowerCamelCase_ = 1 while len(UpperCAmelCase_ ) < 1E6: constant.append(str(UpperCAmelCase_ ) ) i += 1 lowerCamelCase_ = "".join(UpperCAmelCase_ ) return ( int(constant[0] ) * int(...
55
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) SCREAMING_SNAKE_CASE_ = pytest.mark.integration @pytest.mark.para...
301
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Con...
371
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCamelCase__ ( a__ : Dict , a__ : Dict=None ) -> Union[str, Any]: UpperCamelCase_ = None if token is n...
261
0
def a__ ( A_, A_ ): '''simple docstring''' def get_matched_characters(A_, A_ ) -> str: __magic_name__ = [] __magic_name__ = min(len(_stra ), len(_stra ) ) // 2 for i, l in enumerate(_stra ): __ma...
88
"""simple docstring""" from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowercase_ = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n ...
266
0
import unittest import numpy as np from transformers import BertConfig, 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.mo...
356
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case : Optional[int] ={ 'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'], 'processing_vi...
94
0
import functools from typing import Any def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : list[str] ): # Validation if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) or len(SCREAMING_SNAKE_CASE__ ) == 0: r...
62
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _A = logging.get_logger(__name__) _A = { 'Sale...
62
1
'''simple docstring''' import math from collections.abc import Callable def _a ( _lowercase : Callable[[float], float] , _lowercase : float , _lowercase : float ): '''simple docstring''' __UpperCAmelCase : float ...
240
'''simple docstring''' import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline __UpperCAmelCase...
240
1
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 ( ProphetNetForConditionalGeneration ...
333
import doctest from collections import deque import numpy as np class A_ : '''simple docstring''' def __init__(self ) -> None: __UpperCAmelCase = [2, 1, 2, -1] __UpperCAmelCase = [1, 2, 3, 4] def lowerCAmelCase_ (self ...
333
1
'''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_ ( ...
371
'''simple docstring''' import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig lowerCAmelCase : Any ={ '''fac...
147
0
from typing import TYPE_CHECKING from ..utils import _LazyModule __UpperCamelCase : str = { "config": [ "EXTERNAL_DATA_FORMAT_SIZE_LIMIT", "OnnxConfig", "OnnxConfigWithPast", "OnnxSeq2SeqConfigWithPast", "PatchingSpec", ], "convert": ["export", "valid...
146
"""simple docstring""" def _snake_case ( _snake_case : int , _snake_case : int ) -> bool: '''simple docstring''' return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
315
0
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 not is_to...
351
import unittest from transformers import LiltConfig, 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 ModelTesterMixi...
137
0
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/encodec_24khz': 'https://huggingface.co/facebook/encodec_24khz/resolve/main/config.json'...
30
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { 'configuration_rembert': ['REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP'...
30
1
'''simple docstring''' from collections.abc import Callable class a__ : def __init__( self , _UpperCamelCase = None ): """simple docstring""" _lowercase : list = [] # Stores indexes of each item for supporting updates and deletion. _l...
199
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data i...
199
1
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __magic_name__ ( lowerCAmelCase_ ): SCREAMING_SNAKE_CASE ...
218
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 __magic_name__ ( lowerCAmelCase_ ): S...
218
1
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer ...
222
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # See all BioGPT models at https://huggingfac...
222
1
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 _SCREAMING_SNAKE_CASE : '''simple docstring''' lowercase_ = 42 lowercase_ ...
10
import torch from transformers import AutoModel class __lowerCamelCase (torch.nn.Module ): def __init__( self: Union[str, Any],A_: Tuple="sayef/fsner-bert-base-uncased" ): '''simple docstring''' super(A_,self...
310
0
'''simple docstring''' import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_t...
48
'''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 _UpperCamelCase ( A , unittest.Test...
48
1
'''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/licenses/LICENSE-2.0 # # Un...
318
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) _SCREAMING_SNAKE_CASE = models.Sequential() # Step 1 -...
343
0
def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(l...
365
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = "▁" lowercase_ = {"vocab_fi...
20
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_x...
71
import os from datetime import datetime as dt from github import Github A_ :str = [ '''good first issue''', '''feature request''', '''wip''', ] def A ( ) -> Any: __UpperCamelCase : Any =Github(os.enviro...
71
1
from collections import defaultdict from math import ceil, sqrt def UpperCamelCase( lowercase_ = 1000000 , lowercase_ = 10 ) -> int: '''simple docstring''' snake_case_ = defaultdict(lowercase_ ) for outer_width in range(3 , (t_limit // 4) + 2 ): ...
34
import logging from transformers.configuration_utils import PretrainedConfig lowerCamelCase_ = logging.getLogger(__name__) class __lowerCamelCase ( __snake_case ): lowerCamelCase_ : Optional[int] = 'masked_bert' def __init__( self , lowerCam...
34
1
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow...
96
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints,...
75
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 = { 'configuration_roformer': ['ROFORMER_PRETRAINED_C...
270
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig __lowerCAmelCase = logging.getLogger(__name__) class _lowerCAmelCase ( __snake_case ): '''simple docstring''' lowerCAmelCase_ = "masked_bert" def __i...
270
1
snake_case_ = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] snake_case_ = [ 999, 976, 952, 928, ...
214
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandin...
44
0
from __future__ import annotations def __a ( lowerCAmelCase_ : int ,lowerCAmelCase_ : int ) -> list[list[int]]: '''simple docstring''' UpperCAmelCase_= [] create_all_state(1 ,lowerCAmelCase_ ,lowerCAmelCase_ ,[] ,lowerCAmelCase_...
277
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientState, Par...
277
1
import math def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : List[str] = [True] * n lowercase__ : Optional[int] = False lowercase__ : str = False lowercase__ : int ...
130
"""simple docstring""" # Lint as: python3 import itertools import os import re _UpperCAmelCase = re.compile(r"""([A-Z]+)([A-Z][a-z])""") _UpperCAmelCase = re.compile(r"""([a-z\d])([A-Z])""") _UpperCAmelCase = re.compile(r"""(?<!_)_(?!_)""") _UpperCAmelCase = re.compile(r"""(_{2,})""") _...
173
0
import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib __magic_name__ ...
361
def _lowerCAmelCase ( A__: int = 1000 ): '''simple docstring''' UpperCAmelCase = 2**power UpperCAmelCase = str(A__ ) UpperCAmelCase = list(A__ ) UpperCAmelCase = 0 for i in list_num: sum_of_num += int(A__ ...
152
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a__ : List[str] ={ '''configuration_encodec''': [ '''ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''EncodecConfig''', ]...
53
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 3, _lowerCAmelCase : int = 7, _lowerCAmelCase : int = 1000000 ) -> int: _UpperCAmelCase : Dict = 0 _UpperCAmelCase : int = 1 for current_denominator in range(1, limit...
246
0
from typing import TYPE_CHECKING from ...utils import _LazyModule _lowerCamelCase : int = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys ...
206
def __lowerCamelCase (UpperCAmelCase__ : str , UpperCAmelCase__ : str = " " ): SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = 0 for index, char in enumerate(UpperCAmelCase__ ): if char == separator: split_...
206
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ , A_ ): lowerCAmelCase__ : list[list[str]] = [[] for _ in range(A_ )] lowerCAmelCase__ : Union[str, Any] = key - 1 if key <= 0: raise ValueError('''Height of grid can\'t be 0 or negative''' ) if key == 1 or len(A_ ...
106
'''simple docstring''' import datasets from .evaluate import evaluate UpperCamelCase__ : int = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev an...
344
0
import sys from collections import defaultdict class __lowerCAmelCase : def __init__( self: Any ): lowercase :Optional[Any] = [] def SCREAMING_SNAKE_CASE ( self: Tuple , _lowerCAmelCase: List[str] ): return self.node_posit...
368
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __lowerCAmelCase ( lowerCAmelCase): def __init__( self: Any , _lowerCAmelCase: int , _lowerCAmelCase: str , _lowerCAmelCase: U...
158
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : List[str] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def _SCR...
37
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gp...
37
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify...
356
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from t...
166
0
def lowerCAmelCase_ ( A_ ,A_): if b == 0: return 1 if (b % 2) == 0: return actual_power(A_ ,int(b / 2)) * actual_power(A_ ,int(b / 2)) else: return a * actual_power(A_ ,int(b / 2)) * actual_power(A_ ,int(b / 2)) def lowerCAmelCase_ ...
149
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def lowerCAmelCase_ ( A_ ,A_ ,A_): UpperCamelCase__: List[Any] = { "en": "Machine learning is great, isn't it?", "ru": "Машинное обучение - это здорово, не так ли?"...
149
1
'''simple docstring''' from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, requi...
367
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def SCREAMING_SNAKE_CASE( __lowercase , __lowercase ) -> str | Literal[False]: A: List[str] = list(__lowercase ) A: ...
334
0
class A__ : def __init__( self , A_ , A_ , A_ ): '''simple docstring''' UpperCamelCase : Optional[Any] = None UpperCamelCase : int = None UpperCamelCase : Optional[int] = graph se...
52
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration a_ = 50000 a_ = 5000 a_ , a_ = os.path.split(__file__) a_ = os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json""")) ...
179
0
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowercase_ = logging.get_logger(__name__) class A_ ( __UpperCamelCase ): ...
367
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, ) lowercase_ = {'configuration_mbart': ['MBART_PRETRAINED_CONFIG_ARCH...
194
0
from argparse import ArgumentParser from accelerate.commands.config import get_config_parser from accelerate.commands.env import env_command_parser from accelerate.commands.launch import launch_command_parser from accelerate.commands.test import test_command_parser from accelerate.commands.tpu import tpu_command_...
14
"""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 ...
286
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from diff...
50
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _lowercase ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self : List[str] ) -> Optional[Any]: """simple docstring"...
50
1
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.se...
278
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
1
"""simple docstring""" import math import random def __SCREAMING_SNAKE_CASE ( A_ , A_ = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value __UpperCamelCase : Dict = 0.0_2 def __SCREAMING_SNAKE_CASE ( A_ , A_ ...
74
"""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/licenses/LICENSE-2.0 # ...
74
1
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : list , __UpperCamelCase : list , __UpperCamelCase : int ) -> list: """simple docstring""" SCREAMING_SNAKE_CASE__ = len(__UpperCamelCase ) SCREAMING_SNAKE_CASE__ = ...
219
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType,...
219
1
def a__ ( __UpperCamelCase , __UpperCamelCase ): if b == 0: return 1 if (b % 2) == 0: return actual_power(__UpperCamelCase , int(b / 2 ) ) * actual_power(__UpperCamelCase , int(b / 2 ) ) else: return a * actual_power(__UpperCa...
305
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 : str = logging.get_logger(__name__) A : O...
305
1
from collections import defaultdict from math import ceil, sqrt def _UpperCAmelCase ( snake_case = 1_00_00_00 , snake_case = 10 ): """simple docstring""" _lowerCAmelCase = defaultdict(_a ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer...
82
'''simple docstring''' from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test im...
34
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCAmelCase = {'''configuration_encoder_decoder''': ['''EncoderDecoderConfig''']} try: if not is_torch_...
288
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models ...
288
1
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( __lowerCAmelCase )-> Optional[Any]: '''simple docstring''' def is_in_circle(__lowerCAmelCase , __lowerCAmelCase ) -> bool: ...
348
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 ConfigTester from ...test_modeling_tf_common import TFModelTes...
348
1
from __future__ import annotations def __lowerCamelCase ( lowerCAmelCase__ : Union[str, Any] ): return len(set(lowerCAmelCase__ ) ) == len(lowerCAmelCase__ ) if __name__ == "__main__": import doctest doctest.testmod()
359
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, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaToken...
119
0
import inspect import unittest from transformers import RegNetConfig 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 ConfigTester from ...test...
299
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available(): ...
186
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_to...
366
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class __lowerCamelCase ( snake_case_ ): """simple docstring""" def A__ ( self ) -> int: '''simple docstring''' ...
297
0
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva __SCREAMING_SNAKE_CASE ='' __SCREAMING_SNAKE_CASE ='' __SCREAMING_SNAKE_CASE ='' __SCREAMING_SNAKE_CASE =1 # (0 is vertical, 1 is horizontal) def lowercase__( ): low...
213
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 UpperCamelCase (lowercase_: int , lowercase_: Dict , lowercase_: Tuple ) -> ...
192
0
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-b...
226
"""simple docstring""" import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class ...
226
1
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def A__ ( UpperCamelCase , UpperCamelCase , UpperCamelCase = 1 , UpperCamelCase = 1 , UpperCamelCase = 1.0E4 , UpperCamelCase = False , UpperCamelCase = 1.0 , ): assert tim...
292
"""simple docstring""" from math import isqrt, loga def A__ ( UpperCamelCase ): A = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase , UpperC...
292
1
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Conf...
302
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @...
302
1
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def A_ ( _lowercase, _lowercase, _lowercase ): '''simple docstring''' snake_case_ :str...
66
def lowercase__ ( __snake_case : list ): '''simple docstring''' for i in range(len(__snake_case ) - 1 , 0 , -1 ): UpperCAmelCase_ : Dict = False for j in range(__snake_case , 0 ,...
29
0
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase__ : '''simple docstring''' snake_case_ =None snake_case_ =False snake_case_ =False snake_case_ =False snake_case_ =None sn...
94
def lowerCAmelCase__ ( lowerCamelCase_ : str = "The quick brown fox jumps over the lazy dog" ,): '''simple docstring''' lowerCAmelCase__ : Any = set() # Replace all the whitespace in our sentence lowerCAmelCase__ : List[Any] = input_str.re...
94
1
import comet # From: unbabel-comet import torch import datasets __lowerCAmelCase : Union[str, Any] = datasets.logging.get_logger(__name__) __lowerCAmelCase : Union[str, Any] = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and...
88
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a__ ( A_ ): '''simple docstring''' __magic_name__ = [ """decoder.version""", """decoder.output_proje...
88
1
"""simple docstring""" import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should ...
317
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_ava...
317
1
"""simple docstring""" import heapq def lowerCamelCase__ ( __snake_case ) -> Union[str, Any]: """simple docstring""" _UpperCamelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq mo...
194
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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 ..pipeline_params...
263
0
"""simple docstring""" from __future__ import annotations _UpperCamelCase: Any = list[list[int]] # assigning initial values to the grid _UpperCamelCase: Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3...
53
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _U...
53
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Dict = logging.get_logger(__name__) lowercase__ : str = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/reso...
224
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Tuple = logging.get_logger(__name__) lowercase__ : Any = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface...
224
1
'''simple docstring''' def lowercase__ ( __UpperCamelCase = 1000 )-> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
183
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ] ...
183
1
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _snake_case = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.model") @req...
36
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def __UpperCAmelCase ( a_ , a_ , a_ , a_ , a_): snake_case_ = np.array([[...
178
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowercase : Union[str, Any] = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Lear...
371
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowercase : Tuple = argparse.ArgumentParser() parser.add_argument( ...
311
0
"""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 __A ( A_ ,uni...
16
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class __A ( A_ ): '''simple docstring''' def __init_...
16
1
'''simple docstring''' from __future__ import annotations def a ( __a , __a ) -> bool: '''simple docstring''' if len(__a ) == 0: return False UpperCamelCase__ :List[Any] = len(__a ) // 2 if a_list[midpoint] == item: ...
219
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when sw...
219
1
def A (__A : int ) -> list: """simple docstring""" UpperCAmelCase_ = int(__A ) if n_element < 1: UpperCAmelCase_ = ValueError('''a should be a positive number''' ) raise my_error ...
51
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowercase : Any = logging.get_logger(__name__) # pylint: disable=invalid-name class A__ ( __UpperCAmel...
99
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = {'...
366
from collections import deque from math import floor from random import random from time import time class __a : def __init__( self ) -> Dict: '''simple docstring''' lowercase__: Dict = {} def SCREAMING_SNAKE_CASE__ ( s...
288
0
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTokenizer __a ...
337
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTo...
1
0
"""simple docstring""" def snake_case__ ( __lowerCamelCase : str ): """simple docstring""" lowerCamelCase__ : List[str] =[0 for i in range(len(__lowerCamelCase ) )] # initialize interval's left pointer and right pointer lowerCamelCase__ , lowerCamelC...
272
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ran...
272
1
'''simple docstring''' def _A ( snake_case ) -> list[int]: if length <= 0 or not isinstance(snake_case , snake_case ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(snake_case )] if __name__ == "__main__": print(hexagon...
250
'''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, AutoModelF...
161
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_conf...
353
"""simple docstring""" import itertools import string from collections.abc import Generator, Iterable def __UpperCAmelCase ( UpperCAmelCase_ : Iterable[str] , UpperCAmelCase_ : int ) -> Generator[tuple[str, ...], None, None]: '''simple docstring''' ...
95
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor A : int = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self , *__a , ...
57
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils impor...
108
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiec...
231
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Any = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_avai...
231
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch class ...
277
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def lowercase_ (A : List[str] ): snake_case_...
277
1
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar _UpperCAmelCase = TypeVar("""T""") def UpperCamelCase ( __lowercase : int ): '''simple docstring''' return (position - 1) // 2 def UpperCamelCase ...
192
from math import isqrt def UpperCamelCase ( __lowercase : int ): '''simple docstring''' return all(number % divisor != 0 for divisor in range(2 ,isqrt(__lowercase ) + 1 ) ) def UpperCamelCase ( __lowercase : int = 10**6 ): '''si...
192
1
"""simple docstring""" import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageCl...
45
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
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Path from url...
36
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowercase : Any = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} ...
36
1
from math import factorial def UpperCAmelCase__ ( lowerCamelCase = 20 ): lowercase :Any = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... lowercase :List[str] = n // 2 return int(factorial(lowerCamelCase ) / (factorial(low...
236
import torch def UpperCAmelCase__ ( ): if torch.cuda.is_available(): lowercase :Optional[int] = torch.cuda.device_count() else: lowercase :Dict = 0 print(F"Successfully ran on {num_gpus} GPUs" ) if __name__ == "__main__": main()
236
1
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version SCREAMING_SNAKE_CASE__ : Tuple = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize ...
358
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common im...
339
0
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket" ) @patch("builtins.open" ) def UpperCamelCase_( snake_case : Tuple , snake_case : Dict ): '''simple docstring''' ...
85
'''simple docstring''' import math import os import sys def lowercase_ ( lowerCAmelCase__ : str ): """simple docstring""" __UpperCAmelCase : Any = """""" try: with open(lowerCAmelCase__ , """rb""" ) as binary_file: _...
254
0
import copy import random from transformers import CLIPTokenizer class UpperCAmelCase_ ( _UpperCamelCase ): '''simple docstring''' def __init__( self , *_A , **_A ): '''simple docstring''' super().__init__(*_SCREAMING_SNAKE_CASE...
368
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 transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbos...
118
0
'''simple docstring''' import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__...
161
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..u...
161
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : str = logging.get_logger(__name__) __A : Union[str, Any] = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetune...
27
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __A : Any = logging.get_logger(__name__) __A : Dict = {'''vocab_fi...
27
1