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
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward fro...
122
'''simple docstring''' import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __lowerCAmelCase = logging.get_logger(__name__) class UpperCAmelCase__ ( lowercase__ ): """simple docstring""" def __init__( self : Tuple ...
271
0
"""simple docstring""" from importlib import import_module from .logging import get_logger _a : int= get_logger(__name__) class UpperCamelCase : def __init__(self : Optional[Any] , _A : Optional[Any] , _A : List[Any]=None) -> Dict: ...
95
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor _a : Tuple= logging.get_logger(__name__) class UpperCamelCase ( lowercase ): def __init__(self : int , *_A : st...
95
1
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar __UpperCAmelCase = TypeVar("""KT""") __UpperCAmelCase = TypeVar("""VT""") class UpperCamelCase__ ( Generic[KT, VT] ): """simple docstring""" ...
323
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class lowerCamelCase : '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase_ : int , lowerCAmelCase_ : MutableSequence[float] ) ->...
134
0
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> str: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ): raise ValueError('iterations must be defined as integers' ) if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or n...
371
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """microsoft/unispeech-large-1500h-cv""": ( """https://huggingface.co/microsoft/unispeech-larg...
307
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
283
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tok...
107
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 AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def UpperCamelCase ( snake_case__ : int ) ->...
103
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class lowerCAmelCase_ ( unittest.TestCase ): UpperCAmelCase__ : Union[str, Any] = JukeboxTokenizer UpperCAmelCase__ : Optional[int] = { ...
103
1
'''simple docstring''' import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, c...
145
"""simple docstring""" from __future__ import annotations def lowercase (_lowerCAmelCase , _lowerCAmelCase ): __lowerCAmelCase = [] create_all_state(1 , _lowerCAmelCase , _lowerCAmelCase , [] , _lowerCAmelCase ) return result def lower...
301
0
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_attention_mask from ...test_pipelin...
189
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-touri...
189
1
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_avai...
95
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __lowerCAmelCase : def _lowercase ( self , lowerCAmelCase__ ) -> Optional[Any]: ...
95
1
"""simple docstring""" import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests from os.path import join # noqa: this is just for tests from os.path im...
362
"""simple docstring""" from __future__ import annotations def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): lowerCamelCase__ : list[list[int]] = [] lowerCamelCase__ : list[int] = [] lowerCamelCase__ : List[str] = ...
316
0
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to ...
14
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import...
307
0
"""simple docstring""" import os import sys _snake_case = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswer...
324
"""simple docstring""" 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...
324
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_GUIDED_IMA...
103
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version A__ : Tuple ...
103
1
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer else: S...
360
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ : Any = TypeVar("KEY") SCREAMING_SNAKE_CASE__ : Dict = TypeVar("VAL") @dataclass(frozen=__lowercase , slots=__lowercase )...
339
0
from cva import destroyAllWindows, imread, imshow, waitKey def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> Optional[int]: # getting number of pixels in the image UpperCamelCase__ , UpperCamelCase__ : Any = img.shape[0], img.shape[1] #...
189
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from...
189
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''google/bigbird-roberta-base''': '''https://hugg...
103
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_ti...
103
1
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _UpperCamelCase...
346
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class lowerCAmelCase_ ( lowerCamelCase_ ...
346
1
'''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.config import PatchingS...
21
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _lowercase : Union[str, Any] = logging.get_logger(__name__) # pylint: disable=invalid-name cla...
21
1
'''simple docstring''' import os import sys lowercase__ : Optional[int] = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, ...
324
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowercase__ : str = logging.get_logger(__name__) lowercase__ : Any = { 'SenseTime/deformable-detr': 'https://huggingface.co...
324
1
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert....
364
# 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 ...
15
0
"""simple docstring""" from math import sqrt def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' assert isinstance(lowerCAmelCase_ , lowerCAmelCase_ ) and ( number >= 0 ), "'number' must been an int and positive" __SCREAMING_SNAKE_CASE ...
54
UpperCAmelCase__ = {} def A ( _UpperCAmelCase : int , _UpperCAmelCase : int , _UpperCAmelCase : int ) -> int: '''simple docstring''' # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late ...
339
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualRe...
215
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
215
1
import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils....
103
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import Hug...
103
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmToke...
355
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case_ : List[str] = '\\n@misc{chen2021evaluating,\n title=...
236
0
def UpperCamelCase_( lowerCamelCase_ ) -> bool: _lowercase : str = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def UpperCamelCase_( lowerCamelCase_ = 5000 ) -> int: _lowercase : Optional[Any] = [(i * (3 * i - 1)) // 2 f...
21
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_( lowerCamelCase_ ) -> bool: _lowercase : int = int(number**0.5 ) return number == sq * sq def UpperCamelCase_( lowerCamelCase_ , lowerCam...
21
1
'''simple docstring''' import numpy as np def lowerCamelCase (_SCREAMING_SNAKE_CASE : np.ndarray , _SCREAMING_SNAKE_CASE : float ): return np.where(vector > 0 , _SCREAMING_SNAKE_CASE , (alpha * (np.exp(_SCREAMING_SNAKE_CASE ) - 1)) ) ...
366
'''simple docstring''' import re from filelock import FileLock try: import nltk __lowercase : Optional[Any] = True except (ImportError, ModuleNotFoundError): __lowercase : Dict = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) ...
294
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class lowerCAmelCase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self ,*__Up...
37
import math def UpperCAmelCase ( a_ , a_ = 0 , a_ = 0 ) -> list: """simple docstring""" __A = end or len(a_ ) for i in range(a_ , a_ ): __A = i __A = array[i] while temp_index != start and temp_index_value < array[temp_inde...
15
0
"""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() UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = {n...
368
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase__ = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "De...
26
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require...
215
'''simple docstring''' import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ )-...
215
1
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequence...
319
from math import sqrt def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = 0 for i in range(1 , int(sqrt(lowercase ) + 1 ) ): if n % i == 0 and i != sqrt(lowercase ): total += i + n // i elif i ==...
319
1
import string def UpperCAmelCase__ ( lowerCamelCase ): for key in range(len(string.ascii_uppercase ) ): lowercase :Any = "" for symbol in message: if symbol in string.ascii_uppercase: lowercase :Dict = string.ascii_uppercase.find(lowerCamelCase...
236
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExt...
236
1
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = {'vocab_file': 'sentencepiece.model'} a_ = { 'vocab_file': { 'go...
50
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeling_fl...
50
1
"""simple docstring""" import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt",...
247
"""simple docstring""" _snake_case = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.gi...
294
0
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, W...
28
from math import ceil def __UpperCamelCase ( lowercase__ : int = 1001 ) -> int: '''simple docstring''' lowerCAmelCase_ : List[str] = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): lowerCAmelCase_ : Optional[Any] = 2 ...
28
1
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a__( UpperCamelC...
272
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 ...
26
0
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets a : Tuple = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "...
79
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _SCREAMING_SNAKE_...
79
1
'''simple docstring''' import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRober...
319
'''simple docstring''' import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme impor...
319
1
"""simple docstring""" def _snake_case ( lowercase__ , lowercase__ ): if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) _lowerCamelCase : Union[str, Any] = str(bin(lowercase__ ) )[2:] # remove the leading ...
12
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageI...
12
1
from string import ascii_uppercase _UpperCAmelCase : Tuple = {char: i for i, char in enumerate(ascii_uppercase)} _UpperCAmelCase : Optional[Any] = dict(enumerate(ascii_uppercase)) def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase ) -> str: ...
50
import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class lowerCAmelCase ( __UpperCamelCase ): UpperCAmelCase__ = """M-CLIP""" def __init__( self : Optional[Any] , UpperCAmelCase : Union[str, Any]=1024 , UpperCAmelCas...
50
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UN...
214
'''simple docstring''' import re from filelock import FileLock try: import nltk __a: Tuple = True except (ImportError, ModuleNotFoundError): __a: List[Any] = False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.download("""punkt""", quiet=True) def __Up...
214
1
'''simple docstring''' from timeit import timeit _lowerCamelCase : List[str] = { "MALAYALAM": True, "String": False, "rotor": True, "level": True, "A": True, "BB": True, "ABC": False, "amanaplanacanalpanama": True, # "a man a plan a canal panama" } ...
28
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : List[Any] = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "...
28
1
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_...
236
'''simple docstring''' import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MA...
236
1
'''simple docstring''' 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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import...
79
'''simple docstring''' def __lowercase ( __lowercase ) -> int: '''simple docstring''' assert isinstance(__lowercase , __lowercase ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1:...
79
1
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 ...test_tokenization_common import TokenizerTeste...
351
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common imp...
50
0
def lowerCamelCase__ ( A__ : int , A__ : int ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) __lowerCamelCase = str(bin(A__ ) )[2:] # remove the leading "0b" ...
12
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase_ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass el...
12
1
"""simple docstring""" from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) # TODO Update this lowerCamelCase_ = { 'facebook/esm-1b': 'htt...
356
"""simple docstring""" from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class UpperCamelCase_ : def __init__( self : Optional[Any] , lowerCAmelCase_ : Collection[float] | None = None ) -> ...
253
0
# flake8: noqa # Lint as: python3 snake_case_ = [ '''VerificationMode''', '''Version''', '''disable_progress_bar''', '''enable_progress_bar''', '''is_progress_bar_enabled''', '''experimental''', ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable_p...
214
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } class SCREAMING_SNAKE_CASE__ (__snake_case )...
214
1
import re def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = re.compile(R'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' ) if match := re.search(A__ , A__ ): return match.string == phone return False if __name__ == "__main__": ...
351
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax...
93
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
1
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, genera...
368
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> Tuple: '''simple docstring''' lowercase_ = 0 if start < ...
313
0
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor import transforme...
110
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> str: lowerCamelCase__ : Optional[int] = [ 'encoder.version', 'decoder.version', ...
50
0
"""simple docstring""" import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _lowerCAmelCase ...
358
"""simple docstring""" from string import ascii_uppercase __magic_name__ = {str(ord(c) - 55): c for c in ascii_uppercase} def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): if isinstance(UpperCamelCase_ , UpperCamelCase_ ): raise TypeError("""int() can't convert no...
255
0
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')
88
import os def A_ ( a = "matrix.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(a ) , a ) ) as in_file: SCREAMING_SNAKE_CASE_ : Dict = in_file.read() SCREAMING_SNAKE_CASE_ : Dict = [[int(a ) fo...
253
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __A = { "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig", "GroupViTOnnxConfig", "GroupViTTextCo...
273
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE , unittest.TestCase ): '''simple do...
273
1
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big...
87
'''simple docstring''' from math import isqrt, loga def snake_case_ ( __SCREAMING_SNAKE_CASE : int ): """simple docstring""" lowercase_ : Any = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + ...
93
0
import math def SCREAMING_SNAKE_CASE__( _UpperCamelCase : float , _UpperCamelCase : float ) -> int: '''simple docstring''' if ( not isinstance(__SCREAMING_SNAKE_CASE , (int, float) ) or power_factor < -1 o...
370
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__( _UpperCamelCase : Dict , _UpperCamelCase : str , _UpperCamelCase : Optional[int] , _UpperCamelCase : str ) -> Dict: # noqa: E741 '''simple docstri...
31
0
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenize...
106
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import MC...
313
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ = { '''configuration_jukebox''': [ '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''JukeboxConfig''', '''JukeboxPriorConfig''', ...
362
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transfor...
44
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available...
24
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTra...
255
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : Union[str, Any] ={ 'configuration_mctct': ['MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MCTCTConfig'], 'feature_extraction_mctct': ['MCTCTFeatureExtractor'], 'processi...
356
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case : Optional[int] ={ 'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'], 'processing_vi...
94
0
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , Upper...
273
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 ModelTes...
273
1
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' if "img_encoder.pos_embed" ...
357
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_comm...
324
0
from __future__ import annotations __A =list[list[int]] # assigning initial values to the grid __A =[ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, ...
19
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable __SCREAMING_SNAKE_CASE : Optional[int] = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCH...
31
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE ={ "configuration_rembert": ["REMBERT_PRETRAINED_CONFIG_ARCHIVE_MA...
362
"""simple docstring""" class UpperCamelCase : def __init__( self ,__UpperCamelCase ,__UpperCamelCase ) -> int: '''simple docstring''' lowercase_ : List[Any] = name lowercase_ : int = val def __str__( s...
321
0
"""simple docstring""" import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A_ (SCREAMING_SNAKE_CASE_ ,unittest.TestCase ): '''simple docstring''' SC...
61
"""simple docstring""" from __future__ import annotations _a : List[str] = 10 def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list[int] ) -> list[int]: _lowerCAmelCase : Optional[int] = 1 _lowerCAmelCase : Union[str, Any] ...
44
0
"""simple docstring""" import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEm...
366
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # ...
233
0
'''simple docstring''' def lowerCamelCase__ ( ): for n in range(1 , 100_0000 ): yield n * (n + 1) // 2 def lowerCamelCase__ ( _A ): a : List[str] = 1 a : List[str] = 2 while i * i <= n: a : int ...
297
from __future__ import annotations def __lowerCamelCase ( UpperCAmelCase_ : dict , UpperCAmelCase_ : str ): """simple docstring""" a , a :Optional[Any] = set(UpperCAmelCase_ ), [start] while stack: a :Optional[int...
94
0
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class a__ ( nn.Module ): _SCREAMING_SNAKE_CASE : int _SCREAMING_SNAKE_CASE : int ...
199
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class a__ ...
199
1
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 ...test_tokenization_common import Toke...
7
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention...
324
0
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() ...
192
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked befor...
192
1
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging _a = logging.get_logger(__name__) def __a ( __lowerCamelC...
61
'''simple docstring''' from __future__ import annotations import math class a_ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: """simple docstring""" UpperCamelCase = size # approximate the ov...
321
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else: __snake...
367
"""simple docstring""" from __future__ import annotations from math import gcd def _lowercase ( __snake_case ,__snake_case = 2 ,__snake_case = 1 ,__snake_case = 3 ,) -> int | None: # A value less than 2 can cause an infinite loop in the algorithm. if num < 2: ...
58
0
'''simple docstring''' import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from ...
161
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_inf...
233
0
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, OpenAIGPTDoubleHead...
158
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import...
158
1
import argparse import copy def a_ ( SCREAMING_SNAKE_CASE__ : Optional[int] ): '''simple docstring''' _lowerCamelCase : List[str] ={} with open(SCREAMING_SNAKE_CASE__ ) as f: for line in f: if line.split()[0] not in d...
199
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin lowerCam...
199
1
from collections.abc import Sequence def lowerCAmelCase_ (lowerCAmelCase__: Sequence[float] , lowerCAmelCase__: bool = False ): """simple docstring""" if not arr: return 0 UpperCAmelCase_: Optional[Any] = 0 if allo...
82
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigT...
82
1
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 impo...
192
import argparse import os import re A_ : List[str] = 'src/diffusers' # Pattern that looks at the indentation in a line. A_ : Union[str, Any] = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. A_ : int = re.compile(r'^\s*"([^"]+)":') ...
192
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_GUIDED_IMAG...
117
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class UpperCAmelCase__ ( A_ ): """simple docstring""" UpperCAmelCase__ : Optional[int] = "MCTCTFeatureExtractor" UpperCAmelCase__ : str = "Auto...
117
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case : Dict = logging.get_logger(__name__) snake_case : Any = { '''andreasmadsen/efficie...
94
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-bas...
58
0
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_u...
292
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case (UpperCAmelCase__ , UpperCAmelCase__ ) -> np.array: UpperCamelCase_: Dict = F'''{sampling_rate}''' UpperCamelCase_: Any = '1' UpperC...
292
1
'''simple docstring''' import numpy as np import qiskit def __a(SCREAMING_SNAKE_CASE_ : int = 8 , SCREAMING_SNAKE_CASE_ : int | None = None ): '''simple docstring''' _lowerCAmelCase = np.random.default_rng(seed=SCREAMING_SNAKE_CASE_ ) # Roughly 25% of the...
158
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE = {"configuration_wavlm": ["WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "WavLMConfig"]} try: if not is_torch_available(): ...
158
1
"""simple docstring""" import os import re 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 : List[str] = logging.get_log...
352
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : Dict=28_123 ) -> List[str]: '''simple docstring''' _UpperCAmelCase : List[Any] = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs...
202
0
from __future__ import annotations from collections.abc import MutableSequence class __lowerCAmelCase : def __init__( self , _snake_case , _snake_case ): """simple docstring""" if len(_snake_case ) != degree + 1: raise ValueError( ...
82
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 A__ = logging.get_logger(__name__) class __lowerCAmelCase ( lowe...
82
1
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex __A = logging.getLogger(__name__) class snake_case : def __init__(...
108
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 1_0**-1_0 ) -> float: __lowerCAmelCase: ...
108
1
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transforme...
117
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_co...
117
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETRAINED_CONFIG_ARCHIV...
105
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
105
1
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _UpperCAmelCase ( unittest.TestCase ): def lowerCamelCase ( self :List[Any] ): A = [ "safety_checker/pytorch_model.bin", ...
292
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : Union[str, Any] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig...
292
1
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _SCREAMING_SNAKE_CASE : '''simple docstring''' @property def ...
362
from math import pow def lowerCAmelCase_ ( __a , __a , __a , __a , __a , ) -> tuple[int, int]: """simple docstring""" if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += ...
273
0
def a_ ( _A , _A ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def a_ ( ) -> None: """simple docstring""" assert and_gate(0 , 0 ) == 0 assert and_gate(0 ,...
307
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _A : int = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that develop...
202
0
__UpperCAmelCase = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
28
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Co...
28
1
"""simple docstring""" 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 lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCas...
108
"""simple docstring""" import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = ''...
108
1
from numpy import exp, pi, sqrt def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase = 0.0 , _UpperCamelCase = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__":...
279
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( '''The converted tokenizer will be...
279
1
"""simple docstring""" import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTester...
105
"""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, ImagePipel...
105
1
import requests from bsa import BeautifulSoup def a_ ( lowerCAmelCase_ : str, lowerCAmelCase_ : dict ): __lowerCAmelCase = BeautifulSoup(requests.get(lowerCAmelCase_, params=lowerCAmelCase_ ).content, 'html.parser' ) __lowerCAmelCase =...
364
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import ...
207
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_environ...
240
import cva import numpy as np class A_ : def __init__( self , _A , _A ): '''simple docstring''' if k in (0.04, 0.06): UpperCAmelCase = k UpperCAmelCase = window_size else: raise ValueError('''invalid k value''' ) def __...
273
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 ...
207
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 from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils imp...
207
1
'''simple docstring''' import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeli...
28
'''simple docstring''' def __lowerCamelCase ( A__ = 10**9 ) -> int: """simple docstring""" UpperCamelCase = 1 UpperCamelCase = 2 UpperCamelCase = 0 UpperCamelCase = 0 UpperCamelCase = 0 while perimeter <= max_perimeter: ...
28
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __SCREAMING_SNAKE_CASE : List[str] = { '''configuration_perceiver''': ['''PERCEIVER_PRETRAINED_CONFIG_ARCHI...
363
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, id...
284
0
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 lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ ...
279
from math import factorial lowerCAmelCase_ = {str(digit): factorial(digit) for digit in range(1_0)} def lowerCamelCase_ ( _UpperCamelCase ) -> int: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('''Parameter ...
279
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from d...
89
'''simple docstring''' import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers ...
89
1