code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
import qiskit def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' lowercase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register lowercase = qiskit.QuantumCircuit(lowerCAmelCas...
101
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
0
"""simple docstring""" from PIL import Image def lowercase ( _snake_case : Image ) ->Image: """simple docstring""" __snake_case , __snake_case : Any = image.size __snake_case : Dict = 0 __snake_case : Tuple = image.load() for ...
102
# 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 ...
342
0
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 transformers....
103
import math class snake_case__ : def __init__( self , lowerCAmelCase__=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 __magic_name__ : Tuple = n __magic_name__ : Union[str, Any] = [ [math.inf for j in range(0 , ...
342
0
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py lowerCAmelCase__ = '''.''' if __name__ == "__main__": lowerCAmelCase__ = os.path.join(REPO_PATH, '''utils/docum...
104
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__ : def __init__( self , lowerCAmelCase__ = None ) -> None: if components is None: __magic_name__ : Any ...
342
0
"""simple docstring""" import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_...
105
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__: str = logging.get_logger(__name__) __magic_name__: ...
342
0
"""simple docstring""" 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_image_inputs if is_torch_a...
106
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A, _A, _A ): """simple docstring""" __magic_...
342
0
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, U...
107
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
342
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : List[str] = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase : Optional[int] = [[False...
108
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def SCREAMING_SNAKE_CASE ( self ) -> Any: '''simple docstring''' UpperCAmelCase : List[str] = ...
109
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import...
346
from math import factorial def UpperCamelCase ( _A, _A, _A ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if trials < 0 or successes < 0: raise ValueError("""the func...
342
0
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 lowercase ( _lowerCAmelCase ): __SCREAMING_SNAKE_CAS...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
from PIL import Image def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> Tuple: def brightness(SCREAMING_SNAKE_CASE_ ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError('level must be bet...
212
import argparse import os import re __magic_name__: Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __magic_name__: Any = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-...
342
0
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase__ ( _lo...
216
__magic_name__: str = [0, 2, 4, 6, 8] __magic_name__: Optional[int] = [1, 3, 5, 7, 9] def UpperCamelCase ( _A, _A, _A, _A ): """simple docstring""" if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: r...
342
0
"""simple docstring""" from datetime import datetime import matplotlib.pyplot as plt import torch def _SCREAMING_SNAKE_CASE ( __snake_case : Tuple ): '''simple docstring''' for param in module.parameters(): lowercase = False def _SCREAMING_SNAKE_CASE ( ...
220
def UpperCamelCase ( _A ): """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __magic_name__ : int = sorted(string.lower() ) return len(_A ) == l...
342
0
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
100
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
342
0
import warnings from .generation import TFGenerationMixin class A( _lowerCAmelCase ): '''simple docstring''' warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ''' '''be removed in Transform...
204
import unittest from typing import Dict, List, Optional, Union 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_imag...
342
0
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokenizers A...
207
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__: Tuple = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], ...
342
0
def __lowercase ( _A ) -> str: SCREAMING_SNAKE_CASE : int = 0 for ch in input_str: SCREAMING_SNAKE_CASE : Any = ord(_A ) SCREAMING_SNAKE_CASE : List[str] = pow(2 , _A ) # If we al...
245
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__: Dict = logging.get_logger(__name__) __magic_name__: List[Any] ...
342
0
"""simple docstring""" from math import factorial def _SCREAMING_SNAKE_CASE ( _lowercase : List[str] , _lowercase : Tuple , _lowercase : List[str] ) ->str: '''simple docstring''' if successes > trials: ...
105
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbone...
342
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decision-transformer-gym-hoppe...
309
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
342
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : Optional[Any] ): '''simple docstring''' if not isinstance(_A , _A ): UpperCAmelCase__ = F'''Input value of [number={number}] must be an integer''' raise TypeError(_A ) if number < 0: return F...
346
def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = [0] * len(_A ) __magic_name__ : List[str] = [] __magic_name__ : List[str] = [1] * len(_A ) for values in graph.values(): ...
342
0
from __future__ import annotations _UpperCAmelCase : Union[str, Any] = [] def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' for i in range(len(_A ) ): if board[row...
285
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 snake_case__ ( unittest.TestCase ): def __magic_name__ ( self ) ...
342
0
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> List[str]: if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) lowerCAmelCase__ : int = sorted(string.lower() ) return len(_A )...
212
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ="▁" lowercase__ ...
216
# 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 ...
342
0
"""simple docstring""" # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format...
220
import math class snake_case__ : def __init__( self , lowerCAmelCase__=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 __magic_name__ : Tuple = n __magic_name__ : Union[str, Any] = [ [math.inf for j in range(0 , ...
342
0
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME __magic_name__ = ["small", "medium", "large"] __magic_name__ = "lm_head.decoder.weight" __magic_name__ = "lm_head.weight" def _lowerCAmelCase ( UpperCamelCase_ , ...
100
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__ : def __init__( self , lowerCAmelCase__ = None ) -> None: if components is None: __magic_name__ : Any ...
342
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : str = logging.get_logger(__name__) lowerCamelCase : Dict = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class A( _lowerCAmelCase ): ...
204
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__: str = logging.get_logger(__name__) __magic_name__: ...
342
0
import datasets from .evaluate import evaluate A__ : Tuple = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016}\n}\n" ...
207
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A, _A, _A ): """simple docstring""" __magic_...
342
0
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...tes...
245
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
342
0
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( _lowerCAmelCase ): lowerCamelCase : Optional[Any] =(UnCLIPScheduler,) def ...
105
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
'''simple docstring''' import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_prop...
309
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
'''simple docstring''' import random def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : List[Any] = False ): '''simple docstring''' UpperCAmelCase__ = {i: [] for i in range(_A )} # if probability is...
346
from math import factorial def UpperCamelCase ( _A, _A, _A ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if trials < 0 or successes < 0: raise ValueError("""the func...
342
0
import os def __lowerCamelCase ( ): '''simple docstring''' with open(os.path.dirname(_A ) + '/p022_names.txt' ) as file: snake_case_ = str(file.readlines()[0] ) snake_case_ = names.replace('\"' , '' ).split(...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> Any: assert isinstance(_A , _A ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: lowerCAmelCase__ : str = F'''The input value of [n={number}]...
212
import argparse import os import re __magic_name__: Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __magic_name__: Any = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-...
342
0
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import ...
216
__magic_name__: str = [0, 2, 4, 6, 8] __magic_name__: Optional[int] = [1, 3, 5, 7, 9] def UpperCamelCase ( _A, _A, _A, _A ): """simple docstring""" if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: r...
342
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase : Tuple = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", ...
220
def UpperCamelCase ( _A ): """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __magic_name__ : int = sorted(string.lower() ) return len(_A ) == l...
342
0
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class ...
100
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
342
0
import unittest import numpy as np from transformers import DistilBertConfig, 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 a...
204
import unittest from typing import Dict, List, Optional, Union 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_imag...
342
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A__ : List[str] = logging.get_logger(__name__) A__ : Optional[int] = { "xlm-roberta-base": "https://huggingface.co/x...
207
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__: Tuple = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], ...
342
0
from __future__ import annotations from random import choice def __lowercase ( _A ) -> List[str]: return choice(_A ) def __lowercase ( _A , _A ) -> int: SCREAMING_SNAKE_CASE : int = random_pivot(_A ) # partition b...
245
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__: Dict = logging.get_logger(__name__) __magic_name__: List[Any] ...
342
0
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( _lowercase : Optional[Any] ) ->Optional[int]: '''simple docstring''' a : Union[str, Any] = 0.00 a : List[str] = 0 for resistor in r...
105
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbone...
342
0
'''simple docstring''' import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_staging_...
309
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
342
0
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_...
346
def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = [0] * len(_A ) __magic_name__ : List[str] = [] __magic_name__ : List[str] = [1] * len(_A ) for values in graph.values(): ...
342
0
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, r...
285
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 snake_case__ ( unittest.TestCase ): def __magic_name__ ( self ) ...
342
0
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "post_extract_proj": "feature_proj...
212
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
0
from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=_lowerCAmelCase ): _SCREAMING_SNAKE_CASE : Any = ['''sentencepiece'''] def __init__(self : List[str] , *snake_case_ : Optional[Any] , **snake_case_ : str ): ...
216
# 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 ...
342
0
"""simple docstring""" from __future__ import annotations class a : def __init__( self , _lowerCamelCase = 0 ): lowercase = key def UpperCamelCase_ ( self , _lowerCamelCase , _lowerCamelCase ): assert is...
220
import math class snake_case__ : def __init__( self , lowerCAmelCase__=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 __magic_name__ : Tuple = n __magic_name__ : Union[str, Any] = [ [math.inf for j in range(0 , ...
342
0
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 10**9 ): __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 while perimeter <= max_p...
100
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__ : def __init__( self , lowerCAmelCase__ = None ) -> None: if components is None: __magic_name__ : Any ...
342
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase : Any = logging.get_logger(__name__) lowerCamelCase : int ...
204
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__: str = logging.get_logger(__name__) __magic_name__: ...
342
0
import argparse import os import re A__ : Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict A__ : Any = re.compile(r'[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict') ...
207
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A, _A, _A ): """simple docstring""" __magic_...
342
0
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin fr...
245
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
342
0
"""simple docstring""" import math import os import sys def _SCREAMING_SNAKE_CASE ( _lowercase : Any ) ->Dict: '''simple docstring''' a : Dict = """""" try: with open(_A , "rb" ) as binary_file: a : T...
105
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
'''simple docstring''' class a_ : def __init__( self , snake_case_ = "" , snake_case_ = False ): # Mapping from the first character of the prefix of the node _lowerCAmelCase : dict[str, RadixNode] = {} # A node will be a leaf if...
309
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor UpperCAmelCase_ = logging.get_logger(__name__) class lowerCAmelCase_ ( _lowerCAmelCase ): '''simple docstring''' def __i...
346
from math import factorial def UpperCamelCase ( _A, _A, _A ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if trials < 0 or successes < 0: raise ValueError("""the func...
342
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' ...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
class A__ : def __init__( self : Tuple ): '''simple docstring''' lowerCAmelCase__ : Optional[Any] = {} def _lowerCamelCase ( self : List[str] ): '''simp...
212
import argparse import os import re __magic_name__: Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __magic_name__: Any = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-...
342
0
import flax.linen as nn import jax import jax.numpy as jnp class UpperCamelCase__ ( nn.Module ): _SCREAMING_SNAKE_CASE : int _SCREAMING_SNAKE_CASE : jnp.dtype = jnp.floataa def lowerCAmelCase (self : Optional[int] ): __a : Optional[int] ...
216
__magic_name__: str = [0, 2, 4, 6, 8] __magic_name__: Optional[int] = [1, 3, 5, 7, 9] def UpperCamelCase ( _A, _A, _A, _A ): """simple docstring""" if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: r...
342
0
"""simple docstring""" # 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/LICENS...
220
def UpperCamelCase ( _A ): """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __magic_name__ : int = sorted(string.lower() ) return len(_A ) == l...
342
0
"""simple docstring""" import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrateg...
100
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
342
0
# 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 TensorFormatter ...
204
import unittest from typing import Dict, List, Optional, Union 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_imag...
342
0
import doctest from collections import deque import numpy as np class _UpperCAmelCase : """simple docstring""" def __init__( self : Dict ): '''simple docstring''' lowercase__ = [2, 1, 2, -1] lowercase__ = [1, 2, 3, 4] def lowerca...
207
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__: Tuple = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], ...
342
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def __lowercase ( _A , _A , _A ) -> List[str]: SCREAMING_SNAKE_CASE : Tuple = Al...
245
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__: Dict = logging.get_logger(__name__) __magic_name__: List[Any] ...
342
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegme...
105
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbone...
342
0
'''simple docstring''' import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging UpperCamelC...
309
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
342
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrajectoryTransform...
346
def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = [0] * len(_A ) __magic_name__ : List[str] = [] __magic_name__ : List[str] = [1] * len(_A ) for values in graph.values(): ...
342
0
import numpy as np import datasets _UpperCAmelCase : List[Any] = "\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was int...
285
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 snake_case__ ( unittest.TestCase ): def __magic_name__ ( self ) ...
342
0
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientSt...
212
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
0
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 UpperCamelCase__ ( _lowerCAmelCase ): ...
216
# 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 ...
342
0
"""simple docstring""" from __future__ import annotations import math _UpperCamelCase : str = "2020.9.26" _UpperCamelCase : Any = "xcodz-dot, cclaus, dhruvmanila" def _SCREAMING_SNAKE_CASE ( __snake_case : Optional[Any] , __snake_case : Tuple , __snake_case : int ...
220
import math class snake_case__ : def __init__( self , lowerCAmelCase__=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 __magic_name__ : Tuple = n __magic_name__ : Union[str, Any] = [ [math.inf for j in range(0 , ...
342
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 __magic_name__ = False class SCREAMING_SNAKE_CASE_ ( ...
100
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__ : def __init__( self , lowerCAmelCase__ = None ) -> None: if components is None: __magic_name__ : Any ...
342
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A( _lowerCAmelCase ): '''simple docstring''' UpperCamelCase = ['''image_processor''', '''tokenizer'''] UpperCamelCase = '''AutoImageProce...
204
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__: str = logging.get_logger(__name__) __magic_name__: ...
342
0
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A__ : Any = get_logger(__name__) A__ : Union[str, Any] = r"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_leng...
207
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A, _A, _A ): """simple docstring""" __magic_...
342
0
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets UpperCAmelCase__ : List[Any] = "\\n@inproceedings{popovic-2015-chrf,\n title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",\n author = \"Popovi{\'c}, Maja\",\n bo...
245
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
342
0
"""simple docstring""" import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset fro...
105
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
'''simple docstring''' import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""" )
309
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class lowerCAmelCase_ : '''simple docstring''' lowerCAmelCase_ : int lowerCAmelCase_ :...
346
from math import factorial def UpperCamelCase ( _A, _A, _A ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if trials < 0 or successes < 0: raise ValueError("""the func...
342
0
import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCAmelCase : Optional[int] = loggi...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...t...
212
import argparse import os import re __magic_name__: Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __magic_name__: Any = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-...
342
0
import os import re import shutil import sys import tempfile import unittest import black lowercase__ =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies # noqa: E402 # This is the reference code that will ...
216
__magic_name__: str = [0, 2, 4, 6, 8] __magic_name__: Optional[int] = [1, 3, 5, 7, 9] def UpperCamelCase ( _A, _A, _A, _A ): """simple docstring""" if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: r...
342
0
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_a...
220
def UpperCamelCase ( _A ): """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __magic_name__ : int = sorted(string.lower() ) return len(_A ) == l...
342
0
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_imag...
100
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
342
0
def _SCREAMING_SNAKE_CASE ( lowercase : Optional[int] ): '''simple docstring''' lowerCamelCase_ = [1] lowerCamelCase_ = 0, 0, 0 lowerCamelCase_ = ugly_nums[ia] * 2 lowerCamelCase_ = ugly_nums[ia] * 3 ...
204
import unittest from typing import Dict, List, Optional, Union 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_imag...
342
0
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A__ : Tuple = logging.get_logger(__name__) A__ : Any = { "vocab_file": "vocab.json", "tokenizer_config_file": "tokenizer_config.json",...
207
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__: Tuple = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], ...
342
0
from __future__ import annotations def __lowercase ( _A , _A , _A ) -> Optional[int]: if days_between_payments <= 0: raise ValueError("""days_between_payments must be > 0""" ) if daily_interest_rate < 0: raise ValueError("""daily_...
245
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__: Dict = logging.get_logger(__name__) __magic_name__: List[Any] ...
342
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a : int = { "configuration_whisper":...
105
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbone...
342
0
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision...
309
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
342
0
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
346
def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = [0] * len(_A ) __magic_name__ : List[str] = [] __magic_name__ : List[str] = [1] * len(_A ) for values in graph.values(): ...
342
0
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) _UpperCAmelCase : Union[str, Any] = logging.getLogger(...
285
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 snake_case__ ( unittest.TestCase ): def __magic_name__ ( self ) ...
342
0
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils impor...
212
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ "facebook/data2vec-vision-base-ft": ...
216
# 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 ...
342
0
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
220
import math class snake_case__ : def __init__( self , lowerCAmelCase__=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 __magic_name__ : Tuple = n __magic_name__ : Union[str, Any] = [ [math.inf for j in range(0 , ...
342
0
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import Threa...
100
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__ : def __init__( self , lowerCAmelCase__ = None ) -> None: if components is None: __magic_name__ : Any ...
342
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokeni...
204
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__: str = logging.get_logger(__name__) __magic_name__: ...
342
0
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 # # ...
207
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A, _A, _A ): """simple docstring""" __magic_...
342
0
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, require_flax, require_tf, require_to...
245
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
342
0
"""simple docstring""" import copy import re class __UpperCamelCase : lowerCamelCase : Optional[int] ='''hp''' lowerCamelCase : Any ={} lowerCamelCase : Any =None @classmethod def ...
105
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
'''simple docstring''' import numpy as np import qiskit def _UpperCAmelCase ( _lowerCamelCase : List[str] = 8 , _lowerCamelCase : Dict = None ) -> Tuple: _lowerCAmelCase : str = np.random.default_rng(seed=_A ) # Roughly 25% of the qubits will contribute to the...
309
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _UpperCamelCase ( ): '''simple docstring''' UpperCAmelCase__ = ArgumentParser( description=( ...
346
from math import factorial def UpperCamelCase ( _A, _A, _A ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if trials < 0 or successes < 0: raise ValueError("""the func...
342
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nice ...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.i...
212
import argparse import os import re __magic_name__: Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __magic_name__: Any = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-...
342
0