code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
"""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 import cached...
61
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
import math class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_=0 ) -> int: # a graph with Node 0,1,...,N-1 __UpperCamelCase =n __UpperCamelCase =[ [math.inf for j in range(0 , A_ )] fo...
62
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
0
'''simple docstring''' def _lowerCamelCase ( lowercase : list , lowercase : list , lowercase : int ) -> list: _a = len(lowercase ) _a = [[0] * n for i in range(lowercase )] for i in range(lowercase ): ...
63
import argparse from collections import defaultdict import yaml _A = '''docs/source/en/_toctree.yml''' def __UpperCamelCase ( _A ): lowerCAmelCase_ = defaultdict(_A ) for doc in model_doc: counts[doc["local"]] += 1 lowerCAmelCase_ = [key for k...
278
0
"""simple docstring""" 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...
64
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
def lowerCAmelCase_ ( __A, __A ) -> int: '''simple docstring''' if len(__A ) != len(__A ): raise ValueError("String lengths must match!" ) UpperCAmelCase__ = 0 for chara, chara in zip(__A, __A ): ...
65
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 import logging logging.se...
278
0
"""simple docstring""" import math class lowerCamelCase : '''simple docstring''' def __init__( self: List[Any] , snake_case: int=0 ) -> int: # a graph with Node 0,1,...,N-1 snake_case_ :List[str] = n snake_case_ :int = ...
66
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 = logging.get_logger(__name__) _A = { '''google/vit-base-patch16-224''': '''https://hu...
278
0
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_tran...
67
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCamelCase ( _A...
278
0
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Optional[Any] , SCREAMING_SNAKE_CASE_: List[str]=1 ) -> str: '''simple docstring''' if n_shave_prefix_s...
68
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> list[str]: return [sentence[i : i + ngram_size] for i in range(len(UpperCAmelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
69
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
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...
70
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
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_ :str ...
71
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( _A = 3 ): if isinstance(_A , _A ): raise TypeError('''number of qubits must be a integer.''' ) if number_of_qubits <= 0: ...
278
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tok...
72
from functools import lru_cache @lru_cache def __UpperCamelCase ( _A ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod() ...
278
0
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> Optional[int]: if "cls_token" in name: __lowerCamelCase : Dict ...
73
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _A ): lowerCAmelCase_ = 384 ...
278
0
"""simple docstring""" _lowercase = '''Tobias Carryer''' from time import time class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Optional[Any] ,A_ : Optional[int] ,A_ : Any ,A_ : Union[str, Any] ,A_ : Dict=int...
74
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __UpperCamelCase ( _A , _A ): lowerCAmelCase_ = args.log_outputs lowerCAmelCase_ = ...
278
0
'''simple docstring''' import math def a_ ( __snake_case : int ) -> bool: """simple docstring""" return math.sqrt(__snake_case ) * math.sqrt(__snake_case ) == num def a_ ( __snake_case : int ) -> bool: ...
75
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { '''nielsr/canine-s''': 2_048, } # Unicode defines 1,114,112 total “codepoints” _A = 1_114_112 # Below: Constan...
278
0
def lowerCamelCase__ ( _a , _a , _a): return round(float(moles / volume) * nfactor) def lowerCamelCase__ ( _a , _a , _a): return round(float((moles * 0.0821 * temperature) / (volume))) def lowerCamelCase__ ( _a , _a , _a): return...
76
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
0
"""simple docstring""" from timeit import timeit def a_ ( _lowerCAmelCase : int ): '''simple docstring''' if number < 0: raise ValueError('the value of input must not be negative' ) lowercase__ : Any = 0 while number: ...
77
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): f...
278
0
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging snake_case_ = """\ """ snake_case_ = """ Perplexity (PPL) is one...
78
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
278
0
'''simple docstring''' from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _conca...
79
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _A = logging.get_logger(__name__) class A ( __UpperCAmelCase ): def __init__( self, *UpperCamelCase__, **UpperCamelCase__ ): """simple docstring""" warnings.warn...
278
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_te...
80
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _A = l...
278
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : str = logging.get_logger(__name__) lowerCamelCase_ : str = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/r...
81
def __UpperCamelCase ( _A ): if not numbers: return 0 if not isinstance(_A , (list, tuple) ) or not all( isinstance(_A , _A ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) lowerCAmelCase_ = low...
278
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig A__ = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albert-large-v1""": """https://huggingface.c...
82
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAG...
278
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, fl...
83
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
"""simple docstring""" def _snake_case ( lowercase__ : int = 1_0_0_0 ) -> int: '''simple docstring''' lowerCAmelCase_ , lowerCAmelCase_ :Optional[int] = 1, 1 lowerCAmelCase_ :Dict = 2 while True: lowerCAmelCase_ :s...
84
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
0
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _snake_case ( lowercase_ ): lowerCA...
85
import argparse from collections import defaultdict import yaml _A = '''docs/source/en/_toctree.yml''' def __UpperCamelCase ( _A ): lowerCAmelCase_ = defaultdict(_A ) for doc in model_doc: counts[doc["local"]] += 1 lowerCAmelCase_ = [key for k...
278
0
"""simple docstring""" import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available ...
86
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata UpperCamelCa...
87
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 import logging logging.se...
278
0
def a__ ( A_ ): '''simple docstring''' if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(A_, A_ ): raise TypeError("""Input value must be a 'int' type""" ) return bin(A_ ).count("""1""" ) if _...
88
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 = logging.get_logger(__name__) _A = { '''google/vit-base-patch16-224''': '''https://hu...
278
0
'''simple docstring''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights fro...
89
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCamelCase ( _A...
278
0
def lowerCamelCase_ ( UpperCamelCase__ : int ) -> list: """simple docstring""" __lowerCamelCase = int(UpperCamelCase__ ) if n_element < 1: __lowerCamelCase = ValueError('a should be a positive number' ) ...
90
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
"""simple docstring""" UpperCAmelCase_ : Any = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ ...
91
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = {"""vocab_file"""...
92
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
'''simple docstring''' class lowerCAmelCase__ : def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase_ : Any = name ...
93
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( _A = 3 ): if isinstance(_A , _A ): raise TypeError('''number of qubits must be a integer.''' ) if number_of_qubits <= 0: ...
278
0
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ......
94
from functools import lru_cache @lru_cache def __UpperCamelCase ( _A ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod() ...
278
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : str = logging.get_logger(__name__) UpperCAmelCase : str = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class __lowerC...
95
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _A ): lowerCAmelCase_ = 384 ...
278
0
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf lowercase...
96
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __UpperCamelCase ( _A , _A ): lowerCAmelCase_ = args.log_outputs lowerCAmelCase_ = ...
278
0
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def a ( __a="ro" , __a="en" , __a="wmt16" , __a=None ) -> None: '''simple docstring''' try: import datasets except (ModuleNotFoundError, ImportError): raise Import...
97
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { '''nielsr/canine-s''': 2_048, } # Unicode defines 1,114,112 total “codepoints” _A = 1_114_112 # Below: Constan...
278
0
"""simple docstring""" import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf...
98
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
0
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_c...
99
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): f...
278
0
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "huggingface/time-series-transformer-tourism-monthly": ( "https://huggin...
100
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
278
0
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_early_...
101
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _A = logging.get_logger(__name__) class A ( __UpperCAmelCase ): def __init__( self, *UpperCamelCase__, **UpperCamelCase__ ): """simple docstring""" warnings.warn...
278
0
"""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 ( ) ->None: """simple docstring""" print('''Making key files...''' ) make_key_files('''rsa''' ...
102
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _A = l...
278
0
import math def UpperCamelCase( __UpperCamelCase : int = 100 ): lowerCAmelCase_ : Dict = sum(i * i for i in range(1 ,n + 1 ) ) lowerCAmelCase_ : Optional[int] = int(math.pow(sum(range(1 ,n + 1 ) ) ,2 ) ) return square_of_sum - sum_of_squares if __name__ =...
103
def __UpperCamelCase ( _A ): if not numbers: return 0 if not isinstance(_A , (list, tuple) ) or not all( isinstance(_A , _A ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) lowerCAmelCase_ = low...
278
0
'''simple docstring''' import re import string import numpy as np import datasets lowerCAmelCase__ = ''' Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. ''' lowerCAmelCase__ = ''' Arg...
104
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAG...
278
0
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a : List[str] = logging.get_logger(__name__) a : int = { '''t5-small''': '''http...
105
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Tuple = {} try: if not is_sentencepiece_avail...
106
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
0
import string def __magic_name__ ( A : str ): '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): a = "" for symbol in message: if symbol in string.ascii_uppercase: a = string.ascii_uppercase.find(A ) ...
107
import argparse from collections import defaultdict import yaml _A = '''docs/source/en/_toctree.yml''' def __UpperCamelCase ( _A ): lowerCAmelCase_ = defaultdict(_A ) for doc in model_doc: counts[doc["local"]] += 1 lowerCAmelCase_ = [key for k...
278
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : list[int] ): '''simple docstring''' if not numbers: return 0 if not isinstance(SCREAMING_SNAKE_CASE , (list, tuple) ) or not all( isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ...
108
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
"""simple docstring""" def _snake_case ( UpperCamelCase : int ): if num <= 0: raise ValueError("""Input must be a positive integer""" ) UpperCAmelCase : Any = [True] * (num + 1) UpperCAmelCase : Any = 2 while p * p <= num: if primes[p]: for i in range(p * p , ...
109
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 import logging logging.se...
278
0
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( __UpperCAmelCase ): @staticmethod @abstractmethod def A ( A : Optional[int] ) -> Any: raise NotImp...
33
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 = logging.get_logger(__name__) _A = { '''google/vit-base-patch16-224''': '''https://hu...
278
0
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, requir...
73
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCamelCase ( _A...
278
0
from collections import defaultdict class a : """simple docstring""" def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ ) -> Tuple: _A = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N ...
180
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
lowercase__ :List[str] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' # Make sure the supplied data is a bytes-like object if not isinstance(_A , _A ): lowercase = f'a ...
101
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
0
from __future__ import annotations SCREAMING_SNAKE_CASE_ = [] def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> str: '''simple docstring''' for i in range(len(_A ) ): if board[row][i] ...
296
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
"""simple docstring""" import argparse import hashlib # hashlib is only used inside the Test class import struct class _UpperCAmelCase : def __init__( self : Any , _lowercase : Dict ): __UpperCAmelCase = data __UpperCAmelCase = [0X6_7_4_5_2...
332
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( _A = 3 ): if isinstance(_A , _A ): raise TypeError('''number of qubits must be a integer.''' ) if number_of_qubits <= 0: ...
278
0
"""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 ...
224
from functools import lru_cache @lru_cache def __UpperCamelCase ( _A ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod() ...
278
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=__UpperCAmelCase ): '''simple docstring''' UpperCamelCase_ : int = ["""speech"""] def __init__( self : Di...
319
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _A ): lowerCAmelCase_ = 384 ...
278
0
"""simple docstring""" __A = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __A = [{"type": "cod...
177
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __UpperCamelCase ( _A , _A ): lowerCAmelCase_ = args.log_outputs lowerCAmelCase_ = ...
278
0
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCamelCase : Dict = get_tests_dir...
219
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { '''nielsr/canine-s''': 2_048, } # Unicode defines 1,114,112 total “codepoints” _A = 1_114_112 # Below: Constan...
278
0
'''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 SPIECE_UNDERLINE, logging __snake_case ...
4
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
0
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1_3...
33
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): f...
278
0
import warnings from .generation import TFGenerationMixin class A_ ( __UpperCAmelCase ): # warning at import time warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ''' '''be r...
73
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
278
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 snake_case ( snake_case__...
180
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _A = logging.get_logger(__name__) class A ( __UpperCAmelCase ): def __init__( self, *UpperCamelCase__, **UpperCamelCase__ ): """simple docstring""" warnings.warn...
278
0
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 i...
101
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _A = l...
278
0
import math import flax.linen as nn import jax.numpy as jnp def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 1 , _SCREAMING_SNAKE_CASE = 1 , _SCREAMING_SNAKE_CASE = 1.0E4 , _SCREAMING_SNAKE_CASE = False , _SCREAMING_...
296
def __UpperCamelCase ( _A ): if not numbers: return 0 if not isinstance(_A , (list, tuple) ) or not all( isinstance(_A , _A ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) lowerCAmelCase_ = low...
278
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning,...
332
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAG...
278
0
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class UpperCamelCase__ ...
224
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
'''simple docstring''' from ...processing_utils import ProcessorMixin class lowerCAmelCase_ ( __UpperCAmelCase ): '''simple docstring''' UpperCamelCase_ : Any = ["""image_processor""", """feature_extractor"""] UpperCamelCase_ :...
319
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
0
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class UpperCAmelCase (ctypes.Structure ): """simple docstring""" _UpperCAmelCase :int = [("...
177
import argparse from collections import defaultdict import yaml _A = '''docs/source/en/_toctree.yml''' def __UpperCamelCase ( _A ): lowerCAmelCase_ = defaultdict(_A ) for doc in model_doc: counts[doc["local"]] += 1 lowerCAmelCase_ = [key for k...
278
0
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available ...
219
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
'''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 UpperCAmelCase_ ( __UpperCAmelCase ...
4
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 import logging logging.se...
278
0
"""simple docstring""" from __future__ import annotations def lowercase ( __snake_case : Union[str, Any] ): lowercase_ : Dict = str(_A ) return len(_A ) == 9 and set(_A ) == set('''123456789''' ) def lowercase ( ): for base_num in ran...
33
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 = logging.get_logger(__name__) _A = { '''google/vit-base-patch16-224''': '''https://hu...
278
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a =logging.get_logger(__name__) a ={ """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all PEGASUS models at https://huggingface.co/models?filter=pegasus ...
73
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCamelCase ( _A...
278
0
import cmath import math def snake_case ( snake_case__ :str , snake_case__ :Tuple , snake_case__ :Optional[Any] , snake_case__ :Optional[Any]) -> Union[str, Any]: _A = math.radians(_A) _A = math.radians(_A) # Convert voltage and curren...
180
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' return abs(_A ) if a == 0 else greatest_common_divisor(b % a , _A ) def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' while y: # --> when...
101
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
0
SCREAMING_SNAKE_CASE_ = {str(digit): digit**5 for digit in range(1_0)} def __lowercase ( _SCREAMING_SNAKE_CASE ) -> Union[str, Any]: '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_A ) ) def __lowercase ( )...
296
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
"""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 fro...
332
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( _A = 3 ): if isinstance(_A , _A ): raise TypeError('''number of qubits must be a integer.''' ) if number_of_qubits <= 0: ...
278
0
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : List[str] ) -> Tuple: """simple docstring""" lowerCAmelCase_ : str = [int(_A ) for i in ip_va_address.split('.' ) if i.isdigit()] return len(_A ) == 4 and al...
224
from functools import lru_cache @lru_cache def __UpperCamelCase ( _A ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod() ...
278
0
'''simple docstring''' from math import loga def SCREAMING_SNAKE_CASE( __lowercase ) -> Union[str, Any]: if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(_A , _A ): raise TypeError('''Input ...
319
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _A ): lowerCAmelCase_ = 384 ...
278
0
"""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 vocab first, and then a tiny model - so the outcome is truly tiny - # all fil...
177
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __UpperCamelCase ( _A , _A ): lowerCAmelCase_ = args.log_outputs lowerCAmelCase_ = ...
278
0
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, WavaVecaFeatureExtracto...
219
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { '''nielsr/canine-s''': 2_048, } # Unicode defines 1,114,112 total “codepoints” _A = 1_114_112 # Below: Constan...
278
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_token...
4
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
0
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...
33
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): f...
278
0
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..util...
73
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
278
0
# 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 required by a...
180
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _A = logging.get_logger(__name__) class A ( __UpperCAmelCase ): def __init__( self, *UpperCamelCase__, **UpperCamelCase__ ): """simple docstring""" warnings.warn...
278
0
import numpy as np from transformers import Pipeline def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = np.max(_A , axis=-1 , keepdims=_A ) lowercase = np.exp(outputs - maxes ) return shifted_exp / shifted_exp.sum(axis=-1 , ...
101
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _A = l...
278
0
import numpy as np def __lowercase ( _SCREAMING_SNAKE_CASE ) -> Any: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowercase ( _SCREAMING_SNAKE_CASE ) -> Union[str, Any]: '''simple docstring''' return vector *...
296
def __UpperCamelCase ( _A ): if not numbers: return 0 if not isinstance(_A , (list, tuple) ) or not all( isinstance(_A , _A ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) lowerCAmelCase_ = low...
278
0
"""simple docstring""" import json import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common impo...
332
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAG...
278
0
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
224
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
'''simple docstring''' 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_c...
319
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to...
278
0
"""simple docstring""" from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @m...
177
import argparse from collections import defaultdict import yaml _A = '''docs/source/en/_toctree.yml''' def __UpperCamelCase ( _A ): lowerCAmelCase_ = defaultdict(_A ) for doc in model_doc: counts[doc["local"]] += 1 lowerCAmelCase_ = [key for k...
278
0
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __SCREAMING_SNAKE_CASE...
219
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
'''simple docstring''' import itertools import math def a_ ( lowerCamelCase : Optional[int] ): 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 multipl...
4
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 import logging logging.se...
278
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A : List[str] = logging.get_logger(__name__) __A : Tuple =...
33
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 = logging.get_logger(__name__) _A = { '''google/vit-base-patch16-224''': '''https://hu...
278
0
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_flax_common impo...
73
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCamelCase ( _A...
278
0
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def snake_case ( *snake_case__ :Optional[Any]) -> Any: if not isinstance(_A , _A): _A = list(_A) for i in range(len(_A)): ...
180
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
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 ( MaxLengthCriteria, ...
101
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
0
from __future__ import annotations SCREAMING_SNAKE_CASE_ = [True] * 1_0_0_0_0_0_1 SCREAMING_SNAKE_CASE_ = 2 while i * i <= 1_0_0_0_0_0_0: if seive[i]: for j in range(i * i, 1_0_0_0_0_0_1, i): SCREAMING_SNAKE_CASE_ = False ...
296
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class _UpperCAmelCase : def __init__( self : Optional[Any] ): __UpperCAmelCase = {} def a ( self : List[str] , _lo...
332
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( _A = 3 ): if isinstance(_A , _A ): raise TypeError('''number of qubits must be a integer.''' ) if number_of_qubits <= 0: ...
278
0
"""simple docstring""" import string def UpperCamelCase_ ( lowerCAmelCase__ : Tuple ) -> Any: """simple docstring""" lowerCAmelCase_ : List[str] = '' for i in sequence: lowerCAmelCase_ : Dict = ord(_A ) if ...
224
from functools import lru_cache @lru_cache def __UpperCamelCase ( _A ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod() ...
278
0