code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import...
271
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil _a : Optional[Any] = 100 _a : Dict = set(range(3, NUM_PRIMES, 2)) primes.add(2) _a : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not i...
56
0
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class SCREAMING_SNAKE_CASE ( snake_case , snake_case ): """s...
62
__A = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __A = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def __A ( _lowercase , _lowercase , _lowercase ): '''simple docstring''' _A = True _A = [] for neighbour in graph[...
62
1
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def lowerCAmelCase (__A): "...
11
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) a_ = { 'configuration_speecht5': [ 'SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIV...
417
0
'''simple docstring''' def a ( UpperCamelCase_ : int ) -> int: if n == 1 or not isinstance(UpperCamelCase_ , UpperCamelCase_ ): return 0 elif n == 2: return 1 else: snake_case__ =[0, 1] for i in range(2 , n + 1 ): sequence.append(sequence[i - ...
581
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def a ( ) ...
581
1
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _lowerCAmelCase : def __init__( self , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> str: '''simple docstring''' if d...
178
'''simple docstring''' from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def _lowerCAmelCase ( lowercase ) -> Optional[int]: if not is_accelerate_available(): return method __lowerCAmelCase =...
689
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() e...
266
'''simple docstring''' import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class a : """simple docstring""" def __init__( self : Union[str, Any] , snake_case : List[Any] , snake_case : int , snake_cas...
266
1
def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = 0 _lowercase : Any = len(lowerCamelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , lowerCamelCase_ ): if arr[i] > arr[j]: ...
89
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailable() ex...
112
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_environm...
711
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root ...
516
0
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .schedu...
688
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSc...
688
1
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils impo...
721
from __future__ import annotations def lowerCAmelCase_ ( __UpperCAmelCase: str , __UpperCAmelCase: str ) -> bool: UpperCamelCase__ : List[str] = get_failure_array(__UpperCAmelCase ) # 2) Step through text searching for pattern UpperCam...
369
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simpl...
215
'''simple docstring''' import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": __snake_case : str = pd.read_csv('sample_data.csv', header=None) ...
215
1
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 _a ( unittest.TestCase ): """simple docstring""" def SCREAMING_SNAK...
592
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_dataset" )} ), Spli...
592
1
'''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.or...
8
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified...
661
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def A ( _lowercase ): SCREAMING_SNAKE_CASE : Optional[Any] ...
705
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import Bit...
34
0
import math import tensorflow as tf from packaging import version def UpperCamelCase__( UpperCamelCase__ : Optional[int] )->int: A__ = tf.convert_to_tensor(UpperCamelCase__ ) A__ = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype )...
190
import itertools import math def UpperCamelCase__( UpperCamelCase__ : int )->bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numb...
190
1
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_...
720
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : Sequence[float] , _lowerCamelCase : int , _lowerCamelCase : int) ...
94
0
"""simple docstring""" import sys 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: # - tqd...
83
"""simple docstring""" import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn ...
552
0
def A__ ( lowercase: list, lowercase: list, lowercase: int, lowercase: int, lowercase: int ) -> int: if index == number_of_items: return 0 A : Any =0 A : Optional[Any] =0 A : Dict =knapsa...
661
from typing import List from .keymap import KEYMAP, get_character def A__ ( lowercase: str ) -> List[str]: def decorator(lowercase: int ): A : Tuple =getattr(lowercase, 'handle_key', [] ) handle += [key] setat...
661
1
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): i...
59
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensi...
3
0
'''simple docstring''' def _lowerCamelCase (__lowerCamelCase : int = 100 ) -> int: a__ = set() a__ = 0 a__ = n + 1 # maximum limit for a in range(2 , __lowerCamelCase ): for b in range(2 , __lowerCamelCase ): a__ ...
289
'''simple docstring''' import argparse import os import re import packaging.version lowerCAmelCase_ : Optional[int] = "examples/" lowerCAmelCase_ : Optional[int] = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_ve...
289
1
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase_ = 4 lowerCamelCase_ = 3 class __a ( snake_case__ ): """simple docstring"""...
151
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class lowerCAmelCase_ ( snake_case__ ): """simple docstring""" def __init__( self : List[Any] ): '''simple docstring''' self.test() def __a ( se...
582
0
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class UpperCamelCase_ ( unittest.TestCa...
413
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCamelCase_ ( unittest.TestCase ): '''simple docstring''' def lowercase__ (...
413
1
'''simple docstring''' import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class A ( _a ): def __init__( self : Union[str, Any] , low...
22
def _lowercase ( __SCREAMING_SNAKE_CASE ) -> str: return " ".join( ''.join(word[::-1] ) if len(__SCREAMING_SNAKE_CASE ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('''Hey wol...
410
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 ...test_...
103
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, req...
103
1
'''simple docstring''' from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig,...
78
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): A_ : Tuple = 1 A_ : str = 2 while i * i <= n: A_ : Optional[Any] = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors...
708
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", """BigBirdPega...
152
0
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _lowerCamelCase : Dict = ge...
686
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 ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _lowerCame...
686
1
'''simple docstring''' import operator as op def snake_case__ ( _A: Optional[Any] ) -> Tuple: '''simple docstring''' lowerCAmelCase = [] lowerCAmelCase = lambda _A , _A : int(x / y ) # noqa: E731 integer division operation low...
605
'''simple docstring''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class a__( lowerCAmelCase__ ): '''simple docstring''' ...
605
1
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate depr...
60
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 from ..image_utils import...
219
0
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase ( lowercase_ , ...
271
'''simple docstring''' 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 : Union[str, Any] = logging.get_logger(__name__) _...
271
1
import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class a ( unittest.TestCase ): '''simple d...
144
# using dfs for finding eulerian path traversal def SCREAMING_SNAKE_CASE ( __UpperCamelCase : List[Any] , __UpperCamelCase : int , __UpperCamelCase : List[str] , __UpperCamelCase : List[str]=None ) -> Optional[Any]: UpperCAmelCase_ = (path or [])...
144
1
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( A__ , A__ , A__ ): # Initialise PyTorch model lowercase__ = RemBertConfig...
642
import math import sys def _lowerCAmelCase ( A__ ): lowercase__ = '' try: with open(A__ , 'rb' ) as binary_file: lowercase__ = binary_file.read() for dat in data: lowercase__ = F'''{dat:08b}''' r...
642
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : Any ={ "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } try: if not is_t...
364
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def _a ( lowercase__ : int = 3 ): '''simple docstring''' if isinstance(lowercase__ , lowercase__ ): raise TypeError('number of qubits...
85
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils impor...
707
'''simple docstring''' from collections.abc import Generator from math import sin def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" if len(__SCREAMING_SNAKE_CASE ) != 32: raise ValueError('''Input must be of length 32''' ) _UpperCamelCase =b'''''' for i in [3, ...
271
0
def lowerCAmelCase_ ( A_): UpperCamelCase__: List[Any] = [0] * len(A_) UpperCamelCase__: Any = [] UpperCamelCase__: str = [] UpperCamelCase__: Any = 0 for values in graph.values(): for i in values: indegree[i] += 1 ...
380
import math def lowerCAmelCase_ ( A_ ,A_): UpperCamelCase__: Dict = len(A_) UpperCamelCase__: Optional[Any] = int(math.floor(math.sqrt(A_))) UpperCamelCase__: Union[str, Any] = 0 while arr[min(A_ ,A_) - 1] < x: UpperCamelCase__: Any...
380
1
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> bool: if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE_ : Optional[Any] = f'Input value of [number={number}] must be an integer' raise TypeError(SCREAMING_SNAKE_CASE ) if numbe...
311
from string import ascii_lowercase, ascii_uppercase def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> str: if not sentence: return "" SCREAMING_SNAKE_CASE_ : int = dict(zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ) return lower_to_upper.get(sentence[0]...
311
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass A_ = (3, 9, -11, 0, 7, 5, 1, -1) A_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __lowerCamelCase : a__: int a__: Node | No...
29
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data...
677
0
from random import shuffle import tensorflow as tf from numpy import array def _lowerCAmelCase ( __lowerCamelCase : Optional[int] , __lowerCamelCase : Optional[Any] ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[Any] = int(__lowerCamelCase )...
447
from collections.abc import Generator from math import sin def _lowerCAmelCase ( __lowerCamelCase : bytes ): """simple docstring""" if len(__lowerCamelCase ) != 32: raise ValueError("Input must be of length 32" ) __SCREAMING_SNAKE_CASE : Union[str, Any] ...
447
1
'''simple docstring''' from typing import List import numpy as np def A__ ( UpperCAmelCase_ ): _UpperCamelCase : Any = {key: len(UpperCAmelCase_ ) for key, value in gen_kwargs.items() if isinstance(UpperCAmelCase_ , UpperCAmelCase_ )} if len(set(lists_lengt...
195
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case_ : Tuple = { 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_CON...
195
1
'''simple docstring''' from itertools import product def SCREAMING_SNAKE_CASE__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): lowerCAmelCase_ : Tuple =sides_number lowerCAmelCase_ : Tuple =max_face_number * dice_number lowerCAmelCa...
305
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json''', } clas...
305
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : List[str] = { '''configuration_clap''': [ '''CLAP_PRETRAINED_MODEL_ARCHIVE_LIST''', '''ClapAudioConfig''', '...
543
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __SCREAMING_SNAKE_CASE : Optional[int] = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translatio...
661
0
'''simple docstring''' import os from collections.abc import Iterator def _lowerCAmelCase( UpperCAmelCase_ : str = "." ) -> Iterator[str]: for dir_path, dir_names, filenames in os.walk(_lowerCamelCase ): lowerCAmelCase__ = [d for d in dir_...
706
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase( UpperCAmelCase_ : List[Any] ) -> List[str]: lowerCAmelCase__ = ...
211
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, xsplitext from ..table ...
24
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES a = logging.get_logger(__name__) a = OrderedDict( [ # Ba...
518
0
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMaskedLM, DistilBer...
704
lowerCamelCase_ = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def __magic_name__ ( __a : int ): '''simple docstring''' UpperCamelCase__ = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum...
86
0
from ..utils import DummyObject, requires_backends class __a( metaclass=_a ): """simple docstring""" lowerCAmelCase = ['''flax''', '''transformers'''] def __init__( self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE ) -> List[Any]: requires_backen...
30
from math import pow, sqrt def snake_case (*__lowercase ) -> bool: '''simple docstring''' _snake_case : str = len(__lowercase ) > 0 and all(value > 0.0 for value in values ) return result def snake_case (__lowercase , __lowercase ) -> float | ValueError: ...
670
0
"""simple docstring""" import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation im...
710
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __a ( A , A , A = "x" , A = 10**-10 , A = 1 , ): '''simple docstring''' lowercase__ = symbols(A ) lowercase__ = ...
668
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging logg...
106
"""simple docstring""" from math import factorial UpperCAmelCase : Tuple = {str(d): factorial(d) for d in range(10)} def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(__lowerCAmelCa...
567
0
'''simple docstring''' def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> Optional[int]: if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__UpperCamelCase ,n - 1 ,__UpperCamelCase ) * a) % mod els...
384
'''simple docstring''' import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tr...
384
1
def __a ( A__ : int ): if not isinstance(A__ , A__ ): SCREAMING_SNAKE_CASE = F"Input value of [number={number}] must be an integer" raise TypeError(A__ ) if number < 0: return False SCREAMING_SNAKE_CASE = number * numb...
16
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase ( a_ ): """simple docstring""" A__ : str = ['image_processor', 'tokenizer'] A__ : Dict = 'CLIPImageProcessor...
683
0
from __future__ import annotations class __a : def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ ) -> Optional[Any]: '''simple docstring''' lowercase__ , lowercase__: Dict = text, pattern lower...
335
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, loggi...
335
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase__ : Union[str, Any] = { "configuration_conditional_detr": [ "CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
48
from collections.abc import Sequence def __lowerCAmelCase ( _UpperCamelCase : Sequence[int] | None = None ) -> int: '''simple docstring''' if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) SCREAMING_SNAKE_CASE = nums[0] for i in r...
439
0
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescal...
710
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
506
0
'''simple docstring''' def lowerCAmelCase (__A = 4_000_000): """simple docstring""" _a = [] _a , _a = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__A) _a , _a = b, a + b return s...
11
"""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, i...
572
0
"""simple docstring""" import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers imp...
237
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar lowerCamelCase : Tuple =TypeVar('''KT''') lowerCamelCase : Dict =TypeVar('''VT''') class __snake_case( Generic[KT, VT] ): ...
237
1
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) _lowerCamelCase = pytest.mark.integration @pytest.mark.parametrize("""path""" , ["""paw...
6
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
632
0
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_tensor if i...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Optional[Any] = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', ...
94
0
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCamelCase__ ( A__ ): __lowerCamelCase...
306
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLFor...
306
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch ...
410
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer...
410
1
import qiskit def __SCREAMING_SNAKE_CASE ( a__ : int = 2 ) -> Optional[int]: __A : str = qubits # Using Aer's simulator __A : List[Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Creating a Quantum Circuit acting on the q register __A : Tuple ...
17
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } tr...
3
0
from graphs.minimum_spanning_tree_kruskal import kruskal def _A ( ): a__ : Optional[Any] = 9 a__ : Dict = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], [2, 3, 7], [2, 5...
629
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Any = {"""configuration_sew""": ["""SEW_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SEWConfig"""]} try: if not is_torch_available(): raise Optional...
629
1
_lowerCAmelCase : List[Any] = ''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/h...
454
from math import sqrt def __snake_case ( _lowerCAmelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes retur...
454
1
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tenso...
713
def __snake_case ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> bool: return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(_UpperCamelCase ) ) def __snake_case ( _UpperCamelCase , _UpperCamelCase ...
346
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'robert...
523
'''simple docstring''' class a : """simple docstring""" def __init__( self , snake_case_ , snake_case_ , snake_case_ ): '''simple docstring''' __UpperCAmelCase: List[Any] = None __UpperCAmelCase: Tuple = None __UpperCAmelCase: L...
523
1
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
633
import logging from transformers import PretrainedConfig lowercase__ :int = logging.getLogger(__name__) lowercase__ :Dict = { "bertabs-finetuned-cnndm": "https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json", } class...
633
1
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a : def __init__( self : Optional[int] ) -> str: lowerCamelCase_ = '' lowerCamelCase_ = '' ...
549
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the datas...
549
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @d...
600
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase: str = logging.get_logger(__name__) UpperCAmelCase: Optional[Any] = { """facebook/wav2vec2-base-960h""": """https://huggi...
600
1
"""simple docstring""" from __future__ import annotations def lowercase ( lowerCAmelCase__ ): lowerCamelCase_ = str(lowerCAmelCase__ ) return n == n[::-1] def lowercase ( lowerCAmelCase__ = 1_000_000 ): lowerCamelCase_ = 0 for i in range(1 ,lowerCAmelCase...
29
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _lowerCamelCase ( UpperCamelCase_ ): """simple docstring"...
285
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase : str = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if n...
714
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin...
316
0
"""simple docstring""" import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowerCAmelCase__ = '''src/transformers''' # This is to make sure...
83
def lowerCamelCase_ ( UpperCamelCase_ , UpperCamelCase_ ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _a : str = str(bin(UpperCamelCase_ ) )[2:] # remove the leading "0b" _a : Dict = ...
471
0
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 from .tokenization_gpta import GPTaTokenizer ...
717
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
116
0
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _lowerCAmelCase = False try: _lowerCAmelCase = _is_...
569
import os from math import logaa def _lowerCAmelCase ( _lowerCAmelCase = "base_exp.txt" ): '''simple docstring''' A_ : float = 0 A_ : int = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_lowerCAmelCase ) ,_lowerCAmelCase ) ) ): A...
569
1
"""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_bert import BertTokenizer a = logging.get_logger(__name__) a = ...
716
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from a...
529
0
import math import sys def lowerCamelCase__ ( _lowercase ): '''simple docstring''' UpperCAmelCase_ : List[str] = '''''' try: with open(_lowercase , '''rb''' ) as binary_file: UpperCAmelCase_ : Dict = binary_file.read() fo...
30
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase ( unittest.TestCase ): ...
119
0
def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ) -> int: """simple docstring""" if len(snake_case__ ) != len(snake_case__ ): raise ValueError("""The length of profit and weight must be same.""" ) if max_weight <= 0: ...
569
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer im...
569
1
'''simple docstring''' import unittest import numpy as np import requests 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_input...
24
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.t...
655
0
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) SCREAMING_SNAKE_CASE_ = pytest.mark.integration @pytest.mark.parametrize("path", ["paws", "csv"] ) def ...
709
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_toke...
370
0
'''simple docstring''' import math def _SCREAMING_SNAKE_CASE ( __snake_case : int ): _A = [] _A = 2 _A = int(math.sqrt(__snake_case ) ) # Size of every segment _A = [True] * (end + 1) _A = [] while start <= end: i...
107
'''simple docstring''' def a_ ( lowerCamelCase : Optional[Any] ): stooge(lowerCamelCase , 0 , len(lowerCamelCase ) - 1 ) return arr def a_ ( lowerCamelCase : Optional[int] , lowerCamelCase : Union[str, ...
133
0
'''simple docstring''' import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def lo...
706
'''simple docstring''' import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() lowercase =logging.get_logger(__name__) lowercase ={ 'post_extract_proj': 'feature_projection...
331
0
"""simple docstring""" def _A (__a , __a , __a = 0 , __a = 0 ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = right or len(__a ) - 1 if left > right: return -1 elif list_data[left]...
512
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelFo...
512
1
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class...
713
"""simple docstring""" from manim import * class __a ( lowerCAmelCase__ ): def snake_case_ ( self ): _lowerCamelCase = Rectangle(height=0.5 , width=0.5 ) _lowerCamelCase = Rectangle(height=0.46 , width=0.46 )...
222
0
from collections import defaultdict from math import gcd def A_ ( _UpperCAmelCase = 1_50_00_00 ): SCREAMING_SNAKE_CASE_: defaultdict = defaultdict(_UpperCAmelCase ) SCREAMING_SNAKE_CASE_: Any = 2 while 2 * euclid_m * (euclid_m + 1) <= limit...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampli...
671
1
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifie...
710
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _snake_case = { "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LxmertConfig"], ...
413
0
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __a ( _snake_case ...
109
"""simple docstring""" import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation i...
29
0
import numpy as np from PIL import Image def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : np.ndarray , __UpperCamelCase : int , __UpperCamelCase : int ) -> np.ndarray: """simple docstring""" SCREAMING_SNAKE_CASE__ = np.array(...
379
import os __lowerCamelCase : Union[str, Any] = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : str ) -> int: """simple docstring""" SCREAMI...
379
1
from math import ceil, sqrt def lowerCamelCase_ ( __UpperCamelCase = 1_00_00_00 ): A_ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: A_ = max(ceil(sqrt(outer_width**2 - limit ) ) , 1 ) else...
141
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils impor...
141
1
"""simple docstring""" from typing import Any class __UpperCAmelCase : '''simple docstring''' def __init__( self , _A ): '''simple docstring''' _SCREAMING_SNAKE_CASE =data _SCREAMING_SNAKE_CASE =None class __UpperCAmelCase : '''simple docstring''' ...
705
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
165
0
'''simple docstring''' 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: Optional[int] = get_logger(__name__) _A: List[Any] = r""" Args: input_ids (...
126
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCAmelCase ( UpperCAmelCase_ ...
126
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
244
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A__ : Any = logging.get_logger(__name__) A__ : Union[str, Any] = { 'SenseTime/deformable-detr': 'https://hugging...
244
1
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_available(): ...
16
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
612
0
import numpy as np import torch from ..models.clipseg import CLIPSegForImageSegmentation from ..utils import is_vision_available, requires_backends from .base import PipelineTool if is_vision_available(): from PIL import Image class _lowerCamelCase( _a ): lowercase_ : Union[str, Any] ...
713
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class _lowerCamelCase( _a ): @require_torch def UpperCamelCase ( self) -> int: """simple docst...
354
0
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class SCREAMING_SNAKE_CASE_ ( ctypes.Structure ): """simple docstring""" __lowercase : Any ...
155
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __magic_name__ = ...
155
1
"""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_t...
710
"""simple docstring""" import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfAr...
349
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowerCAmelCase_ = { '''configuration_speech_to_text''': ['''SPEECH_TO_TEXT_PRETRA...
60
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowerCAmelCase = (7_2_0, 1_2_8_0) # Height, Width _lowerCAmelCase = (0.4, 0.6) # if height or width lower than this scale, drop ...
161
0
def __UpperCamelCase ( _A : str ) ->list: """simple docstring""" if n_term == "": return [] lowerCamelCase_ =[] for temp in range(int(_A ) ): series.append(f'1/{temp + 1}' if series else """1""" ) return series if...
75
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig __A : int = { 'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/config.json', 'albert-large-v1': 'https://huggingface.co/albert-lar...
75
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A : List[str] = { '''configu...
128
'''simple docstring''' from math import factorial def lowerCAmelCase__ ( lowerCamelCase : int ,lowerCamelCase : int ,lowerCamelCase : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or ...
128
1
'''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...
710
def snake_case (UpperCamelCase : Union[str, Any] ): '''simple docstring''' lowerCamelCase__ = 0 lowerCamelCase__ = len(UpperCamelCase ) for i in range(n - 1 ): for j in range(i + 1 , UpperCamelCase ): if arr[i] > arr[j]: num_invers...
235
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, requ...
21
import string def a__ ( A_ ): '''simple docstring''' __magic_name__ = """""" for i in sequence: __magic_name__ = ord(A_ ) if 65 <= extract <= 90: output += chr(155 - extract ) elif 97 <= extract <= 122: output += chr(219 - ...
529
0
'''simple docstring''' def lowerCAmelCase (__A): """simple docstring""" _a = [0] * len(__A) _a = [] _a = [] _a = 0 for values in graph.values(): for i in values: indegree[i] += 1 ...
705
'''simple docstring''' from __future__ import annotations import math def lowerCAmelCase (__A , __A , __A , __A , __A): """simple docstring""" if depth < 0: raise ValueError('''Depth cannot be less than 0''') if not scores: raise V...
352
0
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging loggi...
455
def lowerCAmelCase ( UpperCamelCase__ : int , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def lowerCAmelCase ( UpperCamelCase__ : float ...
202
0
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _lowercase ( yaml.SafeLoader ): """simple docstring""" def UpperCAmelCase_ ( self : Any , UpperCamelCas...
296
"""simple docstring""" class _lowercase : """simple docstring""" def __init__( self : Tuple , UpperCamelCase__ : Any ) -> int: '''simple docstring''' __UpperCamelCase =arr.split(''',''' ) ...
296
1