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
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class __snake_case ( __SCREAMING_SNAKE_CASE )...
38
'''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 ...
38
1
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils impo...
707
def lowercase_ ( __snake_case : str ) -> list: '''simple docstring''' return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__snake_case ) ) if txt[a].isalpha() ] if __name__ == "__main__": __...
57
0
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _a ( UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ ) -> ...
482
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class A__: def __init__( self : str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE = {} ...
482
1
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 logging.set_verbosity_info...
678
from __future__ import annotations from scipy.special import comb # type: ignore class SCREAMING_SNAKE_CASE_ : """simple docstring""" def __init__( self , A ) -> Tuple: '''simple docstring''' __magic_name__ = list_of_points # Degree det...
678
1
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''si...
55
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : List[Any] = logging.get_l...
509
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Dict = logging.get_logger(__name__) __UpperCamelCase : int = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classicals...
710
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( _lowerCAmelCase ): __snake_case :str = (UnCLIPScheduler,) def _a ( self : Optional[int] , **_lowerCAmelCase : Any ...
53
0
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_util...
80
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast fr...
245
0
'''simple docstring''' 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__ : Tuple = ...
178
'''simple docstring''' UpperCamelCase__ : List[str] = '''0.21.0''' from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) f...
178
1
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow hav...
372
'''simple docstring''' import baseaa def _A ( A ) -> bytes: return baseaa.aaaencode(string.encode("utf-8" ) ) def _A ( A ) -> str: return baseaa.aaadecode(A ).decode("utf-8" ) if __name__ == "__main__": import doctest doctest.testmod(...
372
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVec...
112
"""simple docstring""" import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 _lowerCamelCase = 0b1011_0011_1110_1100_1001_0000_0111_1011_...
112
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils...
180
"""simple docstring""" from __future__ import annotations def __UpperCamelCase ( snake_case__ , snake_case__ ): if len(snake_case__ ) == 0: return False A_ : Union[str, Any] = len(snake_case__ ) // 2 if a_list[midpoint] == item: return True if item < a_li...
180
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ = { """configuration_upernet""": ["""UperNetConfig"""], } try: if not is_torch_available(): raise OptionalDependencyNotAv...
436
import math def __magic_name__ ( lowercase ) -> bool: """simple docstring""" lowercase_ : Optional[Any] = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowercase ...
436
1
def _a ( lowercase__ : int , lowercase__ : int ): '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def _a ( ): '''simple docstring''' assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert ...
85
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig lowercase : int = logging.getLogger(__name__) class _a (a__ ): '''simple docstring''' lowerCAmelCase_ : Union[str, A...
116
0
'''simple docstring''' 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 f...
88
'''simple docstring''' import mpmath # for roots of unity import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self : Union[str, Any] , UpperCAmelCase__ : List[Any]=None , UpperCAmelCase__ : Optional[Any]=None ): '''simple docstring''' ...
88
1
from decimal import Decimal, getcontext from math import ceil, factorial def A ( lowercase__ : int ) -> str: if not isinstance(lowercase__ , lowercase__ ): raise TypeError("""Undefined for non-integers""" ) elif precision < 1: raise ValueError("""Undefined for non-natural numbers""" )...
45
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device UpperCamelCase = False class lowerCAmelCase_ ( unittest.TestCase ...
45
1
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ): '''simple docstring''' if index == r: for j in range(SCREAMING_SNAKE_CASE__ ): ...
693
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _UpperCAmelCase ( ): '''simple docstring''' with offline(O...
693
1
from math import sqrt def UpperCamelCase ( _a ) -> int: '''simple docstring''' lowercase_ :Any = 0 for i in range(1 , int(sqrt(_a ) + 1 ) ): if n % i == 0 and i != sqrt(_a ): total += i + n // i ...
257
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 SCREAMING_SNAKE_CASE : Any = False try: SC...
257
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase = { '''configuration_luke''': ['''LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LukeConfig'''], '''tokenization_luke''': ['''LukeTokenizer'''], } try: if not is_to...
704
import qiskit def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Dict = qiskit.Aer.get_backend('''aer_simulator''' ) __UpperCamelCase :Tuple = qiskit.QuantumCircuit(4 , 2 ) # encode in...
452
0
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import F...
4
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer SCREAMING_SNAKE_CASE_ = logging.get_logger(...
237
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 ...tes...
715
from __future__ import annotations lowerCamelCase_ : List[Any] = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"...
246
0
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller _UpperCAmelCase : List[str] = 3 def snake_case__ ( UpperCamelCase ) -> int: print('''Generating primitive root of p''' ) while True: _Upp...
683
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import ...
670
0
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common imp...
396
"""simple docstring""" def A_ ( __UpperCamelCase : list ): for i in range(len(__UpperCamelCase ) - 1 , 0 , -1 ): lowercase = False for j in range(__UpperCamelCase , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: lowe...
396
1
_lowerCAmelCase: dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.609_344, "knot": 1.852, } _lowerCAmelCase: dict[str, float] = { "km/h": 1.0, "m/s": 0.277_777_778, "mph": 0.621_371_192, "knot": 0.539_956_803, } def _lowercase( __a ...
20
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :Optional[Any] ) -> Dict: return getitem, k def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CAS...
504
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : str = { '''configuration_xlm_roberta_xl''': [ '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMRobertaXLConfig''', '''XLMR...
316
from __future__ import annotations def _snake_case ( lowerCAmelCase : list[int] ): # This function is recursive """simple docstring""" SCREAMING_SNAKE_CASE_ : int = len(lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condi...
316
1
def SCREAMING_SNAKE_CASE_ ( lowerCAmelCase_: int , lowerCAmelCase_: int , lowerCAmelCase_: list[list[int]] ): def update_area_of_max_square(lowerCAmelCase_: int , lowerCAmelCase_: int ) -> int: # BASE CASE if row >= rows or col >= cols: ...
666
'''simple docstring''' 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 lowercase_ ( unittest.TestCase ): '''simple docstring''' ...
447
0
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCam...
710
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVe...
601
0
'''simple docstring''' import argparse import logging import pickle from collections import Counter logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) _UpperCAmelCase : Optional[int] = logging.get...
107
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtracti...
207
0
from __future__ import annotations import bisect def snake_case__ ( lowerCAmelCase_, lowerCAmelCase_, lowerCAmelCase_ = 0, lowerCAmelCase_ = -1 ): """simple docstring""" if hi < 0: SCREAMING_SNAKE_CASE =len(lowerCAmelCase_ ) while lo < ...
704
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowerCamelCase ={ "configuration_perceiver": ["PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PerceiverConfig", "Perce...
252
0
'''simple docstring''' from __future__ import annotations import math from collections.abc import Callable def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = 100 , ): """simple docstring""" __magic_na...
436
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, slow, torch_dev...
204
0
from string import ascii_uppercase lowerCAmelCase = {char: i for i, char in enumerate(ascii_uppercase)} lowerCAmelCase = dict(enumerate(ascii_uppercase)) def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' ...
675
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
675
1
"""simple docstring""" from __future__ import annotations from fractions import Fraction def lowerCamelCase_ ( _lowerCamelCase : int , _lowerCamelCase : int ): return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def lowerCa...
142
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase ( a ): """simple docstring""" __lowercase :Optional[int] = ["image_processor", "tokenizer"] __low...
142
1
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets UpperCAmelCase_ = '''\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wang, Alex and Singh, Ama...
718
from collections.abc import Iterable from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar('''_T''') class __SCREAMING_SNAKE_CASE ( Generic[_T] ): """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE__ = None ): """simple docstring""" ...
519
0
'''simple docstring''' from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __A : '''simple docstring''' def a__ (self , A ) -> Optional[int]: """simple docstring""" raise...
11
import os import sys import unittest __a: Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_map...
108
0
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching...
705
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord impor...
336
0
'''simple docstring''' from __future__ import annotations def A_ ( snake_case , snake_case , snake_case ): SCREAMING_SNAKE_CASE:str = list(range(len(snake_case ) ) ) SCREAMING_SNAKE_CASE:Any = [v / w for v, w in zip(snake_case , snake_ca...
143
"""simple docstring""" from __future__ import annotations def _A( lowerCAmelCase ): if len(lowerCAmelCase ) == 0: return [] A__ , A__ : Dict = min(lowerCAmelCase ), max(lowerCAmelCase ) A__ : List[Any] = int(...
363
0
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva _snake_case : List[Any] = """""" _snake_case : Union[str, Any] = """""" _snake_case : int = """""" _snake_case : Optional[Any] = 1 # (0 is vertical, ...
493
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _a ( _SCREAMING_SNAKE_CASE : int ): # A local function to see if a dot lands in the circle. def is_in_circle(_SCREAMING_SNAKE_CASE : float ,...
493
1
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
264
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase (__snake_case ): def __init__( s...
264
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from...
505
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a = logging.get_logger(__name__) a ...
505
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a_ : List[str] = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
439
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import...
12
0
'''simple docstring''' import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow snake_case_ : Union[str, Any] = [ os.path.join(os.path.dirname(__file__), dirname) for di...
709
'''simple docstring''' def __snake_case ( _UpperCAmelCase : Optional[int]): UpperCamelCase = [] UpperCamelCase = [] UpperCamelCase = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, '''-''': 1, } ...
350
0
'''simple docstring''' import numpy as np class _UpperCamelCase : '''simple docstring''' def __init__( self ): """simple docstring""" a__ = (0, 0) a__ = None a__ = 0 ...
394
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __A : str = logging.get_logger(__name__) __A : Optional[Any] = { 'Salesforce/blip-vqa-base': 'https://huggingface.co...
394
1
import itertools import string from collections.abc import Generator, Iterable def _A( UpperCamelCase__ : Iterable[str] , UpperCamelCase__ : int ) -> Generator[tuple[str, ...], None, None]: '''simple docstring''' __lowercase = iter(UpperCamelCas...
362
import argparse import copy def _A( UpperCamelCase__ : Union[str, Any] ) -> Tuple: '''simple docstring''' __lowercase = {} with open(UpperCamelCase__ ) as f: for line in f: if line.split()[0] not in dict_of_neighbour...
362
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : int = logging.get_logger(__name__) lowerCAmelCase_ : Any = { '''facebook/wav2vec2-base-960h''': '''https:...
673
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import c...
673
1
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : str ): """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
28
"""simple docstring""" import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, Mobi...
28
1
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 a ( lowercase__ , lowercase__ ): "...
63
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case__ : List[Any] = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not is_torch_available(): raise Op...
402
0
def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase, __UpperCamelCase ): '''simple docstring''' SCREAMING_SNAKE_CASE__ =(num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def UpperCAmelCa...
720
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ), ...
588
0
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 UpperCAmelCase_ : List[Any] = { # 1536-bit 5: { '''prime''': int( ...
17
'''simple docstring''' import math import tensorflow as tf from packaging import version def __A ( a_ : List[Any] ): lowerCAmelCase : Any = tf.convert_to_tensor(a_ ) lowerCAmelCase : List[Any] = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2....
525
0
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def UpperCamelCase_ ( __SCREAMING_SNAKE_CASE ): """simple docstring""" if not sentence: return "" snake_case_ : List[str] = dict(zip(__SCREAMING_SNAKE_CASE, __SCREAMING_SNAKE_CASE ...
92
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets a_ = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes) or mu...
92
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class snake_case_ ( lowerCamelCase_ ): """simple docstring""" @staticmethod @abstractmethod def UpperCAmelCase__ ( lowerCamelCase_) -> Union[str, Any]: raise No...
34
def UpperCamelCase_( _A :list[list] )-> list[list]: UpperCamelCase__ = current_set.copy() for row_index, row in enumerate(_A ): UpperCamelCase__ = row[0] for column_index, column in enumerate(_A ): if magnitude == 0: UpperCamelCase__ = ...
551
0
import csv import tweepy # Twitter API credentials _SCREAMING_SNAKE_CASE : Tuple = '' _SCREAMING_SNAKE_CASE : Any = '' _SCREAMING_SNAKE_CASE : Tuple = '' _SCREAMING_SNAKE_CASE : Dict = '' def SCREAMING_SNAKE_CASE ( __UpperCamel...
55
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets _SCREAMING_SNAKE_CASE : Union[str, Any] = '\\n@inproceedings{snover-etal-2006-study,\n title = "A Study of Translation Edit Rate with Targeted Human Annotation",\n author = "Snover, Matthew and\...
55
1
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common impo...
65
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowercase_ ( __snake_case : Optional[Any] ) -> List[Any]: '''simple docstring''' if ( (...
241
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase_( metaclass=SCREAMING_SNAKE_CASE_ ): '''simple docstring''' __lowercase : Optional[int] = ['''flax'''] def __init__( self ,*__UpperCAmelCase ,**__UpperCAmelCase ) -> List[str]: ...
720
'''simple docstring''' from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers impo...
160
0
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutput...
171
'''simple docstring''' import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from tr...
56
0
from __future__ import annotations class lowerCamelCase__ : def __init__(self : Union[str, Any] , _snake_case : str , _snake_case : str ) -> Tuple: """simple docstring""" lowerCamelCase_ , lowerCamelCase_ : Tuple ...
144
from PIL import Image def _a ( lowerCamelCase__ , lowerCamelCase__ ) -> Image: def brightness(lowerCamelCase__ ) -> float: return 1_28 + level + (c - 1_28) if not -255.0 <= level <= 255.0: raise ValueError('level must be between -255.0 (black) and 255.0 (white)' ...
144
1
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> list: '''simple docstring''' _lowerCamelCase : Tuple = [] _lowerCamelCase, _lowerCamelC...
46
from math import factorial UpperCAmelCase : Tuple = {str(d): factorial(d) for d in range(10)} def _A ( SCREAMING_SNAKE_CASE : int ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(SCREAMING_SNAKE_CASE ) ) def _A ( ): ...
563
0
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVis...
463
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def snake_case ( A__ ,A__ ,A__ ,A__ ,A__ ,A__ ): # prepare kernel # the kernel size have to be odd if (ksize % 2) == 0: UpperCAmelCase_ : Lis...
463
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device f...
43
import cva import numpy as np class _A : def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" if k in (0.04, 0.06): SCREAMING_SNAKE_CASE_ : Any = k SCREAMING_SNAKE_CASE_ ...
511
0
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vis...
720
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __lowercase = datasets.load_iris() __lowercase = np.array(data['''data''']) __lowercase = np.array(data['''target''']) __lowercase ...
452
0
'''simple docstring''' import math def a_ ( _lowerCAmelCase ,_lowerCAmelCase = 0 ,_lowerCAmelCase = 0 ) -> list: __lowerCamelCase : List[Any] = end or len(_lowerCAmelCase ) for i in range(_lowerCAmelCase ,_lowerCAmelCase ): __lowerCamelCase : Optio...
459
'''simple docstring''' import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = {'vocab_file': 'vocab.json'} _Uppe...
459
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FunnelConfig'''],...
478
import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_checkpoint_callback, get_earl...
478
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "Salesforce/blip-vqa-base": "https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/c...
32
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } class __magic...
358
0
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.p...
715
from collections.abc import Generator def A ( ) -> Generator[int, None, None]: UpperCamelCase__ , UpperCamelCase__ :str = 0, 1 while True: UpperCamelCase__ , UpperCamelCase__ :Tuple = b, a + b yield b def A ( lowercase__ : int =...
383
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __snake_case = logging.get_logger(__name__) class _a ( _lowerCAmelCase ): """simple docstring""" def __init__( self : List[Any] , *lowerc...
451
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Dict =logging.get_logger(__name__) lowerCAmelCase : List[Any] ...
172
0
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
430
"""simple docstring""" import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def _UpperCAmelCase ( __lowerCamelCase : Optional[int] ) -> Dict: _snake_case = [ '''decoder.version''', ...
430
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class snake_case : UpperCAmelCase__ = field( metadata={''...
626
"""simple docstring""" import doctest from collections import deque import numpy as np class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [2, 1, 2, -1] SCREAMING_SNAKE_CASE_ = [1, 2, 3, 4] def...
626
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenizat...
332
from math import pow, sqrt def a__ (*__lowercase :float ) -> bool: _A : List[str] = len(__lowercase ) > 0 and all(value > 0.0 for value in values ) return result def a__ (__lowercase :float , __lowercase :float ...
332
1
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampl...
302
from cva import destroyAllWindows, imread, imshow, waitKey def A_ ( A__ ) -> Tuple: # getting number of pixels in the image a__ , a__ : Any = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(A__...
302
1
"""simple docstring""" import numpy as np def A__ ( UpperCamelCase__ ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
709
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but ...
168
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_...
38
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
562
0
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __SCREAMING_SNAKE_CASE : Tuple = TypeVar('''T''') class lowerCamelCase_( Generic[T] ): '''simple docstring''' lowercase__ : ...
713
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def lowerCAmelCase_( lowercase_ : float , lowercase_ : float , lowercase_ : float ) -> dict[str, float]: if (resistance, reactance, impedance).count(0 )...
623
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wav...
24
'''simple docstring''' import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPip...
24
1
from datetime import datetime as dt import os from github import Github _a = [ """good first issue""", """good second issue""", """good difficult issue""", """feature request""", """new model""", """wip""", ] def snake_case__ ( ): lowerCAmelCase__ :Dict...
719
from __future__ import annotations import numpy as np def snake_case__ ( UpperCAmelCase : np.ndarray ): lowerCAmelCase__ ,lowerCAmelCase__ :List[str] = np.shape(UpperCAmelCase ) if rows != columns: lowerCAmelCase__ :Tuple ...
111
0
'''simple docstring''' from __future__ import annotations def lowercase_ ( _lowercase , _lowercase = None , _lowercase = None , _lowercase = False , ) -> tuple[int, float, str]: '''simple docstring''' lowerCamelCase_ : Optional[Any] = ciph...
422
'''simple docstring''' def lowercase_ ( _lowercase ) -> set: '''simple docstring''' lowerCamelCase_ : str = set() # edges = list of graph's edges lowerCamelCase_ : Optional[Any] = get_edges(_lowercase ) # While there are still elements in edges list, ta...
422
1
"""simple docstring""" import sys UpperCAmelCase = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """66...
711
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version UpperCAmelCase = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, """...
342
0
'''simple docstring''' import os def __A ( ) -> List[Any]: '''simple docstring''' with open(os.path.dirname(UpperCAmelCase ) + "/grid.txt" ) as f: _UpperCamelCase : Dict = [] # noqa: E741 for _ in range(2_0 )...
435
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowerCAmelCase_ : List[str] = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a compa...
435
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_co...
682
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = '▁' _A = { ...
682
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCAmelCase : Any = { 'configuratio...
241
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Optional[Any] = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } try:...
73
0
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_avail...
266
'''simple docstring''' import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin,...
266
1
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 __snake_case :Any ={ # 1536-bit 5: { 'prime': int( 'FFFFF...
106
'''simple docstring''' 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_ ( snake_case_ : Union[dict, list, ...
78
0
from __future__ import annotations def __lowercase( UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , ): """simple docstring""" if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 val...
484
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py a_ : Tuple = 'src/transformers' a_ : Any = '...
484
1
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 GradientState, Par...
413
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): if not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise TypeError("only integers accepted as input" ) else: lowercase__ = str(abs(SCREAMING_SNAKE_CASE_ ) ) lowercase__ = [list(SCREAMING_SNAKE_CASE_ ...
413
1
import heapq def A__ ( snake_case_ : dict ): SCREAMING_SNAKE_CASE__: list[list]= [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, so I used -1...
107
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxTi...
107
1
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): return round(float(moles / volume ) * nfactor ) def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): return round(float((moles * 0.0_8...
669
import math def UpperCamelCase__( UpperCamelCase__ : int )->list: A__ = [True] * n A__ = False A__ = False A__ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): A__ = i * 2 wh...
190
0
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .at...
174
'''simple docstring''' import requests __snake_case : int = 'YOUR API KEY' def _UpperCAmelCase ( _UpperCamelCase : str, _UpperCamelCase : str = giphy_api_key ) -> list: A_ = '''+'''.join(query.split() ) A_ = F'''https...
174
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor lowerCamelCase_ = logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE( A ): def __init__( self ,*SCREAMING_SNAKE_CA...
498
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _SCREAMING_SNAKE_CASE( A ): @staticmethod @abstractmethod def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> str: "...
498
1
"""simple docstring""" import sys __lowercase : Tuple = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" ...
66
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def lowerCamelCase_ ( _lowerCamelCase : int = 8 ): lowerCamelCase_ = ascii_letters + digits + punctuation return "".joi...
66
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "facebook/lev...
32
import torch def lowerCAmelCase__ ( ) -> int: '''simple docstring''' if torch.cuda.is_available(): A__ = torch.cuda.device_count() else: A__ = 0 print(F'Successfully ran on {num_gpus} GPUs' ) if __name__ == "__main__": ...
514
0
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's ...
352
'''simple docstring''' lowercase_ = 256 # Modulus to hash a string lowercase_ = 1_000_003 def lowerCAmelCase (__A , __A): """simple docstring""" _a = len(__A) _a = len(__A) if p_len > t_len: return False _a ...
352
1
def UpperCamelCase_( lowerCamelCase_ ) -> List[str]: _lowercase , _lowercase : Optional[int] = [], [] while len(lowerCamelCase_ ) > 1: _lowercase , _lowercase : List[str] = min(lowerCamelCase_ ), max(lowerCamelCase_ )...
89
'''simple docstring''' 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_to...
316
0
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTest...
718
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCamelCase : Optional[Any] = { '''configuration_biogpt''': ['''BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BioGptConfig'''], '''tokenizatio...
316
0
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A_ ( SCREAMING_SNAKE_CASE ): _UpperCAmelCase : int = (UnCLIPScheduler,) def lowerCAmelCase ( self : Union[str, Any] ,**SCREAMI...
652
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 import Da...
652
1
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_simplify, require_pytess...
703
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 ( snake_case : Union[dict, list, tuple, torch.Tensor] ) ...
189
0
def __lowerCAmelCase ( ) -> int: '''simple docstring''' return 1 def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __lowerCAmelCase ( _UpperCamelCase...
439
import argparse import os import re a_ : List[str] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ : Optional[Any] = re.compile(R"[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s...
439
1
'''simple docstring''' import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( ...
271
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorSt...
271
1
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_con...
24
'''simple docstring''' def _A ( lowercase__ ): assert ( isinstance(lowercase__ , lowercase__ ) and number_of_steps > 0 ), f'''number_of_steps needs to be positive integer, your input {number_of_steps}''' if number_of_steps == 1: return 1 lowercase__ ...
325
0
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configu...
95
"""simple docstring""" import functools def lowercase ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] ): '''simple docstring''' if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) or n...
95
1
'''simple docstring''' import qiskit def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : int , lowerCamelCase__ : int ): '''simple docstring''' A: Union[str, Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acti...
135
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils imp...
135
1
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE_ : Tuple = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and th...
500
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int ): A__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def _snake_case ( UpperCAmelCase_ : int ): A__ = 0 while number > 0: ...
500
1
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.I...
61
from __future__ import annotations def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : int , lowerCAmelCase_ : int , lowerCAmelCase_ : int ): """simple docstring""" lowerCAmelCase__ = [] lowerCAmelCase__ , lowerCAmelCas...
61
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path a_ : Optional[int] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa imp...
712
def __lowercase( UpperCAmelCase__ ): """simple docstring""" lowerCamelCase = [] lowerCamelCase = [] lowerCamelCase = { "^": 3, "*": 2, "/": 2, "%": 2, "+": 1, "-": 1, } # P...
484
0