code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
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 __a :List[Any] = logging.get_logger(__nam...
86
"""simple docstring""" 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.util...
453
0
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
710
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY_UN...
390
0
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if...
18
"""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 SCREAMING_SNAKE_CASE...
156
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : int =logging.get_logger(__name__) _lowercase : Any ={ "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } class _SC...
711
'''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, BartForSequen...
574
0
"""simple docstring""" import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOC...
83
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCamelCase ( unittest.TestCase ): def __A ( self ): A__ = 10 def __A ( self ): ...
491
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
717
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 UpperCAmelCase_ = '''scheduler_config.json''' class __SCREAMING_SNAKE_CASE ( ...
519
0
def __UpperCAmelCase ( lowerCamelCase_ : int ) -> list[int]: """simple docstring""" if length <= 0 or not isinstance(lowerCamelCase_ , lowerCamelCase_ ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(...
105
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class UpperCamelCase__ : """simple docstring""" def __init__( self , snake_case__ ): '''simple docstring''' _lowerCAmel...
444
0
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') __lowerCAmelCase = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:])...
666
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { 'configuration_git': ['GIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GitConfig', 'GitVisionConfig'], 'proce...
666
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig'''...
7
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.utils...
408
0
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = None ) -> Optional[int]: if vers...
707
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_t...
113
0
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _SCREAMING_SNAKE_CASE ( ): '''simple docstring''' A: str = 9 A: Union[str, Any] = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], ...
135
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipel...
135
1
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Union[str, Any] = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/reso...
714
"""simple docstring""" from __future__ import annotations def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> list[int]: snake_case_ = 0 snake_case_ = len(_SCREAMING_SNAKE_CASE ) - 1 while i < j: if nums[i] + nums[j...
2
0
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class a_ ( ...
301
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _lowerCamelCase ( __a, __a, __a, __a = 100, ): SCREAMING_SNAKE_CASE_ = x_start SCREAMING_SNAKE_CASE_ = fnc(__a ) SCREAMING_SNAKE_CASE_ = 0.0 for _ in ran...
626
0
'''simple docstring''' import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) UpperCAmelCase_ : Any = lo...
424
'''simple docstring''' def UpperCAmelCase_ ( A , A , A ): '''simple docstring''' return round(float(moles / volume ) * nfactor ) def UpperCAmelCase_ ( A , A , A ): '''simple docstring''' return round(float((moles * 0.08_21 * temperature) / (volu...
424
1
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_collator...
276
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 _SCREAMING_SNAKE_CASE ( __UpperCamelCase ...
276
1
'''simple docstring''' from PIL import Image def __lowercase ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Image: """simple docstring""" def brightness(__SCREAMING_SNAKE_CASE ) -> float: return 128 + level + (c - 128) if not -255.0 <= le...
201
'''simple docstring''' from ...processing_utils import ProcessorMixin class lowerCAmelCase_ ( snake_case__ ): """simple docstring""" a_ :Dict =["""image_processor""", """feature_extractor"""] a_ :str ="""TvltImageProcessor""" a_ :str ...
201
1
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from tra...
684
def __UpperCamelCase ( _A ): 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 as an integer''' ) if nu...
431
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class lowerCamelCase__ ( unittest.TestCase):...
714
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
90
0
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def A__ ( snake_case_ : Union[str, Any] ): SCREAMING_SNAKE_CASE__: Dict= test_file.split(os.path.sep ) if componen...
64
def _A ( lowerCamelCase ): a__ : Optional[Any] = 1 for i in range(1 , num + 1 ): fact *= i return fact def _A ( lowerCamelCase ): a__ : List[Any] = 0 while number > 0: a__ : str = number % 10 sum_of_digits += last_digit ...
112
0
'''simple docstring''' class __A : def __init__(self : Any , __a : int , __a : List[Any]=None , __a : Union[str, Any]=None ): UpperCAmelCase_ = data UpperCAmelCase_ = previous UpperCAmelCase_ = n...
415
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE_: Optional[Any] ={ 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig']...
415
1
import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) A = logging.getLogger() def __UpperCAmelCase ( __A ) -...
475
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 dep...
475
1
'''simple docstring''' import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWater...
273
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available A : Dict = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): rais...
273
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : int = logging.get_logger(__name__) lowerCAmelCase : Any = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json""", "...
202
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 lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : ...
202
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "microsoft/beit-base-patch16-224...
712
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class a ( unittest.TestCase ): def UpperCAmelCa...
376
0
import argparse import json import subprocess def _SCREAMING_SNAKE_CASE ( __lowercase : Any , __lowercase : str ) -> Optional[int]: """simple docstring""" __A = [] __A = ( f"curl -H \"Accept: application/vnd.github+json\" ...
637
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common im...
319
0
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Config...
258
"""simple docstring""" print((lambda quine: quine % quine)("""print((lambda quine: quine %% quine)(%r))"""))
258
1
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments _UpperCAmelCase = logging.getLogger(__name__) @dataclass class UpperCAmelCase ( lowerCAmelCase__ ): ...
558
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments ...
311
0
"""simple docstring""" def A ( snake_case :int ) -> bool: __UpperCamelCase = (1 + 2_4 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def A ( snake_case :int = 5_0_0_0 ) -> int: __UpperCamelCase = [(i * (3 * i - 1)) // 2 for i in range(1 , ...
293
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCamelCase : Tuple = "." # In...
293
1
"""simple docstring""" def _UpperCamelCase ( ) -> Any: """simple docstring""" __UpperCAmelCase : Dict = [] __UpperCAmelCase : List[Any] = 1 while len(SCREAMING_SNAKE_CASE__ ) < 1e6: constant.append(str(SCREAMING_...
77
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class snake_case_ ( a_ ): __lowerCA...
237
0
"""simple docstring""" from __future__ import annotations def lowerCamelCase_ ( _lowerCamelCase ): if len(_lowerCamelCase ) < 2: raise ValueError('Monogons and Digons are not polygons in the Euclidean space' ) if any(i <= 0 for i in nums ): raise ValueError('All ...
709
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline A_ : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name class a_ ( snake_c...
696
0
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, ) snake_case = { 'configuration_xlm_...
67
import math import random from typing import Any from .hill_climbing import SearchProblem def __snake_case ( _UpperCamelCase , _UpperCamelCase = True , _UpperCamelCase = math.inf , _UpperCamelCase = -math.inf , _UpperCamelCase = math.inf , _UpperCamelCase = -math.inf , _Up...
487
0
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def A ( _UpperCAmelCase : str , _UpperCAmelCase : complex , _UpperCAmelCase : str = "x" , _UpperCAmelCase : float = 10**-10 , _UpperCAm...
639
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = "https://openaipublic....
639
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_input...
554
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism()...
554
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import...
40
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusio...
501
'''simple docstring''' __lowerCAmelCase : List[str] ="Alexander Joslin" import operator as op from .stack import Stack def UpperCamelCase ( _lowerCamelCase : str ): A__ = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} A__ = Stack()...
440
0
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tes...
115
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = logging.get_logger(__name__) a_ = {'''v...
115
1
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, 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_model...
158
'''simple docstring''' 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_v...
158
1
def __lowerCAmelCase ( __snake_case , __snake_case ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) __lowerCAmelCase = str(bin(__snake_case ) )[2:] # remove the leading "0b" __lowerCAmelCase ...
715
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : List[str] = logging.get_logger(__name__) lowerCamelCase : Dict = { '''microsoft/biogpt''': '''https://huggingface.co/microsoft/biogpt/resolve/main/config.json''', # See all Bio...
290
0
"""simple docstring""" from __future__ import annotations _lowerCAmelCase = list[tuple[int, int]] _lowerCAmelCase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, ...
264
'''simple docstring''' from collections import defaultdict class lowerCamelCase__ : """simple docstring""" def __init__( self : Tuple ,a__ : List[str] ,a__ : str ): a__ = total # total no of t...
331
0
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _UpperCAmelCase ( ...
704
'''simple docstring''' import argparse import os import re import packaging.version __snake_case : int = 'examples/' __snake_case : Dict = { 'examples': (re.compile(R'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compil...
174
0
import datasets from .evaluate import evaluate _UpperCAmelCase = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint arXiv:2103.0626...
504
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int = 4_000_000 ) -> int: __lowerCAmelCase : Union[str, Any] = [] __lowerCAmelCase , __lowerCAmelCase : Union[str, Any] = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(SCREAMING_SNAKE_CASE ...
504
1
'''simple docstring''' def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ ): '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: A : Dict = m...
704
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase : str = logging.get_logger(__name__) # TODO: upload to AWS lowercase : Optional[Any] = { 'yjernite/retribert-base-uncased': ( 'https://...
343
0
"""simple docstring""" import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, ...
222
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
222
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available _UpperCAmelCase : List[Any] = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() e...
108
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regre...
108
1
'''simple docstring''' from collections.abc import Callable import numpy as np def UpperCamelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ): A__ = int(np.c...
440
'''simple docstring''' from __future__ import annotations import math def UpperCamelCase ( _lowerCamelCase : int , _lowerCamelCase : int , _lowerCamelCase : bool , _lowerCamelCase : list[int] , _lowerCamelCase : float ): if depth < 0: raise ValueErr...
440
1
"""simple docstring""" a : str = 8.31_4462 # Unit - J mol-1 K-1 def _SCREAMING_SNAKE_CASE ( _lowercase : float , _lowercase : float , _lowercase : float ) ->float: '''simple docstring''' if moles < 0 or kelvin ...
31
"""simple docstring""" import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation imp...
31
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decision-transformer-gym-hopp...
320
"""simple docstring""" import operator def __snake_case ( _lowercase ,_lowercase = False ,_lowercase = None ): """simple docstring""" UpperCamelCase = operator.lt if reverse else operator.gt UpperCamelCase = solution or [] if not arr: ...
34
0
'''simple docstring''' import os from collections.abc import Iterator def __lowerCAmelCase (__lowerCAmelCase = "." ): for dir_path, dir_names, filenames in os.walk(__lowerCAmelCase ): _UpperCAmelCase : List[Any] = [d for d in dir_names if d != "scripts" and d[0] ...
700
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
0
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor a__ : Optional[int] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : str , ...
622
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 logging a__ : Optional[int] = logging.get_logger(__name__) a__ : ...
622
1
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def snake_case__ ( _A: List[str] ) -> Union[str, An...
721
'''simple docstring''' from collections.abc import Generator from math import sin def snake_case__ ( _A: bytes ) -> bytes: '''simple docstring''' if len(_A ) != 32: raise ValueError("""Input must be of length 32""" ) lowerCAmelCase = b"""""" f...
605
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
335
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class snake_case_ (lowerCamelCase_ ): UpperCAmelCase__ : ...
335
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ : Union[str, Any] = { 'configuration_roformer': ['ROFORMER_PRETRAI...
484
a_ : List[str] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' a_ : Any ...
484
1
'''simple docstring''' def UpperCamelCase ( lowercase_ : int , lowercase_ : int ) -> str: '''simple docstring''' return "\n".join( f'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplicati...
72
'''simple docstring''' import math import unittest from transformers import BioGptConfig, 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_...
263
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, )...
704
import math def _lowerCamelCase( lowerCAmelCase__ : float , lowerCAmelCase__ : float ): '''simple docstring''' return math.pow(lowerCAmelCase__ , 2 ) - a def _lowerCamelCase( lowerCAmelCase__ : float ): '''simple docstring'''...
97
0
import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() __a = logging.get_logger(__name__) ...
319
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): @require_torch ...
319
1
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available():...
716
"""simple docstring""" def snake_case__ ( __lowerCamelCase : int = 4000000 ): """simple docstring""" lowerCamelCase__ : Dict =[] lowerCamelCase__ , lowerCamelCase__ : Union[str, Any] =0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__lowerCamelCase ...
625
0
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowerCamelCase_ (UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : bool = False ): if ...
506
"""simple docstring""" from __future__ import annotations import math def lowerCamelCase_ (UpperCamelCase__ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even number...
506
1
from __future__ import annotations from math import pow, sqrt def a ( A__ , A__ , A__ ) -> List[str]: '''simple docstring''' if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0'''...
710
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch a_ :Optional[Any] ...
250
0
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
659
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __magic_name__ = TypeVar('''T''') class _SCREAMING_SNAKE_CASE ( Generic[T] ): def __init__( self , lowerCamelCase ): snake_case__ = data sna...
276
0
'''simple docstring''' import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def __lowerCamelCase ( __snake_case : int = 8 ) -> Optional[Any]: """simple docstring""" A__ : str =ascii_lette...
711
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : int = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTransf...
687
0
'''simple docstring''' import numpy as np def __A ( lowerCAmelCase_ ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
414
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase_ : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase_ : Any = { '''Intel/dpt-large''': '''https://hu...
414
1
def lowerCamelCase_ ( lowerCAmelCase__ : str ) -> Union[str, Any]: '''simple docstring''' if not head: return True # split the list to two parts A , A = head.next, head while fast and fast.next: A = fa...
714
def lowerCamelCase_ ( lowerCAmelCase__ : Dict , lowerCAmelCase__ : List[Any] ) -> Optional[int]: '''simple docstring''' A = '' for i in table: res += inp[i - 1] return res def lowerCamelCase_ ( lowerCAmelCase__ : List[...
224
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
192
import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ran...
192
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { "Intel/dpt-large": "https://huggingface.co/Intel/dpt-large/resolve/main/config.json", ...
129
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": __lowerCAmelCase = pd.read_csv("sample_data.csv", header=None) __lowerCAmelCase...
129
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __snake_case : Optional[int] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ...
215
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils i...
215
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixi...
289
'''simple docstring''' import re def _lowerCamelCase (__lowerCamelCase : str ) -> bool: a__ = re.compile( r"^(?:0|94|\+94|0{2}94)" r"7(0|1|2|4|5|6|7|8)" r"(-| |)" r"\d{7}$" ) return bool(re.search(__lowerCamelCase , __lowerCamelCase ) ...
289
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor snake_case_ = logging.get_logger(__name__) class a__ ( _lowercase ): def __init__(self : Any, *__UpperCAmelCase : Dict, **__UpperCA...
507
'''simple docstring''' import random from typing import Any def __lowercase (_SCREAMING_SNAKE_CASE :list ): for _ in range(len(_SCREAMING_SNAKE_CASE ) ): SCREAMING_SNAKE_CASE : List[str] = random.randint(0 , len(_SCREAMING_SNAKE_CASE ) - 1 ...
507
1
"""simple docstring""" snake_case = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' snake_ca...
719
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, requir...
406
0
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase__ = False class ...
630
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizer...
630
1
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __A =logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE ( snake_case_ ): def __init__( self , *lowercase , **lowercase ) -> None: warning...
313
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowerCamelCase_ ( lowerCamelCase__ ): if "cls_token" in name: lowerCamelCase_ = name.replace("cls_token" , "vit.em...
313
1
'''simple docstring''' from math import ceil, sqrt def UpperCAmelCase_ ( lowerCAmelCase_ = 100_0000 ): """simple docstring""" lowercase = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowercase = max(c...
310
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_ut...
310
1
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCamelCase (datasets.BeamBasedBuilder ): def ...
616
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availa...
616
1
'''simple docstring''' import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class UpperCAmelCase_ ( __snake_ca...
94
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=__snake_case ): """simple docstring""" __A = ["""flax""", """transformers"""] def __init__( self , *__UpperCamelCase , **__UpperCamelCase ): """simple docstring""" req...
187
0
def _lowerCAmelCase ( lowerCamelCase_ : int = 1_0_0_0 ): __lowercase = -1 __lowercase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c __lowercase = (n * n -...
704
'''simple docstring''' from argparse import ArgumentParser from .env import EnvironmentCommand def _lowerCAmelCase ( ): __lowercase = ArgumentParser('''Diffusers CLI tool''' , usage='''diffusers-cli <command> [<args>]''' ) __lowercase =...
56
0
"""simple docstring""" # Copyright (c) 2021-, NVIDIA CORPORATION. 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-...
610
"""simple docstring""" def __lowerCamelCase ( __UpperCamelCase ) -> str: """simple docstring""" return "".join([hex(__UpperCamelCase )[2:].zfill(2 ).upper() for byte in list(__UpperCamelCase )] ) def __lowerCamelCase ( __UpperCamelCase ) -> byte...
610
1
'''simple docstring''' import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch lowerCAmelCase__ : Optional[Any] ...
329
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): ...
329
1
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def _UpperCAmelCase ( self : Optional[Any] ): ...
562
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
562
1
import fire from utils import calculate_rouge, save_json def lowerCAmelCase ( UpperCAmelCase : str, UpperCAmelCase : Any, UpperCAmelCase : Optional[int]=None, **UpperCAmelCase : Tuple ) ->Any: """simple docstring""" ...
712
def lowerCAmelCase ( UpperCAmelCase ) ->list[int]: """simple docstring""" if num <= 0: raise ValueError('''Input must be a positive integer''' ) __magic_name__ : List[str] = [True] * (num + 1) __magic_name__ ...
336
0
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def SCREAMING_SNAKE_CASE__ ( snake_case__ :Tuple ) -> Tuple: # This defines a "chinese character" as anything in the CJK Unicode block: ...
67
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu from...
632
0
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def UpperCAmelCase ( A__ , A__ ) -> np.array: _snake_case : List[str] = f'''{sampling_rate}''' _snake_case : List[Any] ...
713
from timeit import timeit UpperCAmelCase_ = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan a canal panama" } # Ensure our test data is val...
519
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType lowerCamelCase__ : ...
12
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torc...
474
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/fa...
142
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'microsoft/focalnet-tiny': 'https://huggingface...
142
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : str = { """configuration_llama"...
218
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { """configuration_lxmert"...
218
1
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 TaTok...
707
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 transformers.utils impo...
531
0
'''simple docstring''' def A__ ( __lowerCAmelCase : str , __lowerCAmelCase : int ): return [sentence[i : i + ngram_size] for i in range(len(__lowerCAmelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
50
"""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) ...
552
0
"""simple docstring""" def snake_case_ ( A_ : int = 10, A_ : int = 22 ): '''simple docstring''' _lowerCamelCase : Union[str, Any] = range(1, A_ ) _lowerCamelCase : Dict = range(1, A_ ) return sum( ...
598
"""simple docstring""" 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_file...
598
1
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 ConfigTester from ...test_modeling_common...
352
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __a ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> str: # load base model SCR...
352
1
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from ...
637
"""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_configuration_comm...
637
1
import random from .binary_exp_mod import bin_exp_mod def lowercase__ ( A_: List[str] , A_: Optional[Any]=1000 ) -> List[str]: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # ...
68
"""simple docstring""" def __lowercase ( snake_case_ : int = 2000000 ) ->int: '''simple docstring''' __A : List[Any] = [0 for i in range(n + 1 )] __A : str = 1 __A : Dict = 1 for i in range(2 ,int(n**0.5 ) + 1 ): ...
177
0
'''simple docstring''' import math import sys def _SCREAMING_SNAKE_CASE ( A : str ) -> str: """simple docstring""" __snake_case : Dict = '' try: with open(A , 'rb' ) as binary_file: __snake_case ...
715
'''simple docstring''' import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is...
61
0
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers ...
55
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_v...
464
0
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : List[Any] = ...
703
def _UpperCamelCase ( lowercase__ ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowercase__ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('doctest').testmod()
260
0
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy ...
397
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_ut...
397
1
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase ( A__ ): ...
391
def _lowerCAmelCase ( A__: int , A__: int ): '''simple docstring''' if number < 0 or shift_amount < 0: raise ValueError('''both inputs must be positive integers''' ) UpperCAmelCase = str(bin(A__ ) ) binary_number += "0" * shift_amount ret...
391
1
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin __a : ...
637
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequence...
637
1
# 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 app...
708
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase__ ( UpperCAmelCase__): '''simple docstring...
433
0
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def __A ( _SCREAMING_SNAKE_CASE : BertModel , _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : str ): ...
211
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCAmelCase ( UpperCamelCase__ : BertModel , UpperCamelCase__ : str , UpperCamelCase__ : str ): ...
262
0
"""simple docstring""" from __future__ import annotations def _a ( _SCREAMING_SNAKE_CASE ) -> bool: snake_case_ = str(_SCREAMING_SNAKE_CASE ) return n == n[::-1] def _a ( _SCREAMING_SNAKE_CASE = 1_000_000 ) -> int: snake_c...
2
"""simple docstring""" 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 impor...
2
1
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets SCREAMING_SNAKE_CASE : str = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification},\n auth...
89
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorF...
150
0
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def UpperCamelCase ( a ) -> int: '''simple docstring''' __magic_name__ ...
700
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _lowerCAmelCase = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _lowerCAmelCase = [ord(letter) for letter in string.asci...
245
0