code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTe...
23
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
'''simple docstring''' import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() Upper...
164
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def U...
164
1
"""simple docstring""" def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase ) -> float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(f'''{price_plus_tax(1_0_0, 0.2_5) = }''') print(f'''{price_plus_tax(1...
255
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_com...
255
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
370
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance A_ : List[Any] = 637_8137.0 A_ : Dict = 635_6752.31_4245 A_ : int = 6_3_7_8_1_3_7 def snake_case_ ( lowerCAmelCase_ ,...
349
0
import os import numpy import onnx def __lowercase ( _UpperCamelCase, _UpperCamelCase ) ->List[Any]: """simple docstring""" lowercase : Optional[int] = a.name lowercase : Union[str, Any] = b.name lowercase : Optional[Any] ...
337
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase ( ) ->int: """simple docstring""" lowercase : Tuple = HfArgumentParser(_UpperCamelCase ) lowercase : List[str] = parser.parse_args_in...
337
1
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, ...
126
"""simple docstring""" 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 ...
126
1
import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE : List[Any] = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE : int = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) ...
21
"""simple docstring""" from collections.abc import Iterable from typing import Generic, TypeVar lowercase__ = TypeVar("""_T""") class __lowerCamelCase ( Generic[_T] ): '''simple docstring''' def __init__( self : Optional[int] , a_ : Iterable[_T] | None = No...
241
0
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class lowerCamelCase_ ( yaml.SafeLoader ): '''simple docstring''' def SCREAMING_SNAKE_CASE__ ( self : Any , __lowerCamelCase : Opti...
256
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGenerat...
256
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _SCREAMING_SNAKE_CASE : int = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2StructConfig''', ...
314
def UpperCAmelCase_ ( _A = 1_00_00_00 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = set(range(3 , _A , 2 ) ) primes.add(2 ) for p in range(3 , _A , 2 ): if p not in primes: continue primes.diff...
314
1
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _UpperCAmelCase : '''simple docstring''' lowerCamelCase__ =42 lowerCamelCase__ =None lowerCamelCase__ =None SCREAMI...
24
"""simple docstring""" def lowercase ( ) ->int: """simple docstring""" return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(_snake_case , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": p...
24
1
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATA...
340
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_ = '''src/transformers''' a_ = '''docs/source/en/tasks''' def ...
340
1
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 _UpperCAmelCase ( ...
207
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a_ ( lowerCAmelCase_ : Dict[str, torch.Tensor] ): __lowerCAmelCase = [] __lowerCAmelCase = [] __lowerCAm...
207
1
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root o...
15
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar UpperCAmelCase : Dict =TypeVar("""T""") class _lowercase (Generic[T] ): '''simple docstring''' def __init__( self , snake_case__ ): ...
128
0
"""simple docstring""" class lowerCamelCase__ : def __init__( self ,A ,A ,A ): UpperCAmelCase = None UpperCAmelCase = None UpperCAmelCase = graph self._normalize_graph(A ,A ) UpperCAmelCase =...
362
"""simple docstring""" from __future__ import annotations def _a ( _snake_case , _snake_case = None , _snake_case = None ): """simple docstring""" if start is None: UpperCAmelCase = 0 if end is None: UpperCAmelCase =...
234
0
def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" return 1 if input_a == input_a else 0 def UpperCAmelCase ( ) -> None: """simple docstring""" assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate...
15
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ) from transformers.testing...
325
0
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( __UpperCamelCase : List[str] ,__UpperCamelCase : str ,__UpperCa...
362
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGE...
329
0
'''simple docstring''' import os from pathlib import Path def __magic_name__ ( ) -> str: '''simple docstring''' from torch.utils.cpp_extension import load snake_case_ = Path(__UpperCAmelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' snak...
56
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_availabl...
56
1
'''simple docstring''' def snake_case__ ( lowerCamelCase__ : list ) -> list: if len(lowerCamelCase__ ) <= 1: return lst A_ : Any = 1 while i < len(lowerCamelCase__ ): if lst[i - 1] <= lst[i]: i += 1 ...
370
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_co...
4
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_...
63
'''simple docstring''' import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def _lowerCamelCase ( lowercase : Union[str, Any] , lowercase : int , lowerc...
63
1
"""simple docstring""" _snake_case = 8.31_44_62 # Unit - J mol-1 K-1 def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: raise ValueE...
324
"""simple docstring""" import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class UpperCamelCase ( snake_case_ ): def __init__( self : Union[str, ...
324
1
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pi...
84
'''simple docstring''' from math import isqrt def UpperCAmelCase__ ( UpperCAmelCase_ : int ) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(UpperCAmelCase_ ) + 1 ) ) def UpperCAmelCase__ ( UpperCAmelCase_ : int = 1...
185
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : Optional[Any] = { 'configuration_time_series_transformer': [ 'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimeSeriesTransformerCo...
350
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : int = logging.get_logger(__name__) UpperCAmelCase : Union[str, Any] = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/reso...
331
0
from math import factorial def _lowerCamelCase( lowercase__ = 1_0_0 ) -> int: '''simple docstring''' return sum(int(a_ ) for x in str(factorial(a_ ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
295
'''simple docstring''' from typing import TYPE_CHECKING from ..utils import _LazyModule UpperCamelCase__ : int = { 'config': [ 'EXTERNAL_DATA_FORMAT_SIZE_LIMIT', 'OnnxConfig', 'OnnxConfigWithPast', 'OnnxSeq2SeqConfigWithPast', ...
344
0
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def UpperCamelCase_ ( A__ : list[list[float]] ): '''simple docstring''' lowerCAmelCase_ : List[str] = Decimal # C...
350
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __snake_case ( unittest.TestCase): """simple docstring""" def __lowercase ( self : Tuple ) -> Dict: ...
89
0
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_transformers.convert_switch...
227
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Dict = logging.get_logger(__name__) __A : Union[str, Any] = { '''facebook/vit-mae-base''': '''https://huggingface.co/facebook/vit-mae-base/resolve/ma...
33
0
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokeni...
166
"""simple docstring""" import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): impo...
166
1
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline _snake_case = version.parse(version.parse(torch.__version__).base_v...
36
'''simple docstring''' import math class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Union[str, Any] , UpperCamelCase__ : Optional[Any]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" ...
28
0
# Function to print upper half of diamond (pyramid) def A__ ( UpperCAmelCase_ ): for i in range(0 , UpperCamelCase__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(' ' , end='' ) for _ in range(0 , ...
363
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def A__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ): if not arr: return None, None, 0 ...
236
0
def A_ ( _lowerCAmelCase = 1000 ) -> int: UpperCamelCase , UpperCamelCase : Any = 1, 1 UpperCamelCase : Dict = [] for i in range(1 , n + 1 ): UpperCamelCase : Union[str, Any] = prev_numerator + 2 * prev_denominator UpperCamelCase : ...
52
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, ...
128
0
import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax...
350
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig'...
188
0
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def lowerCAmelCase_ (lowerCAmelCase__: Tuple , lowerCAmelCase__: str , lowerCAmelCase__: int ): """simple docstring""" ...
147
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTo...
147
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ = { "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Autoform...
83
'''simple docstring''' import requests lowercase__ = "" # <-- Put your OpenWeatherMap appid here! lowercase__ = "https://api.openweathermap.org/data/2.5/" def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = "Chicago" , SCREAMING_SNAKE_CASE__ = APPID ) -> dict: '''sim...
83
1
from math import factorial, radians def __UpperCamelCase ( _A , _A = 18 , _A = 10 ): lowerCAmelCase_ = angle_in_degrees - ((angle_in_degrees // 3_6_0.0) * 3_6_0.0) # Converting from degrees to radians lowerCAmelCase_ = radians(_A ) lowerCAmelCase_ ...
278
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
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'kssteven/ibert-roberta-base': 'https:/...
222
'''simple docstring''' import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py a_ = 'src/diffusers' # Matches is_xxx_available() a_ = re.compile(R'is\_([a-z_]*)_avail...
222
1
from __future__ import annotations from collections.abc import Callable lowercase = list[list[float | int]] def __UpperCAmelCase ( a_ , a_): snake_case_ = len(a_) snake_case_ = [[0 for _ in range(size + 1)] for _ in range(a_)] snake_...
178
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 UpperCamelCase_ ( ...
178
1
"""simple docstring""" def lowerCamelCase__ ( __snake_case = 1_00 ) -> int: """simple docstring""" _UpperCamelCase = set() _UpperCamelCase = 0 _UpperCamelCase = n + 1 # maximum limit for a in range(2, ...
100
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutpu...
100
1
import enum import shutil import sys snake_case__ , snake_case__ : List[str] = shutil.get_terminal_size() snake_case__ : Tuple = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class A_ ( enum.Enum ): lowerCAmel...
117
def _a ( lowerCamelCase: int = 2_00 ) -> int: '''simple docstring''' __A = [1, 2, 5, 10, 20, 50, 1_00, 2_00] __A = [0] * (pence + 1) __A = 1 # base case: 1 way to make 0 pence for coin in coins: ...
117
1
"""simple docstring""" import numpy as np def __lowercase ( __lowerCAmelCase : np.array ): return 1 / (1 + np.exp(-vector )) def __lowercase ( __lowerCAmelCase : np.array ): return vector * sigmoid(1.702 * vector ) ...
368
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] , __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : int ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction =...
109
0
from math import log from scipy.constants import Boltzmann, physical_constants lowercase : Dict = 3_0_0 # TEMPERATURE (unit = K) def A_ ( A__ , A__ , A__ , ) -> float: if donor_conc <= 0: raise ValueError('Donor concentration should be positive'...
99
"""simple docstring""" from __future__ import annotations def a__ ( __SCREAMING_SNAKE_CASE ) -> bool: __lowerCAmelCase: Tuple = str(__SCREAMING_SNAKE_CASE ) return len(__SCREAMING_SNAKE_CASE ) == 9 and set(__SCREAMING_SNAKE_CASE ) == set("123456789" ) ...
217
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType lo...
171
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available ...
171
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import 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_tensor, random_attentio...
185
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import ...
185
1
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : int = logging.get_logger(__name__) _snake_case : List[Any] = { 'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-t...
363
from collections.abc import Sequence def a_ ( lowerCAmelCase_ : Sequence[float], lowerCAmelCase_ : bool = False ): if not arr: return 0 __lowerCAmelCase = 0 if allow_empty_subarrays else float('-inf' ) __lowerCAmelCase = 0.0 for n...
207
0
'''simple docstring''' def _A ( snake_case = 50_00_00_00 ) -> str: _lowercase : List[str] = set() _lowercase : Union[str, Any] = int((limit - 24) ** (1 / 2) ) _lowercase : Dict = set(range(3 , prime_square_limit + 1 , 2 ) ...
250
"""simple docstring""" def A_ ( ): """simple docstring""" _a = [] _a = 1 while len(_lowerCAmelCase ) < 1e6: constant.append(str(_lowerCAmelCase ) ) i += 1 _a = ''''''.join(_lowerCAmelCase ) return ( int(...
320
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow fro...
361
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase = False class A ( unittest.TestCase ): pass @...
304
0
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class A__ ( _lowerCamelCase): # to overwrite at feature extractactor specif...
86
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : Tuple = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __lowerCAmelCase (_UpperCamelCase = 100 ): __lowerCAmelCase : Optional[int] = 1 __low...
86
1
# Lint as: python3 import itertools import os import re __UpperCAmelCase = re.compile(R'([A-Z]+)([A-Z][a-z])') __UpperCAmelCase = re.compile(R'([a-z\d])([A-Z])') __UpperCAmelCase = re.compile(R'(?<!_)_(?!_)') __UpperCAmelCase = r...
145
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_ber...
145
1
"""simple docstring""" from __future__ import annotations def a__ ( __SCREAMING_SNAKE_CASE ) -> bool: return len(set(__SCREAMING_SNAKE_CASE ) ) == len(__SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest.testmod()
217
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditio...
217
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_...
368
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated SCREAMING_SNAKE_CASE__ : Tuple = collections.namedtuple("_Datasets...
339
0
from __future__ import annotations def UpperCAmelCase_ ( __snake_case ) -> list[int]: """simple docstring""" if len(__snake_case ) == 0: return array _lowercase , _lowercase =min(__snake_case ), max(__snake_case ) # Compute the variables _...
5
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class lowerCamelCase__ ( nn.Module): def __init__(self , UpperCAmelCase = 1_6 , UpperCAmelCase = 8_8 , UpperCAmelCase = None , UpperCAmelCase ...
5
1
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class lowerCamelCase__( UpperCamelCase__): def __init__( self: List[str] , UpperCamelCase_: List[str] , UpperCamelCase_: Tuple , UpperCamelCase_: Optional[An...
367
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState ...
29
0
from ....utils import logging __lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase_ ( _A ): '''simple docstring''' def __init__( self : Optional[Any] , UpperCamelCase__ : Optional[int] , UpperCamel...
88
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @...
88
1
'''simple docstring''' import random from typing import Any def __lowerCamelCase ( _lowercase ) -> list[Any]: for _ in range(len(_lowercase ) ): UpperCAmelCase : Union[str, Any] = random.randint(0 , len(_lowercase ) - 1 ) UpperCAmel...
338
'''simple docstring''' def __lowerCamelCase ( _lowercase ) -> int: UpperCAmelCase : List[str] = 0 while num > 0: digit_sum += num % 1_0 num //= 1_0 return digit_sum def __lowerCamelCase ( _lowercase = 1_0_0 ) -> int...
338
1
"""simple docstring""" 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""": 2048, } # Unicode defines 1,114,112 total “codepoints” a_ = 1114112 # Be...
179
"""simple docstring""" import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inpu...
179
1
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowerCamelCase__ = "%20".join(argv[1:]) if len(argv) > 1 else quote(str(input("Search...
310
"""simple docstring""" import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem lowerCamelCase__ = importlib.util.find_spec("s3fs") is not None if _has_safs: from .sa...
310
1
def a ( _UpperCAmelCase : int ): '''simple docstring''' __UpperCAmelCase : Any = abs(_UpperCAmelCase ) __UpperCAmelCase : Tuple = 0 while n > 0: res += n % 10 n //= 10 return res def ...
226
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def a ( _UpperCAmelCase : Tuple , _UpperCAmelCase : Optional[int] ): '''simple do...
226
1
import math import qiskit def A ( _lowercase = 1 , _lowercase = 1 , _lowercase = 1 ) -> qiskit.result.counts.Counts: if ( isinstance(lowercase__ , lowercase__ ) or isinstance(lowercase__ , lowercase__ ) or isinstance(lowercase__ ...
356
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder ...
258
0
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.confi...
207
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
207
1
"""simple docstring""" import os def __lowercase ( _a = "input.txt" ): with open(os.path.join(os.path.dirname(_a ) , _a ) ) as input_file: snake_case_ : Tuple = [ [int(_a ) for element in line.split(''',''' )] for line in input_file.rea...
354
"""simple docstring""" import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_uti...
155
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __snake...
20
'''simple docstring''' import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class _a ( unittest.TestCase ...
251
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : str = logging.get_logger(__name__) _lowerCamelCase : Dict = { '''facebook/...
365
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : Any = {'...
206
0
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def SCREAMING_SNAKE_CASE_ ( __A : list , __A : list , __A : list , __A : list , __A : li...
32
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def...
74
0
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters lowerCAmelCase__ : List[Any] =(720, 1280) # Height, Width lowerCAmelCase__ : Union[str, Any] =(0.4, 0.6) # if height or width lower than this scale, drop it. lowerCAme...
118
from collections import deque from .hash_table import HashTable class UpperCAmelCase_ ( UpperCamelCase_ ): '''simple docstring''' def __init__( self , *_A , **_A ): '''simple docstring''' super().__init__(*_A , **_A ) ...
118
1
"""simple docstring""" 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_uti...
46
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ...
46
1
'''simple docstring''' def lowercase__( __UpperCamelCase: int ,__UpperCamelCase: int ): """simple docstring""" SCREAMING_SNAKE_CASE : int = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): SCREA...
246
'''simple docstring''' from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...
246
1
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore __UpperCamelCase = namedtuple('''covid_data''', '''cases deaths recovered''') def lowercase (SCREAMING_SNAKE_CASE_ : List[Any] = "https://www.worldometers.info/c...
113
from typing import Any class __lowerCAmelCase : def __init__( self : List[Any] , snake_case__ : Any ): """simple docstring""" _UpperCAmelCase = data _UpperCAmelCase = None class __lowerCAmelCas...
133
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_ou...
363
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _UpperCAmelCase ( __snake_case ): '''simple docstring''' lowerCamelCase__ =['image_processor', 'tokenizer'] lowerCamelCase__ ...
24
0
def __lowercase ( _A ) -> str: SCREAMING_SNAKE_CASE : int = 0 for ch in input_str: SCREAMING_SNAKE_CASE : Any = ord(_A ) SCREAMING_SNAKE_CASE : List[str] = pow(2 , _A ) # If we al...
245
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__: Dict = logging.get_logger(__name__) __magic_name__: List[Any] ...
342
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a__ : int = { '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', '''MegaOnnxConfig'''], } try: if not is_torch_a...
19
from math import pi, sqrt, tan def UpperCAmelCase_( a__ ): """simple docstring""" if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def UpperCAmelCase_( a__ , a__ , a__ ): ""...
19
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase_ = { """configuration_tapas""": ["""TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TapasConfig"""], """tokenization_tapas""": ["""Tapa...
58
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils imp...
99
0
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.trai...
369
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> bool: """simple docstring""" snake_case__ : Optional[int] = len(__lowerCAmelCase ) + 1 snake_case__ : Tuple = len(__lowerCAmelCase ) + 1 # dp is a 2d matrix where d...
44
0
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): ...
84
"""simple docstring""" import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="""session""" )...
84
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart impor...
72
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class ...
72
1
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mixin...
5
# flake8: noqa # Lint as: python3 UpperCAmelCase__ = [ '''VerificationMode''', '''Version''', '''disable_progress_bar''', '''enable_progress_bar''', '''is_progress_bar_enabled''', '''experimental''', ] from .info_utils import VerificationMode from .logging import disable_progress_ba...
5
1
'''simple docstring''' def snake_case__ ( lowerCamelCase__ : list[list[int]] , lowerCamelCase__ : int , lowerCamelCase__ : int , lowerCamelCase__ : set ) -> int: A_ ,A_ : Optional[Any] = len(lowerCamelCase__ ), len(...
4
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_co...
4
1
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda fr...
12
import numpy as np def UpperCAmelCase ( a_ , a_ , a_ = 1E-12 , a_ = 1_0_0 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(a_ )[0] == np.shape(a_ )[1] # Ensure proper dimensionality. assert np.shape(a_ )[0] == np.shape(a_ )[0] ...
15
0
"""simple docstring""" # 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/LICE...
163
"""simple docstring""" import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected" , [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10, "ma...
163
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def _UpperCamelCase ( lowercase__ ): __SCREAMING_SNAKE_CASE : List[str] = {} __SCREAMING_SNAKE_CASE : Optional[Any] = job['''started_at'''] __SCR...
9
"""simple docstring""" def lowercase ( A_ )-> str: '''simple docstring''' if isinstance(A_ , A_ ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(A_ , A_ ): raise TypeError("'str' obj...
40
0
"""simple docstring""" import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_av...
361
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __a ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE_ = ['image_processor', 'tokenizer'] SCREAMING_SNAKE_CASE_ ...
157
0
"""simple docstring""" from PIL import Image def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(lowerCamelCase ) -> int: return int(1_2_8 + factor * (c - 1_2_8) )...
98
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table import...
186
0
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassificatio...
348
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __A = { "facebook/mask2former-swin-small-coco-instance": ( "https://huggingface.co/facebook/mask2former-swin-smal...
348
1
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class _lowerCAmelCase...
17
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
336
0
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__ : """simple docstring""" __magic_name__ = 42 __magic_name__ = ...
25
'''simple docstring''' def lowercase (): """simple docstring""" _lowerCAmelCase : Optional[int] = [3_1, 2_8, 3_1, 3_0, 3_1, 3_0, 3_1, 3_1, 3_0, 3_1, 3_0, 3_1] _lowerCAmelCase : int = 6 _...
25
1
"""simple docstring""" from __future__ import annotations def lowercase_ ( _UpperCAmelCase ): """simple docstring""" if len(_UpperCAmelCase ) == 0: return [] A_ , A_ : Optional[int] = min(_UpperCAmelCase ), max(_UpperCAmelCase ) ...
167
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Any = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', '...
167
1
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum ...
307
import torch from torch import nn class A__ ( nn.Module ): def __init__( self : Optional[int] , a : Union[str, Any] , a : str , a : str , a : List[Any] , a : List[Any]=1 , a : Tuple=False ): ...
307
1
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py __lowerCAmelCase : Optional[int] ='src/diffusers' # Matches is_xxx_available() __lowerCAmelCase : str =re.compile(r'is\_([a-z_]*)_...
9
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils imp...
148
0
def SCREAMING_SNAKE_CASE__ ( ) -> Tuple: snake_case : Any = 0 for i in range(1 ,1001 ): total += i**i return str(lowercase )[-10:] if __name__ == "__main__": print(solution())
176
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[int] = logging.get_logger(__name__) lowerCamelCase : Tuple = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-research/efficientformer...
176
1
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : List[Any] = log...
222
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Union[str, Any] = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBlipQFor...
222
1
from typing import Any class __lowerCAmelCase : def __init__( self , lowerCAmelCase__ ) -> str: '''simple docstring''' a__ : Optional[Any] =data a__ : List[Any] =None class __lo...
354
def _A ( SCREAMING_SNAKE_CASE : int = 1 , SCREAMING_SNAKE_CASE : int = 1_000 ): """simple docstring""" a__ : Any =1 a__ : Any =0 for divide_by_number in range(SCREAMING_SNAKE_CASE , digit + 1 ): a__ : list[int] =[] a_...
148
0
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" __A = current_set.copy() for row_index, row in enumerate(__UpperCamelCase ): __A = row[0] for column_index, column in enumerate(__UpperCamelCase ): if magnitude == 0:...
266
"""simple docstring""" from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowercase_ = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n ...
266
1
from __future__ import annotations from typing import TypedDict class lowerCamelCase__ ( _a ): _lowerCAmelCase = 42 _lowerCAmelCase = 42 def __lowerCamelCase ( __magic_name__ : str ): if not isinstance(__magic_name__ , __magic_name__ ): ...
42
import os def __lowerCamelCase ( __magic_name__ : str = "input.txt" ): with open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) ) as input_file: a__: str =[ [int(__magic_name__ ) for element in line.split("," )] ...
42
1
'''simple docstring''' from functools import reduce a_ = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' ...
152
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, require...
19
0
from __future__ import annotations def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> bool: lowercase : Union[str, Any] = get_failure_array(__snake_case ) # 2) Step through text searching for pattern lowercase : ...
364
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingface_...
285
0
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase = loggin...
89
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def lowercase ( A_ )-> List[str]: '''simple docstring''' a , a : int = analyze_text(__a ) a : Optional[int]...
350
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.co...
226
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils ...
201
'''simple docstring''' a_ : str = """ # 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 """ a_ : Any...
55
0
"""simple docstring""" import os def _a ( ): """simple docstring""" with open(os.path.dirname(_snake_case ) + """/p022_names.txt""" ) as file: UpperCAmelCase = str(file.readlines()[0] ) UpperCAmelCase = names.replace(...
234
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _UpperCamelCase = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn"...
234
1
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _a ( lowerCamelCase: Optional[int] ) -> Dict: '''simple docstring''' __A = Sw...
117
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils im...
36
0
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup _snake_case = logging.get_logger(__name__) class lowerCAmelCase ...
357
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDC...
201
0
'''simple docstring''' from __future__ import annotations import os from typing import Any import requests _UpperCamelCase = '''https://api.github.com''' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user _UpperCamelCase ...
208
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ......
70
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase = {'''configuration_xglm''': ['''XGLM_PRETRAI...
352
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, D...
103
0