code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from scipy.stats import pearsonr import datasets lowerCamelCase_ = ''' Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on t...
418
def lowercase ( _lowerCAmelCase , _lowerCAmelCase ): UpperCAmelCase__ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowercase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): UpperCAmelCase__ = 0 while...
392
0
"""simple docstring""" from __future__ import annotations import math def _A ( _a : int ): """simple docstring""" if num <= 0: A = f'{num}: Invalid input, please enter a positive integer.' raise ValueError(_a ...
255
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger UpperCAmelCase =get_logger(__name__) UpperCAmelCase =R"\n Args:\n input_ids (`jnp.ndarray` of...
255
1
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testin...
8
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class __snake_case ( _SCREAMING_SNAKE_CASE ): ...
388
0
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A_ ( a_ ): _SCREAMING_SNAKE_CASE ...
525
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() clas...
525
1
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 ...
149
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase ( __a , unittest.TestCase ): '''simple docstring''' _A : Un...
149
1
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effic...
664
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determi...
664
1
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken lo...
691
def lowerCamelCase( a__ ,a__): return int((input_a, input_a).count(0) == 0) def lowerCamelCase( ): assert and_gate(0 ,0) == 0 assert and_gate(0 ,1) == 0 assert and_gate(1 ,0) == 0 assert and_gate(1 ,1) == 1 if __name__ == "__main__": test_and_gate(...
691
1
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset from utils import logger class _A ( _UpperCAmelCase ): """simple docstring""" def __init__( self : Any , A_ : Union[str, Any] , A_ :...
93
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL __lowercase : int = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") ...
93
1
def UpperCAmelCase ( a_ , a_ , a_ ) -> Optional[Any]: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__a , n - 1 , __a ) * a) % mod else: __A = binary_exponentiation(_...
55
from ...configuration_utils import PretrainedConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''', '''funnel-transformer/small-b...
14
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import require_tensorflow_text, require_t...
720
import os from datetime import datetime as dt from github import Github lowerCamelCase_ = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '''wip''', ] def __magic_name__ ( ...
86
0
'''simple docstring''' def lowercase__( __UpperCamelCase: int ,__UpperCamelCase: int ): """simple docstring""" if number < 0 or shift_amount < 0: raise ValueError('both inputs must be positive integers' ) SCREAMING_SNAKE_CASE : ...
28
'''simple docstring''' import inspect import unittest from transformers import MobileViTConfig 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_configura...
28
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging _snake_case : Tuple = logging.get_logger(__name__) _snake_case : str = { 'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/res...
717
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports _snake_case : List[str] = '\nimport os\n' _snake_case : Dict = '\ndef foo():\n import os\n return False\n' _snake_case : List[Any] =...
377
0
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor,...
629
from typing import TYPE_CHECKING from ...utils import _LazyModule __lowerCamelCase : str = {"""tokenization_byt5""": ["""ByT5Tokenizer"""]} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys __lowerCamelCase : List[str] = _LazyModule(__name__, glo...
629
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCas...
549
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class A__ : def __init__( self ): __lowerCAmelCase : Any = {} def __lowerCamelCase ( self , _SCREAMING_SNAKE_CASE ): __lowerCAmelCase : D...
549
1
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, ...
53
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _UpperCAmelCase ( unittest.TestCase ): """simple docstring""" def lowercase ( self : Union[str, Any] ) -> List[str]: __lowerCAmelCase = ...
53
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A( SCREAMING_SNAKE_CASE__ ): """simple docstring""" SCREAMING_SNAKE_CASE__ = """Speech2TextFeatureExtractor""" SCREAMING_SNAKE_CASE__ = """Speech2TextTokenizer""" ...
719
from __future__ import annotations from typing import TypedDict class __A( __lowerCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE__ = 42 SCREAMING_SNAKE_CASE__ = 42 def __magic_name__ ( __a : str ): '''simple docstring''' if not...
86
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel @requi...
699
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.uti...
699
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A : Dict = {"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeiTConfig""", """DeiTOnnxCo...
700
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.tes...
450
0
"""simple docstring""" import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_...
308
"""simple docstring""" def lowercase__ ( lowerCamelCase : list , lowerCamelCase : int = 0 ) -> list: lowerCAmelCase__ : List[Any] = length or len(lowerCamelCase ) lowerCAmelCase__ : Optional[Any] = False for i in...
308
1
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class snake_case : def __init__(self , SCREAMING_SNAKE_CASE_ ): """simple docstring"""...
628
"""simple docstring""" import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __lowercase ): UpperCAmelCase__ = (DDIMParallelScheduler,) UpperCAmelCase__ = (('''eta''', 0.0), ('''nu...
628
1
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from .....
363
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAvailable() e...
513
0
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( __A , __A ) -> str: # Checks if the entire collection has been sorted if len(lowerCAmelCase__ ) <= 1 or n <= 1: return insert_next(lowerCAmelCase__ , n - 1 ) rec_insertion_...
721
'''simple docstring''' import math def SCREAMING_SNAKE_CASE__ ( __A , __A ) -> float: if ( not isinstance(__A , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('power_factor must be a valid float value between -1 and 1.' ...
542
0
"""simple docstring""" # flake8: noqa # Lint as: python3 a_ = [ 'VerificationMode', 'Version', 'disable_progress_bar', 'enable_progress_bar', 'is_progress_bar_enabled', 'experimental', ] from .info_utils import VerificationMode from .logging import di...
76
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def A__ ( _UpperCAmelCase : int , _UpperCAmelCase : int , _UpperCAmelCase : int , _UpperCAmelCase : int , ...
150
"""simple docstring""" from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class SCREAMING_SNAKE_CASE_ ( _lowercase): ...
150
1
'''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_t...
42
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.test_...
321
0
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, Pi...
707
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple...
658
0
import logging import os import threading import time try: import warnings except ImportError: _lowerCAmelCase: Optional[int] = None try: import msvcrt except ImportError: _lowerCAmelCase: List[str] = None try: import fcntl except ImportError: _lowerCAmelCase: Dict ...
20
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import T...
611
0
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder snake_case__ : int = datasets.utils.logging.get_logger(__name__) class snake_case_( folder_based_builder.FolderBased...
704
"""simple docstring""" class snake_case_: def __init__( self : Union[str, Any] , UpperCamelCase_ : str ): lowerCAmelCase : Dict = val lowerCAmelCase : str = None lowerCAmelCase : Dict = None def ...
637
0
'''simple docstring''' import torch def snake_case_ ( ): '''simple docstring''' if torch.cuda.is_available(): _snake_case = torch.cuda.device_count() else: _snake_case = 0 print(f'''Successfully ran on {num_gpus} GPUs''' ) if __name__ == "__main__": ...
672
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from ut...
355
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __a : Optional[int] = '\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification}...
709
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __a : str = argparse.ArgumentParser() parser.add_argument('''--dump_path''', default=N...
298
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ = {'configuration_opt': ['OPT_PRETRAINED_...
34
from __future__ import annotations from typing import Any class UpperCAmelCase__ : '''simple docstring''' def __init__( self : Dict , UpperCamelCase : int = 6 ): """simple docstring""" _lowercase : Node | None ...
322
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = r"\n Args:\n input_ids (`torch.L...
129
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __lowerCAmelCase ...
129
1
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 Batch...
27
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor...
27
1
import math def UpperCAmelCase_ ( snake_case__ , snake_case__ ) -> float: """simple docstring""" return math.pow(_lowerCAmelCase , 2 ) - a def UpperCAmelCase_ ( snake_case__ ) -> float: """simple docstring""" return 2 * x ...
716
def UpperCAmelCase_ ( snake_case__ , snake_case__ ) -> float: """simple docstring""" _validate_point(snake_case__ ) _validate_point(snake_case__ ) if len(snake_case__ ) != len(snake_case__ ): raise ValueError('Both points must be in the same n-dimens...
604
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a ( un...
409
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import Autoencod...
409
1
"""simple docstring""" from __future__ import annotations import numpy as np def lowercase ( a__ : list[float] ) -> int: return np.maximum(0 , a__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
342
"""simple docstring""" from typing import Any import numpy as np def lowercase ( a__ : np.ndarray ) -> bool: return np.array_equal(a__ , matrix.conjugate().T ) def lowercase ( a__ : np.ndarray , a__ : np.ndarray ) -> Any: _UpperCamelCase = v.conjuga...
342
1
"""simple docstring""" import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from ...
58
"""simple docstring""" 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 im...
259
0
from __future__ import annotations def a__ ( __UpperCamelCase ): # This function is recursive SCREAMING_SNAKE_CASE_ = len(__A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if array_length <= 1: return array ...
715
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available A : Dict = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: ...
356
0
"""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, CLIPTextModel, C...
510
"""simple docstring""" from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline _snake_case = ...
510
1
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCamelCase : '''simple docstring''' l...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise OptionalDepende...
109
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from t...
109
1
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def __a ( __UpperCAmelCase ): return x + 2 class __UpperCamelCase ( unittest.TestCase ): """simple docstring""" def _UpperCAmelCase ( sel...
719
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ : Any = {'configuration_xglm': ['XGLM_PRETRAINED_CONFIG...
148
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( ...
42
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
200
0
"""simple docstring""" def _snake_case ( snake_case__ : str , snake_case__ : Any , snake_case__ : str=False ): if isinstance(snake_case__ , snake_case__ ) and isinstance(snake_case__ , snake_case__ ): A = len(set_a.intersection(snake_case__ ...
22
"""simple docstring""" from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.sch...
22
1
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, ...
586
"""simple docstring""" from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: if not postfix_notation: return 0 lowercase__: int = {'''+''', '''-''', '''*''', '''/'''} lowercase__: list[Any] = [] for token in p...
586
1
"""simple docstring""" from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( 'stable diffusion controlnet', '0.22.0', 'Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffu...
716
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import D...
244
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, ...
54
'''simple docstring''' import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def _snake_case ( _SCREAMING_SNAKE_CASE...
433
0
"""simple docstring""" import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _A ( __lowercase ): """simple docstring""" return input_array.reshape((input_array.size, 1) ) ...
258
"""simple docstring""" from math import sqrt def _A ( __lowercase ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all e...
258
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
44
"""simple docstring""" from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = '''T5Config''' class Upper...
95
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE_ ( _lowercase): '''simple docstring''' __magic_name__ : str = '''SpeechT5FeatureExtractor''' __magic_name__ : List[Any] = '''Speec...
720
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
150
0
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ......
308
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_pro...
308
1
import json import sys def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> str: with open(lowerCamelCase__ , encoding='utf-8' ) as f: __lowerCamelCase : str = json.load(lowerCamelCase__ ) __lowerCamelCase : ...
337
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class A_ ( SCREAMING_SNAKE_CASE ): _UpperCAmelCase : int = (PNDMScheduler,) _UpperCAmelCase : str = (('''num_inference_steps'''...
337
1
'''simple docstring''' def __a ( lowerCAmelCase__ : str ): a__ : Tuple = 0 # if input_string is "aba" than new_input_string become "a|b|a" a__ : str = '''''' a__ : int = '''''' # append each character + "|" in new_strin...
688
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelera...
688
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __SCREAMING_SNAKE_CASE : Optional[int] = { 'configuration_conditional_detr': [ 'CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP'...
2
"""simple docstring""" import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_visio...
2
1
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins _UpperCamelCase : Union[str, Any] =["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def lowerCamelCase_ ( A_ , A_ ): # Mark tests as "unit" by default if not ma...
316
'''simple docstring''' import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC _UpperCamelCase : Union[str, Any] =parse(importlib.metadata.version("torch")) def lowerCamelCase_ ( A_ , A_ ...
316
1
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaForCo...
704
"""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_tokenize...
282
0
"""simple docstring""" from math import ceil def A ( snake_case__ , snake_case__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = list(range(0 , _UpperCamelCase ) ) SCREAMING_SNAKE_CASE__ = [item for sublist in list(dev...
196
"""simple docstring""" import os from datetime import datetime as dt from github import Github A__ : Tuple = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def _lowerCAmelCase ( ): ...
353
0
from ...processing_utils import ProcessorMixin class __lowercase( SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase_ = '''SpeechT5FeatureExtractor''' UpperCamelCase_ = '''SpeechT5Tokenizer''' def __init__( self : Opti...
585
import requests from bsa import BeautifulSoup def _a ( __SCREAMING_SNAKE_CASE : str = "https://www.worldometers.info/coronavirus" ): """simple docstring""" _lowerCAmelCase = BeautifulSoup(requests.get(__SCREAMING_SNAKE_CASE ).text , 'html.parser' ) _lowerC...
585
1
"""simple docstring""" import argparse import json 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 ...
388
import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterM...
137
0
# 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 = re.compile(r'(_{2,})') __UpperCAmelCase ...
503
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, lo...
503
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: if not is_torch_available(): raise OptionalDe...
187
from __future__ import annotations def a(lowercase__ , lowercase__ , lowercase__ , lowercase__ ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): snake_case_ , snake_case_ = ...
187
1
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowercase ( __UpperCamelCase , __UpperCam...
715
"""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_tokenizers, require_vi...
190
0
from ...processing_utils import ProcessorMixin class __a ( __UpperCamelCase ): __snake_case : Dict = ["""image_processor""", """feature_extractor"""] __snake_case : Union[str, Any] = """TvltImageProcessor""" __snake_case : int = """TvltFeatureExtractor""" ...
600
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class __a ( __UpperCamelCase ): __snake_cas...
600
1
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> str: return "".join(chr(ord(lowerCAmelCase__ ) - 32 ) if '''a''' <= char <= '''z''' else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
720
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> float: if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) UpperCAmelCase__ : Tuple = sum(lowerCAmelCase__ ) / len(lowerCAmelCase__ ) # Calculate the average...
312
0
"""simple docstring""" _UpperCamelCase : Any = {str(digit): digit**5 for digit in range(10)} def a_ ( _lowerCAmelCase : int ): '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_lowerCAmelCase ) ) def a_ ( ): ...
599
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisio...
599
1
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" ...
451
from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase__ : Tuple = logging.get_logger(__name__) lowercase__ : Union[str, Any] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.j...
451
1
from __future__ import annotations def lowerCamelCase_ ( _lowercase , _lowercase = None , _lowercase = None , _lowercase = False , ) -> tuple[int, float, str]: __A : int = cipher_alphabet or [chr(_lowercase ) for i in range(97 , 123 ...
520
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_PRE...
520
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Any = logging.get_logger(__name__) _snake_case : List[Any] = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class ...
700
_snake_case : List[Any] = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] _snake_case : Lis...
421
0
"""simple docstring""" import inspect import re 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_config_docstrings.py lowercase__ = """src/transfor...
630
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase__ = argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) pa...
630
1
"""simple docstring""" import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __A : List[str] = logging.get_logger(__name__) def lowercase ( UpperCamelCase : Dict , UpperCamelCase : ...
595
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : List[str] = { "configuration_electra": ["ELECTRA_PR...
595
1
'''simple docstring''' from math import ceil def __UpperCamelCase ( a : int = 1001 ) ->int: snake_case = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): snake_case = 2 * i + 1 snake_case = 2 * i snake_case = total...
342
'''simple docstring''' def __UpperCamelCase ( a : Optional[int] , a : int , a : str=False ) ->List[str]: if isinstance(a , a ) and isinstance(a , a ): snake_case = len(set_a.intersection(a ) ) if alternative_unio...
342
1
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_avai...
718
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTok...
524
0
from __future__ import annotations def lowerCamelCase_ ( UpperCAmelCase__ ): """simple docstring""" if len(UpperCAmelCase__ ) == 0: return array a_ , a_ = min(UpperCAmelCase__ ), max(UpperCAmelCase__ ) # Compute ...
483
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Any =logging.get_logger(__name__) # TODO Update this A_ : List[str] ={ """facebook/esm-1b""": """http...
483
1
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 import logging loggi...
711
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import T...
688
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json", } class _SC...
256
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "facebook/s2t-small-librispeech-asr": ( "https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json" ...
256
1
_snake_case = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottametre""": """Ym""", } # Exponent o...
611
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor _snake_case = logging.get_logger(__name__) class lowerCAmelCase ( lowercase_ ): def __init__( self :Optional[int] , *_lowercase :Tuple , ...
611
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ : Optional[Any] = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise Opti...
183
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable...
84
0
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, Pat...
290
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
290
1
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "RUCAIBox/mvp": "https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json", } class __Up...
366
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __UpperCAmelCase ( lowerCAmelCase ,lowerCAmelCase ...
366
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer from .tokeni...
622
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHeads...
622
1
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer UpperCAmelCase_ : Dict = logging.get_logger...
21
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 ...test_configuration_common i...
311
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import requ...
491
"""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 _snake_case = logging.get_logger(__name__) _snake_ca...
491
1
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sentencepi...
365
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ft...
107
0
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __snake_case ( lowerCamelCase_ ): lowerCAmelCase_ = ["image_processor", "tokenizer"] lowerCAmelCase_ = "AutoImageProcessor" lo...
379
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __lowerCamelCase : List[str] = TypeVar('''KEY''') __lowerCamelCase : int = TypeVar('''VAL''') @dataclass(frozen=lowerCamelCase_ , slots=lo...
379
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json" ),...
10
from __future__ import annotations _lowerCAmelCase = [True] * 1_000_001 _lowerCAmelCase = 2 while i * i <= 1_000_000: if seive[i]: for j in range(i * i, 1_000_001, i): _lowerCAmelCase = False i += 1 def _snake_case ( __snake_case ): return seive[n...
10
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __magic_name__ : List[str] = logging.get_logger(__name__) __magic_name__ : ...
712
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __magic_name__ : Optional[Any] = logging.get_logger(__name__) __magic_name__ : Tuple = { 'google/umt5-small': 'h...
608
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, ...
623
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : List[str] = logging.get_logger(__name__) _snake_case : int = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } c...
441
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : Optional[Any] =logging.get_logger(__name__) __lowercase : Optional[int] ={ """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/co...
550
__lowercase : Dict ="""0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader imp...
550
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSampling...
348
# 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 applicab...
348
1
"""simple docstring""" from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class __magic_name__ : def __init__( self : Tuple , snake_case__ : Collection[float] | None = None ): '''simpl...
475
"""simple docstring""" import unittest import numpy as np def lowerCamelCase (a_ :np.ndarray , a_ :np.ndarray , a_ :np.ndarray , a_ :np.ndarray | None = None , ) -> np.ndarray: lowercase :str = np.shape(a_) lower...
475
1
'''simple docstring''' import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.u...
679
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() a : Optional[Any] = logging.get_logger(__name__) a : List[str] = {name: getattr(transformers, n...
679
1
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_d...
718
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestC...
166
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __UpperCamelCase ( unittest.TestCase , A__ ): def UpperCamelCase( self ): _UpperCAmelCase = load_tool('''text-classification''' ) self.to...
32
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormer...
422
0
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class __SCREAMING_SNAKE_CASE ( _a , unittest.TestCase ): snake_case : Optional[int] = ...
548
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, t...
548
1
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def _SCREAMING_SNAKE_CASE ( __snake_case : str , __snake_case : str = "cpu" , __snake_case : Union[str, None] = None ): _A = torch.load(__snake_case , map_loca...
107
'''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...
107
1
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_proces...
708
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.tra...
388
0
"""simple docstring""" import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class snake_case_ ( low...
34
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar __SCREAMING_SNAKE_CASE = TypeVar("""T""") class __snake_case ( Generic[T] ): """simple docstring""" def __init__( self :Tuple ...
388
0
from torch import nn def _UpperCAmelCase ( A ): '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError...
510
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json', } cl...
510
1
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> int: '''simple docstring''' return abs(_lowerCamelCase ) if a == 0 else greatest_common_divisor(b % a , _lowerCamelCase ) def lowerCamelCase_( _lowerCamelCase , ...
46
"""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...
46
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar UpperCAmelCase : List[str] = TypeVar('T') class lowerCamelCase (Generic[T] ): def __init__( self , lowercase__ , lowercase_...
47
'''simple docstring''' import math from numpy import inf from scipy.integrate import quad def _a ( lowerCAmelCase_ ): """simple docstring""" if num <= 0: raise ValueError('''math domain error''' ) return quad(lowerCAmelCase_ , 0 , lowerCAmelCa...
47
1