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 inspect import unittest from transformers import ViTMSNConfig 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 ...test_m...
225
class SCREAMING_SNAKE_CASE : def __init__( self : List[Any] ): '''simple docstring''' __a = {} # Mapping from char to TrieNode __a = False def UpperCamelCase_ ( self : Dict , __lowercase : list[str] ): ...
225
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time UpperCAmelCase_ = Lock() def __magic_name__ ( lowercase , lowercase , lowercase , lowercase , lowerc...
436
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def __magic_name__ ( lowercase ) -> Union[str, Any]: """simple doc...
436
1
import collections import importlib.util import os import re from pathlib import Path lowercase : List[Any] = """src/transformers""" # Matches is_xxx_available() lowercase : List[str] = re.compile(R"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowercas...
336
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, ) lowercase : List[str] = { """configuration_clip""": [ "...
336
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
252
import math from numpy import inf from scipy.integrate import quad def snake_case__ ( lowerCAmelCase_ ): """simple docstring""" if num <= 0: raise ValueError('math domain error' ) return quad(lowerCAmelCase_, 0, lowerCAmelCase_, args=(lower...
252
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : str =logging.get_logger(__name__) __lowerCAmelCase : Any ={ # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _lowercase ( A__ ):...
696
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase : List[Any] ={ 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class _...
696
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A__ = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokenization_mvp""": ["""M...
717
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A__ = { """configuration_layoutlmv2""": ["""LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Layo...
49
0
'''simple docstring''' import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_model...
78
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffus...
260
0
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase : Any = 6378137.0 UpperCAmelCase : str = 6356752.314245 UpperCAmelCase : Tuple = 6_37_81_37 def _SCREAMING_SNAKE_CASE ( a , a ...
77
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase : List[str] = logging.get_log...
77
1
"""simple docstring""" def _snake_case ( snake_case__ : int = 100 ): A = n * (n + 1) * (2 * n + 1) / 6 A = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F"""{solution() = }""")
91
"""simple docstring""" from __future__ import annotations def snake_case__ ( _lowerCamelCase, _lowerCamelCase, _lowerCamelCase, ) ->tuple: """simple docstring""" if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more o...
575
0
from ... import PretrainedConfig a : Union[str, Any] = { 'sijunhe/nezha-cn-base': 'https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json', } class a ( _lowerCamelCase ): snake_case_ = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP snake_case_ ...
711
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a : List[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHI...
593
0
import sys import turtle def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : tuple[float, float] , UpperCAmelCase_ : tuple[float, float] ) -> Optional[Any]: return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : tuple[floa...
443
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class...
28
0
"""simple docstring""" def A ( snake_case__ ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): SCREAMING_SNAKE_CASE__ = f"""Input value of [number={number}] must be an integer""" raise TypeError(snake_case__ ) ...
721
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torc...
616
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { 'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json', # See all CANINE models at https://huggingface.co/models?filter=canine } class ...
393
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase :List[str] = logging.get_logger(__name__) lowerCamelCase :Any = { 'vocab_file': 'vocab...
487
0
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) loggin...
704
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """post_extract_proj""": """feature_projection.projecti...
531
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _UpperCamelCase : Optional[int] =argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ...
206
from PIL import Image def a__ (__lowercase :Image , __lowercase :float ) -> Image: def brightness(__lowercase :int ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError('''level must be between -255....
206
1
'''simple docstring''' def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_) -> bool: UpperCamelCase__ : Dict = len(lowerCamelCase_) UpperCamelCase__ : Dict = len(lowerCamelCase_) UpperCamelCase__ : Dict = [[...
6
'''simple docstring''' import numpy as np from PIL import Image def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_) -> np.ndarray: UpperCamelCase__ : List[Any] = np.array(lowerCamelCase_) if arr.s...
6
1
from __future__ import annotations from collections.abc import Callable def A_ ( A__ , A__ , A__ , A__ = 100 , ) -> Any: a__ : List[str] = x_start a__ : int = fnc(__a ) a__ : str = 0.0 for _...
302
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import pat...
626
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : List[Any] = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', ...
702
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case_( a__ ): pass class snake_case_: def __init__( self : Any , UpperCamelCase_ : Any ): lowerCAmelCase : Any = data lowerCAmelCa...
637
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCam...
12
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import ja...
123
0
from __future__ import annotations def _lowercase ( UpperCAmelCase_): """simple docstring""" if not nums: return 0 snake_case__ : List[Any] = nums[0] snake_case__ : str = 0 for num in nums[1:]: snake_case__ , snake_case_...
127
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowercase_: Union[str, Any] = logging.get_logger(__name__) def _lowercase ( UpperCAmelCase_): """simple docstring""" if isinstance(UpperCAmelCase_ , ...
127
1
'''simple docstring''' import math def lowerCAmelCase ( UpperCamelCase__ : int ): """simple docstring""" __UpperCAmelCase = [True] * n __UpperCAmelCase = False __UpperCAmelCase = False __UpperCAmelCase = True ...
262
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase ( UpperCamelCase__ : Optional[int] , UpperCamelC...
262
1
"""simple docstring""" import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_uti...
720
"""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 from ..auto import CONFIG_MAPPING A__ : Union[str, Any] = logging....
660
0
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compu...
594
"""simple docstring""" from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowe...
594
1
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_rouge, chunks, p...
718
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and ...
455
0
from typing import Any def _A ( SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : dict , SCREAMING_SNAKE_CASE : dict , SCREAMING_SNAKE_CASE : dict , ): """simple docstring""" _validation( SCREAMING_SNAKE_CASE_ ...
563
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing...
386
0
'''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 lowerCamelCase ( unittest.TestCase ): '''simple docstring''' ...
716
'''simple docstring''' from __future__ import annotations import requests __snake_case : Union[str, Any] = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category c...
687
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
89
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> Optional[int]: # Initialise ...
89
1
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import...
709
'''simple docstring''' import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import...
273
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__magic_name__ ) class lowerCAmelCase__ ( __magic_name__ ): '''simple docstring''' lowercase_ = field...
184
from __future__ import annotations from statistics import mean def a ( A__ : list[int] , A__ : list[int] , A__ : int ) -> list[int]: """simple docstring""" _lowercase =[0] * no_of_processes _lowercase =[0] * no_of_processes ...
291
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase__ = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "tokenization_gp...
718
from __future__ import annotations from collections import Counter from random import random class _a : """simple docstring""" def __init__( self ): _lowercase ={} def __lowerCAmelCase ( self , lowerCAmelCase_ ): _lowercase ={} def __lowerCAmelCase ( ...
594
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase = { "configuration_mobilebert": [ "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Mob...
66
'''simple docstring''' import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ......
597
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _snake_case = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONF...
491
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def __snake_case ( SCREAMING_SNAKE_CASE: np.ndarray ): """simple docstring""" _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = rgb[:, :, 0], rgb[:...
491
1
import glob import os import random from string import ascii_lowercase, digits import cva __snake_case = '''''' __snake_case = '''''' __snake_case = '''''' __snake_case = 1 # (0 is vertical, 1 is horizontal) def _A ( ) -> None...
1
from collections.abc import Generator from math import sin def _A ( _lowercase ) -> bytes: """simple docstring""" if len(_lowercase ) != 32: raise ValueError('Input must be of length 32' ) __UpperCamelCase = B'' for i in [3, 2, 1, 0]: ...
1
1
import logging from transformers import PretrainedConfig _lowercase: Any = logging.getLogger(__name__) _lowercase: Optional[Any] = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', } class ...
225
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 transformers.testing_utils impor...
225
1
import os import numpy import onnx def UpperCAmelCase__( __UpperCAmelCase : str , __UpperCAmelCase : Optional[Any] ): __snake_case : int = a.name __snake_case : Dict = b.name __snake_case : str = '' __snake_cas...
576
from __future__ import annotations def __UpperCAmelCase ( lowerCamelCase_ : list[float] ) -> float: """simple docstring""" SCREAMING_SNAKE_CASE_ : Tuple = 0.0_0 SCREAMING_SNAKE_CASE_ : Tuple = 0 for resistor in resistors: if...
105
0
from importlib import import_module from .logging import get_logger lowerCAmelCase__ = get_logger(__name__) class snake_case__: """simple docstring""" def __init__( self : int , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : Optional[An...
703
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_device ...
81
0
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visio...
556
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenize...
556
1
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore a_ = namedtuple('covid_data', 'cases deaths recovered') def __UpperCAmelCase ( __UpperCamelCase = "https://www.worldometers.info/coronavirus/" ): ...
523
"""simple docstring""" from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCAmelCase_ ...
523
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a__ : str = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], ""...
589
"""simple docstring""" import numpy as np def A__ ( __lowerCamelCase ): """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
589
1
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __a = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __a = [file for file in filepaths if file != file.lower()] if upper_fi...
712
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
0
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_mode...
46
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
46
1
'''simple docstring''' import unittest from transformers import BertGenerationConfig, 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_modelin...
710
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
39
0
from __future__ import annotations from statistics import mean def a__ ( snake_case , snake_case , snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : Tuple = [0] * no_of_processes __SCREAMING_SNAKE_CASE : List[str] = [0] * no_of_proces...
74
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _UpperCAmelCase : List[Any] = { '''configuration_layoutlmv2''': ['''LAYOUT...
107
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __snake_case ( unittest.TestCase ): """simple do...
712
import pytest _lowercase = '''__dummy_dataset1__''' _lowercase = ''' import json import os import datasets REPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/" URLS = {"train": REPO_URL + "wikiann-bn-train.jsonl", "validation": REPO_URL + "wikiann-bn-valida...
683
0
import numpy as np def a__ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): SCREAMING_SNAKE_CASE_ = int(np.ceil((x_end - xa) / h ) ) SCREAMING_SNAKE_CASE_ = np.zeros((n + 1,) ) SCREAMING_SNAKE_CASE_ = ya ...
140
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class a ( __UpperCAmelCase , unittest.TestCase ): lowerca...
611
0
import math import tensorflow as tf from packaging import version def A_ ( _lowerCAmelCase ) -> Any: UpperCamelCase : List[Any] = tf.convert_to_tensor(_lowerCAmelCase ) UpperCamelCase : Any = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype )...
38
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import t...
38
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = { "configuration_informer": [ "INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
498
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCamelCase_ = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig...
498
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils...
710
'''simple docstring''' 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, ...
411
0
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test...
243
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : float , __UpperCamelCase : float ): '''simple docstring''' if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 ...
58
0
"""simple docstring""" import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef SCREAMING_SNAKE_CASE : Union[str, Any] = ( """This...
702
"""simple docstring""" import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase ( _snake_case : Optional[Any] ) ->Any: """simple docstring""" return x + 2 class _UpperCAmelCase ( unittest.T...
229
0
"""simple docstring""" import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_...
46
import math def a__ ( _UpperCamelCase : float ,_UpperCamelCase : float ): if ( not isinstance(_UpperCamelCase ,(int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('''power_factor must be a valid float value between -1 and ...
175
0
"""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 A_ : Optional[Any] = logging.get_logger(__name__) A_ : str ...
696
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline A_ : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name class a_ ( snake_c...
696
1
def __snake_case ( lowerCAmelCase_ = 1_0**9 ) -> int: SCREAMING_SNAKE_CASE__ = 1 SCREAMING_SNAKE_CASE__ = 2 SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ = 0 while perimeter ...
100
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
1
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : str ): '''simple docstring''' if not all(char in '''01''' for char in bin_string ): raise ValueError('''Non-binary value was passed to the function''' ) if not bin_string: ...
95
"""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 low...
95
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderCo...
525
'''simple docstring''' from __future__ import annotations lowerCAmelCase = list[tuple[int, int]] lowerCAmelCase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, ...
525
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> Dict: SCREAMING_SNAKE_CASE_...
107
import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import ( ...
107
1
'''simple docstring''' def A_ ( ) -> Union[str, Any]: __SCREAMING_SNAKE_CASE : str = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] __SCREAMING_SNAKE_CASE : int = 6 __SCREAMING_SNAKE_CASE : List[Any] = 1 __SCREAMING_SNAKE_CASE...
158
from sklearn.metrics import recall_score import datasets __SCREAMING_SNAKE_CASE =""" Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the fa...
234
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor a__ : str = logging.get_logger(__name__) class lowercase_ ( a__ ): def __init__( self , *a , **a ): war...
223
'''simple docstring''' from __future__ import annotations def _UpperCamelCase ( __A , __A ) -> Optional[int]: '''simple docstring''' if len(__A ) <= 1 or n <= 1: return insert_next(__A , n - 1 ) rec_insertion_sort(__A , n - 1 ...
223
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[Any] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''InstructBlip...
639
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) __lowercase = hex_num[0] == '''-''' if is_negative: __lowercase = hex_num[1:] tr...
639
1
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer,...
706
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging ...
413
0
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( UpperCAmelCase__ ): __lowerCAmelCase : Dict = ['image_processor', 'tokenizer'] __lowerCAmelCase : str = 'AutoImageProce...
160
"""simple docstring""" import os 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: int = logging.get_logger(__name__) A: str = ...
160
1
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, ...
383
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { "vocab_file": "vocab.json", "merg...
383
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase = { """configuration_graphormer""": ["""GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GraphormerConfig"""], ...
174
"""simple docstring""" import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = {name: getattr(transformers,...
174
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
534
from __future__ import annotations from dataclasses import dataclass @dataclass class SCREAMING_SNAKE_CASE_ : __magic_name__: float __magic_name__: TreeNode | None = None __magic_name__: TreeNode | None = None def SCREAMING_SNAKE_CASE_...
534
1
"""simple docstring""" from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase__ ( _a ): a : Dict = """EncodecFeatureExtractor""" a : str = ("""T5T...
616
"""simple docstring""" from PIL import Image def lowerCAmelCase_ ( UpperCamelCase__ : Image , UpperCamelCase__ : int ): """simple docstring""" __lowercase = (259 * (level + 255)) / (255 * (259 - level)) def contrast(UpperCamelCase__ ...
616
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
719
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( __snake_case : list[int] ): '''simple docstring''' if len(__snake_case ) == 0: return array lowercase , lowercase = min(__snake_case ), max(__snake_case )...
134
0
import qiskit def __lowerCAmelCase ( UpperCAmelCase__ : int , UpperCAmelCase__ : int ) -> qiskit.result.counts.Counts: lowerCamelCase_ = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register ...
272
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowercase = {'''UserAgent''': UserAgent().random} def __lowerCAmelCase ( UpperCAmelCase__ : Optional[int] ) -> dict: lowerCamelCase_ ...
272
1
"""simple docstring""" import doctest from collections import deque import numpy as np class UpperCAmelCase_ : def __init__( self ) -> None: __lowercase : int = [2, 1, 2, -1] __lowercase : Optional[int] = [1, 2, 3, 4] def _lowerCame...
523
"""simple docstring""" from __future__ import annotations from scipy.special import comb # type: ignore class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Union[str, Any] = list_of_points # Degree determines...
523
1
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __a : __snake_case : int __snake_case : Node | None = None __snake_case : Node | None = None ...
600
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : str = logging.get_logger(__name__) a : Union[str, Any] = { "microsoft/git-base": "https://huggingface.co/microsoft/git-base...
63
0
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...
650
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_uti...
650
1
'''simple docstring''' from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, ...
435
'''simple docstring''' from sklearn.metrics import fa_score import datasets lowerCAmelCase_ : int = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ lowerCAmelCase_ ...
435
1
def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> int: while a != 0: _UpperCAmelCase , _UpperCAmelCase = b % a, a return b def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> int: if gcd(__snake_case , __snake_c...
709
from collections import deque from math import floor from random import random from time import time class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : Any ) -> int: """simple docstring""" _UpperCAmelCase = {} def lowerCamelCase ...
402
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.pipe...
106
import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig if TYPE_CHECKING: from ... import Pr...
36
0
from __future__ import annotations from statistics import mean def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: list[int] , __lowerCamelCase: list[int] , __lowerCamelCase: int ): '''simple docstring''' lowercase_ = [0] * no_of_processes lowercase_ = [0] * no_of_proce...
601
from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE__ = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE__ = _LazyModule(__na...
601
1
'''simple docstring''' 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 snake_case ( uni...
294
'''simple docstring''' def _UpperCamelCase ( lowerCAmelCase__: int ,lowerCAmelCase__: int ) -> str: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) SCREAMING_SNAKE_CASE_ = str(bin(lowerCAmelCase__ ) )[2:] # ...
294
1
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...ut...
719
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, id...
380
0
from __future__ import annotations def lowercase_ (A : list[int] , A : int ): snake_case__ : list[list[int]] = [] snake_case__ : list[int] = [] snake_case__ : List[Any] = 0 snake_case__ : int...
478
from ....utils import logging a_ :Optional[int] = logging.get_logger(__name__) class snake_case__ ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Optional[Any], _snake_case : List[str], _snake_case : Any=None, _snake_case : Tu...
478
1
'''simple docstring''' 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 __UpperCAmelCase = "src/transformers" __UpperC...
720
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig __UpperCAmelCase = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE : ''...
692
0
def A__ ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase = str(bin(SCREAMING_SNAKE_C...
32
from math import sqrt def A__ ( SCREAMING_SNAKE_CASE_ : int ) -> bool: """simple docstring""" 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 mult...
32
1
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def UpperCamelCase ( snake_case__ : np.ndarray ): '''simple docstring''' return input_array.r...
714
import math lowerCamelCase__ = 10 lowerCamelCase__ = 7 lowerCamelCase__ = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( snake_case__ : int = 20 ): '''simple docstring''' __snake_case :Dict = ...
291
0
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_...
646
"""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 __A = 0b101100111110110010010000011110111011000110011110 # bin(x)...
646
1
import os import time import numpy as np import onnxruntime as ort lowercase_: List[Any] = '''1''' lowercase_: Tuple = '''0''' lowercase_: Optional[int] = '''1''' lowercase_: Union[str, Any] = ort.SessionOptions() lowercase_: List[str] = ort...
710
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_: int = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTransformerConfig', ...
127
0
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowercase : str = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): ...
568
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_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/...
568
1
"""simple docstring""" from typing import Any class UpperCamelCase : def __init__( self ,__UpperCamelCase ) -> Tuple: '''simple docstring''' lowercase_ : Any = data lowercase_ : Optional[int] = None class UpperCamelCase...
477
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def lowercase__( ): print('Making key files...' ) make_key_files('rsa' , 10_24 ) print('Key files generation...
477
1
def __UpperCAmelCase ( __a : int ,__a : int ,__a : int ) -> Optional[int]: """simple docstring""" _a : List[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total...
14
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ft...
588
0
class snake_case ( __SCREAMING_SNAKE_CASE ): pass class snake_case ( __SCREAMING_SNAKE_CASE ): pass class snake_case : def __init__(self ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [ [], ...
721
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, ...
628
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Option...
275
'''simple docstring''' from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. __A : Tuple = 10 def UpperCamelCase_ ( A__ : ...
275
1
def __lowercase ( UpperCAmelCase__ = 600_851_475_143 ): """simple docstring""" try: __lowerCAmelCase = int(UpperCAmelCase__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: ...
704
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeechConfig''']} t...
102
0
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transfo...
495
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
495
1
'''simple docstring''' from ... import PretrainedConfig __a = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class UpperCAmelCase_ ( _a ): """simple docstring""" lowercase = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP ...
707
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerConfig", "Blip2VisionCon...
301
0
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() except OptionalDependencyNotAvailable: fr...
681
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
681
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, ...
709
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''google/umt5-small''': '''https://huggingface.co/google/umt5-small/resol...
144
0
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @require_torch @re...
148
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase_ ( UpperCamelCase ): '''simple docstring''' __A : Tuple = ["image_processor", "tokenizer"] __A : Any = "...
340
0
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _A ( __magic_name__ ): lowercase__ ...
611
_snake_case = [ (1000, """M"""), (900, """CM"""), (500, """D"""), (400, """CD"""), (100, """C"""), (90, """XC"""), (50, """L"""), (40, """XL"""), (10, """X"""), (9, """IX"""), (5, """V"""), (4, """IV"""), (1, """I"""), ] def _A ( __magic_name_...
611
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase__ : List[Any] = {'configuration_vit': ['VIT_PRETRAINED_CONFIG_ARCHIVE_MAP...
31
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tes...
131
0
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time SCREAMING_SNAKE_CASE__ = Lock() def UpperCAmelCase__ ( lowerCamelCase_ : Optional[Any] , lowerCamelCase_ : List[Any] , lowerCamelCase_...
700
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__ = { '''facebook...
577
0
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase = ['small', 'medium', 'large'] _lowerCAmelCase = 'lm_head.decoder.weight' _lowerCAmelCase = 'lm_head.weight' def UpperCamelCase ( _A ...
264
"""simple docstring""" from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def UpperCamelCase ( _A = "laptop" ) -> DataFrame: lowercase : List[str] = F"""https://www.amazon.in/laptop/s?k={product}""" low...
264
1
import torch from torch import nn class lowerCamelCase ( nn.Module ): '''simple docstring''' def __init__( self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase=1 , lowerCAmelCase=False ): ...
709
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 0, 0, 0 UpperCAmelCase_ = ugly_nums[ia] * 2 UpperCAmelCase_ = ugly_nums[ia] * 3 UpperCAmelCase_ = ugly_nums[i...
23
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase : List[str] = logging.get_logger(__name__) _lowerCamelCase ...
352
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mas...
352
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Optional[Any] = logging.get_logger(__name__) _a : Dict = { """microsoft/cvt-13""": """https://huggingface.co/microsoft/cvt-13/resolve/main/config.json""", # See all ...
710
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerFo...
87
0