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""" 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, BertJapaneseTok...
96
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCAmelCase ( A__ ): ...
207
0
'''simple docstring''' def lowercase_ ( lowerCAmelCase__ : List[Any] ): """simple docstring""" __UpperCAmelCase : Optional[int] = 1 __UpperCAmelCase : Optional[Any] = 2 while i * i <= n: __UpperCAmelCase : str = 0 wh...
366
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configura...
16
0
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.u...
340
import argparse import os 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_task_guides.py a_ = '''src/transformers''' a_ = '''docs/source/en/tasks''' def ...
340
1
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_util...
138
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxM...
138
1
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_tr...
108
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : List[Any] , SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : List[Any] ): '''simple docstring''' if height >= 1: move_tower(height - 1 , ...
108
1
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' ...
351
# 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 appl...
105
0
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor lowerCAmelCase : int = logging.get_logger(__name__) class __lowercase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *lowerCAmelCase__ : ...
13
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase : Union[str, Any] = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attenti...
13
1
'''simple docstring''' from __future__ import annotations class __UpperCamelCase : def __init__( self :Dict ,_UpperCamelCase :list[list[int]] ): snake_case_ : Optional[int] = TypeError( """Matrices must be formed from a list of zero...
358
'''simple docstring''' import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def UpperCAmelCase ( lowerCamelCase_ :str ): ''...
8
0
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
158
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def lowerCamelCase ( l...
331
0
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_...
254
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" lowerCAmelCase__ :list[list[int]] = [[0 for _ in range(_SCREAMING_SNAKE_CASE )] for _ in range(m + 1 )] for i in range(m + 1 ): lowerCAmelCase__ :str ...
254
1
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowerCame...
308
from heapq import heappop, heappush import numpy as np def snake_case( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , ) -> tuple[float | int, list[tuple[int, int]]]: '''simple docstring''' lowercase , lowercase : Op...
308
1
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fr...
355
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
0
from bisect import bisect from itertools import accumulate def lowerCamelCase__ ( snake_case_ : Optional[Any] , snake_case_ : Tuple , snake_case_ : Optional[Any] , snake_case_ : Dict ) -> str: __snake_case = sorted(...
24
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class lowerc...
222
0
'''simple docstring''' import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): ...
55
'''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
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...
261
"""simple docstring""" import copy import re class snake_case__ : _snake_case : Dict = """hp""" _snake_case : List[str] = {} _snake_case : int = None @classmethod def a__ ( cls , lowerCamelCase , lowerCamelCase ): __a = prefix ...
261
1
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 __lowerCamelCase = logging.get_logger(__...
353
"""simple docstring""" 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 UpperCamelCase__( __A ...
154
0
"""simple docstring""" import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def a_ ( lowerCamelCase ): return input_array.reshape((input_array.size, 1) ) def a_ ( lowerCamelCase ...
98
"""simple docstring""" from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCAmelCase__ (snake_case__ : str , snake_case__ : str ): """simple docstring""" _snake_case : Optional[Any] ...
64
0
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_file...
292
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) A_ : Tuple = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfi...
292
1
'''simple docstring''' from __future__ import annotations from collections.abc import Generator def UpperCAmelCase_ ( ): lowercase_ :dict[int, int] = {} lowercase_ :Dict = 2 while True: lowercase_ :Optional[Any] = factor_map.pop(__lowerCamelCa...
223
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int ,__lowerCamelCase : int ): return int((input_a, input_a).count(0 ) == 0 ) def UpperCAmelCase_ ( ): assert and_gate(0 ,0 ) == 0 assert and_gate(0 ,1 ) == 0 assert and_gate(1 ,0 ...
223
1
'''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_configuration_co...
370
'''simple docstring''' 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 O...
251
0
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) Uppe...
181
def __UpperCAmelCase ( __a : float ) -> float: """simple docstring""" return 10 - x * x def __UpperCAmelCase ( __a : float ,__a : float ) -> float: """simple docstring""" if equation(__a ) * equation(__a ) >= 0: raise ValueErr...
235
0
def lowerCAmelCase_ ( __lowerCAmelCase )-> list[list[int]]: '''simple docstring''' UpperCAmelCase : List[str] =[] if len(lowerCamelCase_ ) == 1: return [nums.copy()] for _ in range(len(lowerCamelCase_ ) ): UpperCAmelCase : int...
367
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __snake_case ( lowerCamelCase__ ): @require_torch def UpperCAmelCase__ ( self ) -> List[str]: '...
78
0
"""simple docstring""" # Imports import numpy as np class A_ : '''simple docstring''' def __init__( self , lowercase_=None , lowercase_=None , lowercase_=None , lowercase_=None , lowercase_=None ): """simple docstring""" self.set_matricies(red=lowercase_ ,...
61
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
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __A = logging.get_logger(__name__) def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> List[Any]: "...
366
from ..utils import DummyObject, requires_backends class lowercase_ ( metaclass=__lowercase ): UpperCamelCase_ : Optional[int] = ["speech"] def __init__( self : str , *A__ : List[str] , **A__ : Tuple ) -> Optional[Any]: requi...
278
0
'''simple docstring''' def lowercase__( __UpperCamelCase: Dict ,__UpperCamelCase: Dict ): """simple docstring""" if not len(UpperCAmelCase_ ) == len(UpperCAmelCase_ ) == 3: raise ValueError('Please enter a valid equation.' ) if equationa[0] =...
251
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Optional[Any] = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json', } c...
83
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase = 50 ) -> int: snake_case_ = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ...
355
"""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 .token...
312
0
'''simple docstring''' from collections import defaultdict from math import gcd def UpperCamelCase__ ( lowerCAmelCase = 1_50_00_00 ): """simple docstring""" _lowerCAmelCase = defaultdict(lowerCAmelCase ) _lowerCAmelCase ...
70
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): UpperCAmelCase_ = namedtuple("result" , "name value" ) if (vo...
241
"""simple docstring""" from collections.abc import Iterable from typing import Generic, TypeVar lowerCamelCase = TypeVar("""_T""") class lowercase__ ( Generic[_T] ): '''simple docstring''' def __init__( self : int , _Up...
241
1
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __magic_name__ (...
239
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentP...
239
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor A_ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( UpperCamelCase ): def __init__( self : Optional[Any] , *snake_c...
296
"""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 transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import...
296
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class SCREAMING_SNAKE_CASE__ ( lowercase__ ): snake_case__ ...
32
'''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 # # U...
239
0
def A ( __UpperCAmelCase ) -> int: '''simple docstring''' if n == 1 or not isinstance(snake_case__ , snake_case__ ): return 0 elif n == 2: return 1 else: UpperCAmelCase_ = [0, 1] for i in range(2 ...
365
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def A ( __UpperCAmelCase , __UpperCAmelCase=() , __UpperCAmelCase=None , __UpperCAmelCase="no" , __...
344
0
from functools import lru_cache @lru_cache def UpperCAmelCase_ ( __snake_case ) -> int: """simple docstring""" if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": ...
5
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class lowerCamelCase__ ( nn.Module): def __init__(self , UpperCAmelCase = 1_6 , UpperCAmelCase = 8_8 , UpperCAmelCase = None , UpperCAmelCase ...
5
1
import math def lowerCAmelCase__ ( a__ = 100 ) ->int: '''simple docstring''' _UpperCamelCase = sum(i * i for i in range(1 , n + 1 ) ) _UpperCamelCase = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squa...
63
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
1
'''simple docstring''' _lowerCAmelCase = 8.314_462 # Unit - J mol-1 K-1 def __lowerCAmelCase ( snake_case__ , snake_case__ , snake_case__ ): if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("Invalid inputs. Enter positive value."...
298
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class A ( SCREA...
298
1
"""simple docstring""" import unittest from knapsack import knapsack as k class __UpperCAmelCase( unittest.TestCase ): """simple docstring""" def UpperCAmelCase_ ( self ): '''simple docstring''' lowe...
150
"""simple docstring""" import os from pathlib import Path def lowercase__() ->List[Any]: """simple docstring""" from torch.utils.cpp_extension import load lowercase__ : Any= Path(A ).resolve().parent.parent.parent / "kerne...
150
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor _lowerCamelCase : List[Any] = logging.get_logger(__name__) class lowercase ( __UpperCAmelCase): def __init__...
167
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Any = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', '...
167
1
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class __snake_case ( yaml.SafeLoader ): '''simple docstring''' def UpperCAmelCase__ ( self : int , A : Optional[int] ): __sna...
363
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils impor...
293
0
"""simple docstring""" from math import factorial _lowercase = {str(digit): factorial(digit) for digit in range(10)} def _snake_case ( snake_case__ : int ): if not isinstance(snake_case__ , snake_case__ ): raise TypeError('Parameter number must be int' ) if number ...
74
import argparse import os import re lowercase_ = 'src/transformers' # Pattern that looks at the indentation in a line. lowercase_ = re.compile(R'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. lowercase_ = re.compile(R'^\s*"([^"]+)":') # Pattern that...
205
0
"""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, TextInput, TruncationSt...
371
"""simple docstring""" from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import * ...
336
0
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, require_sentencepiece, require...
13
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : List[Any] = { "configuration_tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig"], "tokenization_tapas...
238
0
"""simple docstring""" def _A ( UpperCamelCase_ : int = 10**12) -> int: '''simple docstring''' __lowercase = 1 __lowercase = 0 __lowercase = 1 __lowercase = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * num...
361
"""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 # ...
144
0
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_arra...
196
"""simple docstring""" def _lowerCamelCase( a = 1_0_0_0 ): __a = 3 __a = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: result -= a a += 1 return re...
261
0
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modeli...
358
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 import TEXT_GUIDED_IM...
29
0
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class SCREAMING_SNAKE_CASE__ ( _lowercase ): '''simple docstring''' __lowerCamelCase : int = CustomTokenizer pass
116
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixi...
41
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_: Optional[Any] ={ "configuration_megatron_bert": ["MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegatronBertConfig"], } try: if not...
360
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : int = 1_00_00_00 ) -> int: '''simple docstring''' UpperCAmelCase_ = limit + 1 UpperCAmelCase_ = [0] * limit for first_term in range(1 , snake_case_ ): for n in range(snake_cas...
106
0
'''simple docstring''' import random class a_ : @staticmethod def lowercase__ ( lowercase : str ): """simple docstring""" lowercase_ :Union[str, Any] = [ord(lowercase ) for i in text] lowercas...
223
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : int ={ '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
223
1
"""simple docstring""" _lowerCAmelCase : List[Any] = range(2, 20 + 1) _lowerCAmelCase : Dict = [10**k for k in range(ks[-1] + 1)] _lowerCAmelCase : dict[int, dict[int, list[list[int]]]] = {} def __snake_case ( SCREAMING_SNAKE_CASE__ : Any ...
202
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowerCAmelCase : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepend...
202
1
"""simple docstring""" 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,...
109
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets SCREAMING_SNAKE_CASE_: Optional[Any] ='\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n ...
1
0
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, BartForSequenceClassif...
252
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def UpperCamelCase ( _a ) -> Union[str, Any]: '''simple docstring''' return getitem, k def UpperCamelCase ( _a , ...
252
1
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _snake_case : lowerCAmelCase_ : int lowerCAmelCase_ : TreeNode | None = None lowerCAmelCase_ : TreeNode | No...
85
"""simple docstring""" 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_n...
153
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = {'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']} try: if not is_torch_available(): rai...
361
def _A ( lowerCAmelCase_ : int = 1000 ): """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
221
0
from __future__ import annotations from fractions import Fraction def A ( a_ ,a_ ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( a_ ) ...
71
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't ...
102
0
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem lowercase : Any = importlib.util.find_spec("""s3fs""") is not None if _has_safs: from .safilesystem import SaFi...
285
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowercase : Union[str, Any] = logging.get_logger(_...
285
1
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''', [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''', num_bytes=13_37, num_...
194
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _a = argparse.ArgumentParser( description=( """Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Le...
194
1
'''simple docstring''' def _UpperCAmelCase ( _UpperCamelCase : list ) -> list: A_ = len(_UpperCamelCase ) for i in range(1, _UpperCamelCase ): A_ = collection[i] A_ = 0 A_ = i -...
357
'''simple docstring''' from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __snake_case : Optional[Any] = logging.get_logger(__name__) __snake_case : Tup...
18
0
from typing import Any class snake_case_ : def __init__( self : Any , lowercase_ : Any ) -> List[str]: lowercase__ : str = data lowercase__ : List[str] = None class snake_case_ : def...
87
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big...
87
1
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, TFBaseModelOutputWi...
297
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __lowerCamel...
297
1
"""simple docstring""" import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_...
16
'''simple docstring''' 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 lowerCamelCase ( tf.keras.layers.Layer ): '''simple docst...
134
0
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node A__ : Union[str, Any] =4 A__ : Optional[Any] ...
354
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, ...
220
0
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration __lowercase : Dict = 50000 __lowercase : Dict = 5000 __lowercase , __lowercase : Optional[int] = os.path.split(__file__) __lowerc...
318
'''simple docstring''' from __future__ import annotations import time __lowercase : List[Any] = list[tuple[int, int]] __lowercase : List[Any] = [ [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...
318
1
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_DEF...
348
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
348
1
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
73
import os import sys import unittest lowerCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backen...
199
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, ) __SCREAMING_SNAKE_CASE : Dict = {'''configuratio...
350
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel...
73
0
'''simple docstring''' 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_tor...
70
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position A__ : Dict ='''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.pyth...
70
1
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_sta...
266
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class snake_case__ (A__ ): """simple docstring""" def __init__( self , __lowercase , __lowercase ) -> int: """simple docstring""" ...
266
1
"""simple docstring""" import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class a ( __a, unittest.TestCase ): """simple docstring""" ...
335
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lowerCAmelCase ( __a , unittest.TestCase ): _lo...
231
0
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() __a ...
364
'''simple docstring''' import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="session" ) def __UpperCAmelCase ...
17
0
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokeniz...
26
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ) -> List[Any]: # noqa: E741 _lowerCAmelCase : Optional[int] = len(_lowerCamelCase ) _lowerCAmelCase : str = 0 _lowerCAmelCase : Any = [0] * n ...
44
0
"""simple docstring""" import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( '''The `image_to_image.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionImg2ImgPipeline` instead.''' )
362
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int = 4000000 ) -> int: '''simple docstring''' __lowerCamelCase : Tuple = [0, 1] __lowerCamelCase : Union[str, Any] = 0 while fib[i] <= n: fib.append(fib[i] ...
64
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase : List[Any] = { "camember...
169
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput _lowerCAmelCase : List[Any] = "scheduler_config.json" class _UpperCamelCase ...
169
1
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 import require_vision from tra...
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
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase : List[Any] = logging.get_logger(__name__) class __magic_name__ ( lowerCamelCase__ ): """...
300
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __magic_name__ ( lowerCamelCase__ ): """simple docstring""" __UpperCamelCase = (DDPMScheduler,) def SCREAMING_SNAKE_CASE ( self :Union[s...
300
1
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor lowercase : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ): """simple docstring""" def __in...
171
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 .tokenization_rembert import...
171
1
import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def A ( ...
48
"""simple docstring""" from __future__ import annotations def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case ) -> int | float: """simple docstring""" if len(__snake_case ) == 0: raise ValueError('''find_max() arg is an empty s...
194
0
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import logging ...
360
# 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 # # Unless required by applica...
278
0
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCAmelCase : Union[str, Any] =4 lowerCAmelCase ...
223
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import to...
223
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' lowercase_ = [1] lowercase_ , lowercase_ , lowercase_ = 0, 0, 0 lowercase_ = ugly_nums[ia] * 2 lowercase_ = ugly_nums[ia]...
313
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators ...
313
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : Union[str, Any] = {'configuration_xlnet': ['XLNET_...
83
'''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_verbosit...
311
0
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> Union[str, Any]: """simple docstring""" ...
115
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterMixin ...
115
1
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) snake_case_ = str(SCREAMING_SNAKE_CASE__ ) snake_case_...
8
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 lowerCAmelCase = 'src/transformers' # This is to make s...
110
0
"""simple docstring""" def lowercase__ ( snake_case_ :int = 10**9 ): __UpperCAmelCase = 1 __UpperCAmelCase = 2 __UpperCAmelCase = 0 __UpperCAmelCase = 0 __UpperCAmelCase = 0 while perimeter <= max_perimeter: perimete...
86
"""simple docstring""" import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class _Up...
86
1
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( snake_case_ ): ...
79
'''simple docstring''' def __lowercase ( __lowercase ) -> int: '''simple docstring''' assert isinstance(__lowercase , __lowercase ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1:...
79
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import...
217
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b...
217
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import...
37
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) _snake_case : Any = models.Sequential() # Step 1 - Convol...
123
0
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...
15
import argparse import os import torch from transformers.utils import WEIGHTS_NAME a__ = ['''small''', '''medium''', '''large'''] a__ = '''lm_head.decoder.weight''' a__ = '''lm_head.weight''' def __UpperCAmelCase ( __a : str ,__a : str ) -> ...
15
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
325
import math def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int ) -> bool: assert isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are prime...
325
1
UpperCamelCase__ = "Tobias Carryer" from time import time class __SCREAMING_SNAKE_CASE : def __init__( self , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase=int(time() ) ): # noqa: B008 UpperCamelCase__ = mult...
87
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConfig", "SwiftFormerOnnxConfig", ...
87
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 # # ...
89
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCamelCase ( A__ ): '''simple docstring''' a_ : str = ["""image_processor""", """tokenizer"""] a_ : List[str] ...
241
0
def _A ( lowerCAmelCase_ : int = 3 , lowerCAmelCase_ : int = 7 , lowerCAmelCase_ : int = 100_0000 ): """simple docstring""" lowerCAmelCase__ = 0 lowerCAmelCase__ = 1 for current_denominator in range(1 ...
221
from statistics import mean, stdev def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : int = 3 ): """simple docstring""" lowerCAmelCase__ = min(lowerCAmelCase_ ) lowerCAmelCase__ = max(lowerCAmelCase_ ) # ...
221
1
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import...
200
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
336
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase ( UpperCAmelCase ) -> bool: snake_case_ = str(UpperCAmelCase ) return len(UpperCAmelCase ) == 9 and set(UpperCAmelCase ) == set('123456789' ) def UpperCAmelCase ( ) -> int | None: for base_nu...
312
"""simple docstring""" __UpperCamelCase = 256 # Modulus to hash a string __UpperCamelCase = 100_0003 def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> bool: snake_case_ = len(UpperCAmelCase ) snake_case_ = len(UpperCAmelCase ) if p_len > t_len: ...
312
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_t...
163
'''simple docstring''' import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import ...
163
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :int ) -> List[str]: a__ ...
109
from __future__ import annotations def __lowercase ( __lowerCAmelCase : float , __lowerCAmelCase : float , __lowerCAmelCase : float ): if (voltage, current, resistance).count(0 ) != 1: raise ValueError('One and only one argument mus...
109
1
import math def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> list: UpperCamelCase__ : Tuple = [True] * n UpperCamelCase__ : Optional[Any] = False UpperCamelCase__ : int = False UpperCamelCase_...
201
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from...
7
0
"""simple docstring""" def lowerCamelCase__ ( __snake_case, __snake_case ) -> float: """simple docstring""" _validate_point(__snake_case ) _validate_point(__snake_case ) if len(__snake_case ) != len(__snake_case ): ra...
358
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""...
100
0
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCame...
21
'''simple docstring''' def snake_case_ (_a : str , _a : str ): UpperCAmelCase = len(_a ) + 1 UpperCAmelCase = len(_a ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with...
34
0
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optuna, defau...
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
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def _lowercase ( lowercase__ , lowercase__ , lowercase__ , lowercase__=5 ): # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_interface.py assert masked_input.coun...
275
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
86
0
from functools import reduce a__: Union[str, Any] = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '66896...
39
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @requ...
39
1