code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, Pat...
0
from math import sqrt def _lowerCAmelCase ( A__ ): assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase__ = True # 0 and 1 are none primes. if number <= 1: lowercase__ = False for diviso...
622
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torc...
1
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { """vocab_file""": """vocab.json""", """tokenizer_config...
2
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
622
0
'''simple docstring''' from collections.abc import Generator def A_( ): UpperCamelCase , UpperCamelCase = 0, 1 while True: UpperCamelCase , UpperCamelCase = b, a + b yield b def A_( A : int = 1000): ...
3
def _lowerCAmelCase ( A__ = 50_000_000 ): lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): ...
622
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : Tuple = { '''vinvino02/glpn-kitti''': '''https://huggingface.co/vinvino02/glpn-k...
4
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...util...
622
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """roberta-base""": """ht...
5
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import torc...
6
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
622
0
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline a = logging.get_logger(__name__) class l...
7
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
'''simple docstring''' import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, x...
8
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase__( lowerCamelCase , un...
622
0
def A ( ) -> int: return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(__UpperCamelCase , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f'{solution() = }')
9
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class lowerCAmelCase_ ( __lowercase ):...
10
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase_ = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "Dei...
11
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fr...
622
0
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Dict = 1_0 def UpperCamelCase ( lowercase_ , lowercase_ , lowercase_ , lowercase...
12
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__ : Optional[Any] = logging.getLogger() def _lowe...
622
0
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union A__ : Any = re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""") @total_ordering @data...
13
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__( lowerCamelCase , unittest.TestCase ): '''simple docstring''' A : int ...
622
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): ...
14
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 fro...
622
0
def UpperCamelCase ( __magic_name__ : Optional[Any] , __magic_name__ : Tuple ) -> int: """simple docstring""" lowercase__ = """""" for i in table: res += inp[i - 1] return res def UpperCamelCase ( __magic_name__ : int...
15
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
0
def __a ( A__ : str , A__ : str ): if len(A__ ) != len(A__ ): raise ValueError("String lengths must match!" ) SCREAMING_SNAKE_CASE = 0 for chara, chara in zip(A__ , A__ ): if chara != chara: count += 1 ...
16
def _lowerCAmelCase ( A__ = 600_851_475_143 ): try: lowercase__ = int(A__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater than or equa...
622
0
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self ...
17
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ = None ): lowercase__ = word_bank or [] # create a table lowercase__ = len(A__ ) + 1 lowercase__ = [] for _ in range(A__ ): table.append([] ) # seed value lowercas...
622
0
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) _lowerCAmelCase = sorted(string.lower() ) ...
18
a__ : Tuple = "Tobias Carryer" from time import time class UpperCAmelCase__: '''simple docstring''' def __init__( self : str , lowerCAmelCase : List[str] , lowerCAmelCase : Any , lowerCAmelCase : str , lowerCAmelCase : ...
622
0
"""simple docstring""" import fire from utils import calculate_rouge, save_json def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case=None, **__snake_case ) -> Optional[int]: """simple docstring""" _UpperCamelCase = [x.strip() ...
19
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any] , *l...
622
0
# 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 be considered # since t...
20
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_IMA...
622
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProces...
21
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
622
0
'''simple docstring''' import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoToken...
22
from math import sqrt def _lowerCAmelCase ( A__ ): assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase__ = True # 0 and 1 are none primes. if number <= 1: lowercase__ = False for diviso...
622
0
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(UpperCAmelCase__ ...
23
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Tuple = { '''configuration_llama''': ['''LLAMA_PRETRAINE...
24
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
622
0
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=1337 , num_examples=42 , dataset_name="my_datas...
25
def _lowerCAmelCase ( A__ = 50_000_000 ): lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): ...
622
0
'''simple docstring''' import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING __Upp...
26
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...util...
622
0
def __lowerCAmelCase( _SCREAMING_SNAKE_CASE ) -> int: """simple docstring""" if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): _A = F"Input value of [number={number}] must be an integer" raise TypeError(_S...
27
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
'''simple docstring''' from jiwer import compute_measures import datasets UpperCamelCase_ = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER ...
28
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
622
0
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex A_ = logging.getLogger(__name__) class __lowerCamelCase : def __init__( self ): low...
29
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.utils...
30
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase__( lowerCamelCase , un...
622
0
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) from transf...
31
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCAmelCase_ = (3, 9, -11, 0, 7, 5, 1, -1) UpperCAmelCase_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __UpperCamelCase : __A : int __A : Node | None...
32
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
0
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset 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 Ima...
33
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fr...
622
0
"""simple docstring""" # XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path SCREAMING_SNAKE_CASE_ = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import datacla...
34
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__ : Optional[Any] = logging.getLogger() def _lowe...
622
0
def a ( A__ , A__ ) -> None: '''simple docstring''' SCREAMING_SNAKE_CASE__ : str = len(A__ ) print('''The following activities are selected:''' ) # The first activity is always selected SCREAMING_SNAKE_CASE__ : List[str...
35
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__( lowerCamelCase , unittest.TestCase ): '''simple docstring''' A : int ...
622
0
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property from...
36
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 fro...
622
0
def UpperCamelCase_ ( __a ) -> "list[int]": if upper_limit < 0: raise ValueError("Limit for the Catalan sequence must be ≥ 0" ) a__ : List[str] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 a__ : Optional[int] = 1 if upper_limit > 0...
37
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
0
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: A_ : str = None try: import msvcrt except ImportError: A_ : Optional[int] = None try: import fcntl except ImportError: A_ : List[Any] = ...
38
def _lowerCAmelCase ( A__ = 600_851_475_143 ): try: lowercase__ = int(A__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater than or equa...
622
0
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, ...
39
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ = None ): lowercase__ = word_bank or [] # create a table lowercase__ = len(A__ ) + 1 lowercase__ = [] for _ in range(A__ ): table.append([] ) # seed value lowercas...
622
0
import os import re import shutil import sys import tempfile import unittest import black __UpperCAmelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_copies # noqa: E402 # This is the reference co...
40
a__ : Tuple = "Tobias Carryer" from time import time class UpperCAmelCase__: '''simple docstring''' def __init__( self : str , lowerCAmelCase : List[str] , lowerCAmelCase : Any , lowerCAmelCase : str , lowerCAmelCase : ...
622
0
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_te...
41
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any] , *l...
622
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A_ = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetConfig", "ResNetOnnxConfi...
42
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_IMA...
622
0
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL lowerCAmelCase = version.parse(version.parse(torch.__version__).base_version) < version.parse('1.11') def _a ( SCREAMING_SNAKE_CASE , ...
43
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
622
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Optional[Any] = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'to...
44
from math import sqrt def _lowerCAmelCase ( A__ ): assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase__ = True # 0 and 1 are none primes. if number <= 1: lowercase__ = False for diviso...
622
0
from collections.abc import Sequence def A ( lowercase__ : Sequence[int] | None = None ) -> int: if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) UpperCamelCase__ :int = nums[0] for i in range(1 , len(lowercase__ ) ): UpperCamelCase__...
45
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_a...
46
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
622
0
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller SCREAMING_SNAKE_CASE__ = 3 def UpperCAmelCase__ ( lowerCamelCase_ : int ): print('Generating primitive root of p' ) while True: __...
47
def _lowerCAmelCase ( A__ = 50_000_000 ): lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): ...
622
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer UpperCAmelCase__ : str = logging.get_logg...
48
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...util...
622
0
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex _lowercase : int = logging.getLogger(__name__) class _UpperCAmelCase : ...
49
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...
50
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
622
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available a__ : Optional[Any] = {'tokenization_herbert': ['HerbertTokenizer']} try: if not is_tokenizers_available(): raise OptionalDepen...
51
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRE...
52
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase__( lowerCamelCase , un...
622
0
def a_ ( lowerCAmelCase_ : int = 10 ): if not isinstance(lowerCAmelCase_, lowerCAmelCase_ ) or n < 0: raise ValueError('Invalid input' ) __lowerCAmelCase = 10**n __lowerCAmelCase = 2_8433 * (pow(2, 783_0457, lowerCAmelCase_...
53
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ):...
54
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
0
def UpperCAmelCase ( a_ = 1_0_0_0 ) -> int: """simple docstring""" __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 result if __nam...
55
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fr...
622
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Any = logging.get_logger(__name__) _a : Optional[Any] = { "xlm-mlm-e...
56
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__ : Optional[Any] = logging.getLogger() def _lowe...
622
0
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_availa...
57
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__( lowerCamelCase , unittest.TestCase ): '''simple docstring''' A : int ...
622
0
"""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 ...
58
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 fro...
622
0
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_utils import OnnxRuntime...
59
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
0
def lowerCamelCase_ ( _UpperCamelCase ) -> Any: """simple docstring""" snake_case_ : Dict = [] snake_case_ : int = set({'''(''', '''[''', '''{'''} ) snake_case_ : Dict = set({''')''', ''']''', '''}'''} ) ...
60
def _lowerCAmelCase ( A__ = 600_851_475_143 ): try: lowercase__ = int(A__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater than or equa...
622
0
def _A ( lowerCAmelCase_ : int ): """simple docstring""" lowerCAmelCase__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def _A ( lowerCAmelCase_ : int ): """simple docstring""" lowerCAmelCase_...
61
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ = None ): lowercase__ = word_bank or [] # create a table lowercase__ = len(A__ ) + 1 lowercase__ = [] for _ in range(A__ ): table.append([] ) # seed value lowercas...
622
0
def lowerCamelCase__ ( lowercase , lowercase , lowercase , lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[Any] = len(lowercase ), len(grid[0] ) if ( min(lowercase , lowercase ) < 0 ...
62
a__ : Tuple = "Tobias Carryer" from time import time class UpperCAmelCase__: '''simple docstring''' def __init__( self : str , lowerCAmelCase : List[str] , lowerCAmelCase : Any , lowerCAmelCase : str , lowerCAmelCase : ...
622
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor a : str = logging.get_logger(__name__) class a ( lowercase__ ): """simple docstring""" def __init__( self : Optional[Any] , *_...
63
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any] , *l...
622
0
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, ...
64
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_IMA...
622
0
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} t...
65
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
622
0
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 from trans...
66
from math import sqrt def _lowerCAmelCase ( A__ ): assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase__ = True # 0 and 1 are none primes. if number <= 1: lowercase__ = False for diviso...
622
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProc...
67
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
def lowercase__ ( A_: Optional[int] , A_: Optional[Any] , A_: Optional[int] ) -> Any: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(A_ , n - 1 , A_ ) * ...
68
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
622
0
'''simple docstring''' import math def __UpperCAmelCase ( _UpperCAmelCase : list , _UpperCAmelCase : int ) -> int: __snake_case = len(_UpperCAmelCase ) __snake_case = int(math.floor(math.sqrt(_UpperCAmelCase ) ) ) __snake_case = 0 ...
69
def _lowerCAmelCase ( A__ = 50_000_000 ): lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): ...
622
0
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_...
70
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...util...
622
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids...
71
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def UpperCamelCase ( lowercase_ : Tuple , lowercase_ : str , lowercase_ : Optional[Any] , lowercase_ : Tuple ...
72
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
622
0
import heapq as hq import math from collections.abc import Iterator class _snake_case : def __init__( self , a) -> Optional[Any]: SCREAMING_SNAKE_CASE = str(id_) SCREAMING_SNAKE_CASE = None SCREAMING_SNAKE_CASE = None SCREAMING_SNAK...
73
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __UpperCamelCase ( lowerCAmelCase__ ): ...
74
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase__( lowerCamelCase , un...
622
0
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a__ ( lowerCAmelCase__ ) -> Any: UpperCAmelCase__ : Union[str, Any] = [ '''decod...
75
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer a_ = logging.get_l...
76
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
0
"""simple docstring""" from __future__ import annotations from random import choice def _UpperCamelCase ( UpperCamelCase ) -> Optional[Any]: """simple docstring""" return choice(UpperCamelCase ) def _UpperCamelCase ( UpperCamelCase , UpperCa...
77
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fr...
622
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
78
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__ : Optional[Any] = logging.getLogger() def _lowe...
622
0
SCREAMING_SNAKE_CASE__ : Union[str, Any] = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ...
79
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__( lowerCamelCase , unittest.TestCase ): '''simple docstring''' A : int ...
622
0
from manim import * class __UpperCamelCase ( _lowerCAmelCase ): def _a ( self : str ) -> Tuple: """simple docstring""" __lowercase = Rectangle(height=0.5 , width=0.5 ) __lowercase = Rectangle(height=0.46 , width=0.46 ...
80
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 fro...
622
0
import numpy as np _snake_case : str = [ ["a", "b", "c", "d", "e"], ["f", "g", "h", "i", "k"], ["l", "m", "n", "o", "p"], ["q", "r", "s", "t", "u"], ["v", "w", "x", "y", "z"], ] class a : """simple docstring""" def __init__( self : Opti...
81
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
0
"""simple docstring""" import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): UpperCAmelCase_ = f"""{sampling_rate}""" UpperCAmelCase_ = ...
82
def _lowerCAmelCase ( A__ = 600_851_475_143 ): try: lowercase__ = int(A__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater than or equa...
622
0
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) lowerCAmelCase__ = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_p...
83
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ = None ): lowercase__ = word_bank or [] # create a table lowercase__ = len(A__ ) + 1 lowercase__ = [] for _ in range(A__ ): table.append([] ) # seed value lowercas...
622
0
from __future__ import annotations import collections import pprint from pathlib import Path def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): return "".join(sorted(__SCREAMING_SNAKE_CASE ) ) def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): return word_by_signature[signa...
84
a__ : Tuple = "Tobias Carryer" from time import time class UpperCAmelCase__: '''simple docstring''' def __init__( self : str , lowerCAmelCase : List[str] , lowerCAmelCase : Any , lowerCAmelCase : str , lowerCAmelCase : ...
622
0
import os SCREAMING_SNAKE_CASE__ : Any = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} def _a ( lowercase__ : str ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[int] = 0 SCREAMING_SNAKE_CASE__ ...
85
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any] , *l...
622
0
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __snake_case ( __UpperCamelCase : Tuple ,__UpperCamelCase : Dict ,__UpperC...
86
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_IMA...
622
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...
87
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
622
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, re...
88
from math import sqrt def _lowerCAmelCase ( A__ ): assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase__ = True # 0 and 1 are none primes. if number <= 1: lowercase__ = False for diviso...
622
0
import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE : str = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" SCREAMING_SNAKE_CASE : Dict = "\nArgs:\n ...
89
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
90
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
622
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''], } try: if not is_t...
91
def _lowerCAmelCase ( A__ = 50_000_000 ): lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): ...
622
0
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from trans...
92
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...util...
622
0
"""simple docstring""" from __future__ import annotations import pandas as pd def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->list[int]: """simple docstring""" lowerCAmelCase__ :int = [0] * no_of_processes lowerCAmelCase__ :i...
93
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=__A ): """simple docstring""" UpperCamelCase_ = ['''flax'''] def __init__( self : Dict , *UpperCAmelCase : List[Any] , ...
94
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
622
0
"""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 snake_case ( A_...
95
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
"""simple docstring""" def a ( __UpperCAmelCase : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __magic_name__: Optional[Any] = sorted(string...
96
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase__( lowerCamelCase , un...
622
0
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.pipelines.alt_diffusion.modeling_roberta_series i...
97
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowerCAmelCase ( u...
98
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
0
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, ...
99
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fr...
622
0