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""" 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 impor...
645
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECORDS...
152
0
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_ut...
119
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, requi...
119
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING UpperCAmelCase_ : Tuple = logging.get_logger(__name__) class __A ( UpperCamelCase__ ): UpperCamelCase = ...
21
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def UpperCamelCase ( __lowe...
204
0
import os def __UpperCamelCase ( ) ->Union[str, Any]: """simple docstring""" lowerCamelCase_ =os.path.dirname(os.path.realpath(a_ ) ) lowerCamelCase_ =os.path.join(a_ , """triangle.txt""" ) with open(a_ ) as f: lowerCamelCase_...
712
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available ...
75
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=__magic_name__ ): """simple docstring""" _snake_case : Dict = ['transformers', 'torch', 'note_seq'] def __init__( self : Tuple ...
98
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": snake_case__ : Tuple = pd.read_csv('''sample_data.csv''', header=None) ...
392
0
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREA...
712
from __future__ import annotations import bisect def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = 0 , SCREAMING_SNAKE_CASE = -1 ): '''simple docstring''' if hi < 0: __UpperCamelCase :str = len(SCREAMING_SNAK...
452
0
"""simple docstring""" from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """microsoft/xprophetnet-large-wiki100-cased""": ( """https://huggi...
19
"""simple docstring""" 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, res...
19
1
'''simple docstring''' import re def lowercase_ ( lowercase__ ) ->bool: _snake_case: Dict = re.compile(R'^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$' ) if match := re.search(lowercase__ , lowercase__ ): return match.string == phone return ...
273
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_avai...
273
1
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _A ( __l...
26
'''simple docstring''' import argparse import os import re import packaging.version __UpperCamelCase = "examples/" __UpperCamelCase = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init...
26
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Optional[int] = { 'configuration_clap': [ 'CLAP_PRETRAINED_MODEL_ARCHIVE_LIST', 'ClapAudioConfig', 'ClapConfig', 'Cla...
267
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaP...
267
1
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_ut...
598
"""simple docstring""" import argparse import json import subprocess def UpperCamelCase ( _lowerCAmelCase : Optional[Any], _lowerCAmelCase : Optional[int] ) -> Union[str, Any]: _UpperCAmelCase : Tuple = [] _UpperCAmelCase : Dict ...
238
0
"""simple docstring""" import os import sys import unittest a : Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 g...
702
"""simple docstring""" import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def snake_case__ ( _SCREAMING_SNAKE_CASE ) ->Dict: #...
422
0
from statistics import mean import numpy as np def __magic_name__ ( __a : list , __a : list , __a : list , __a : int ): '''simple docstring''' UpperCamelCase__ = 0 # Number of processes finished UpperCamelCase_...
513
'''simple docstring''' def A__ ( __lowerCAmelCase : list[int] , __lowerCAmelCase : list[int] ): lowerCamelCase__ = len(__lowerCAmelCase ) print("""The following activities are selected:""" ) # The first activity is always selected lower...
50
0
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCa...
703
"""simple docstring""" 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""": """sentencepiec...
507
0
import doctest from collections import deque import numpy as np class a : """simple docstring""" def __init__( self : List[str] ) -> Any: __UpperCAmelCase : List[str] = [2, 1, 2, -1] __UpperCAmelCase : int = [1,...
63
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 100 ): __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "...
155
0
from __future__ import annotations def __UpperCAmelCase ( __A ) -> List[str]: '''simple docstring''' return len(set(lowerCamelCase__ ) ) == len(lowerCamelCase__ ) if __name__ == "__main__": import doctest doctest.testmod() ...
715
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __UpperCAmelCase ( __A ) -> Union[str, Any]: '''simple docstring''' if ( (cp >= 0x4_E_0_0 and cp <= 0x9_F_F_F) ...
277
0
import numpy as np def __lowercase ( _UpperCamelCase ) ->np.ndarray: """simple docstring""" return 1 / (1 + np.exp(-vector )) def __lowercase ( _UpperCamelCase ) ->np.ndarray: """simple docstring""" return vector * sigmoid(_UpperC...
319
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __a = logging.get_logger(__name__) __a = {'''vocab_file''': '''vocab.txt'''} __a = { '''vocab_file''': ...
319
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { """facebook/wav2vec2-base-960h""": """https://huggingface.co/fa...
239
"""simple docstring""" from itertools import count def __lowerCAmelCase ( __lowerCAmelCase : int = 50 ) -> int: _UpperCamelCase : Any = [1] * min_block_length for n in count(__lowerCAmelCase ): fill_count_functions.append(1 ) for block_length in ...
239
1
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resol...
373
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer impo...
424
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowerCAmelCase (...
629
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : str = { """huggingface/informer-tourism-monthly""": ( ...
629
1
'''simple docstring''' import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # 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 six # no...
94
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class A ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" @staticmethod @abstractmethod def _UpperCAmelCase ( __lowerCAmelCase ): raise NotImplementedError() ...
208
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowercase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass el...
718
"""simple docstring""" import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common i...
22
0
'''simple docstring''' import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCAmelCase = { "facebook/mask2former-swin-small-coco-instance": ( "https://huggingface.co/fa...
432
'''simple docstring''' 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 sagemak...
432
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase_ = { "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], } try: ...
599
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def lowerCAmelCase__ ( a_ : bytes , a_ : int ) -> np.array: UpperCAmelCase__ : Union[str, Any] = f"""{sampling_ra...
599
1
'''simple docstring''' import unittest from transformers import 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 ...
407
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __A =get_t...
407
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 snake_case_ : Any = logging.get_logger(__name__) snake_case_ : Optional[An...
721
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowerCamelCase ( pl.LightningModule ): def __init__( self , __snake_case ) -> int: ...
166
0
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 ConfigTester from .....
631
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPEN...
631
1
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase( lowerCAmelCase_...
233
'''simple docstring''' from ...configuration_utils import PretrainedConfig class __lowerCAmelCase( lowerCAmelCase__ ): __snake_case : Optional[Any] = 'bert-generation' def __init__( self : List[Any] , SCREAMING_SNAKE_CASE : Any=50_358 ...
233
1
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 if is_torch_available(): import torch if is_vision_av...
622
'''simple docstring''' def lowerCamelCase__ ( A : int = 50 ): '''simple docstring''' UpperCAmelCase = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile...
210
0
"""simple docstring""" def __UpperCamelCase ( SCREAMING_SNAKE_CASE ) -> list: """simple docstring""" __snake_case = len(SCREAMING_SNAKE_CASE ) for i in range(1 , SCREAMING_SNAKE_CASE ): __snake_case = collection[i] ...
614
"""simple docstring""" def __UpperCamelCase ( SCREAMING_SNAKE_CASE ) -> list: """simple docstring""" __snake_case = len(SCREAMING_SNAKE_CASE ) for i in range(1 , SCREAMING_SNAKE_CASE ): __snake_case = collection[i] ...
614
1
"""simple docstring""" import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets _A = "\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n and Saurav Kadavath\n ...
505
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailabl...
505
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''junnyu/roformer_chinese_small''': '...
226
import argparse import json from tqdm import tqdm def A(): lowerCAmelCase_ = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__a , default="biencoder-nq-dev.json" , help="Path to raw DPR training data" , ) parser.add_argument(...
226
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : Tuple = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'f...
640
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import Tokenize...
640
1
'''simple docstring''' import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
720
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowerCAmelCase_ : Dict = TypeVar("T") class lowercase ( Generic[T]...
461
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _lowerCAmelCase :Tuple = logging.get_logger(__name__) class UpperCAmelCase ( lowerCAmelCase_ ): '''simple docstring'''...
251
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ :Optional[int] = logging.get_logger(__name__) UpperCAmelCase__ :Union[str, Any] = { """microsoft/wavlm-base""": """https...
150
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils impo...
706
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert...
469
0
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowercase : Any = Lock() def lowerCamelCase__ ( A : List[Any] , A : Union[str, Any] , A : Tuple , A : Optional[int] , ...
210
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCamelCase__( unittest.TestCase ): def a__( self : Optional[int] )-> List[str]: """sim...
210
1
from __future__ import annotations snake_case__ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] snake_case__ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowerCamelCase__ ( a : list[float] ) -> list[float]: """simple docstring""" a__ :T...
373
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models at https://huggingf...
373
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torc...
613
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a : int = { """configuration_bridgetower""": [ """BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BridgeTowerConfig""", """Bridge...
613
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __a = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "Ll...
310
"""simple docstring""" import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase : '''simple docstring''' def __init__( self: Any , snake_case: Dict=2 , snake_case: Uni...
310
1
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowerCAmelCase_ = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < ...
531
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_m...
531
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() __magic_na...
717
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase = "laptop" ): snake_case__ = F"""https://www.amazon.in/laptop/s?k={product}""" snake_case__ = { "User-Agent": "...
530
0
"""simple docstring""" 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...
363
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __UpperCAmelCase (unittest.TestCase , __A ): '''simple docstring''' def lowerCamelCase ( self ): '''simple docstring''...
363
1
import heapq def __magic_name__ ( lowercase ) -> set[int]: """simple docstring""" lowercase_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq m...
436
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { """microsoft/unispeech-large-1500h-cv""": ( """https://huggingface.co/micr...
436
1
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : List[Any] , __lowerCamelCase : str ) ->int: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _SCREAMING_SNAKE_CASE = str(bin(__UpperCamelCase ...
314
import sys SCREAMING_SNAKE_CASE : List[Any] = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "6689664895044...
141
0
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def lowerCamelCase_ ( _lowerCamelCase ): '''simple docstring''' if not is_accelerate_available(): return method lowerCamelC...
707
"""simple docstring""" import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") A_ : Optional[int] = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) A_ : L...
696
0
def __lowerCamelCase ( lowerCamelCase__ : str ): '''simple docstring''' if n_term == "": return [] lowerCamelCase = [] for temp in range(int(lowerCamelCase__ ) ): series.append(f'1/{temp + 1}' if series else """1""" ) return series if ...
457
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging UpperCAmelCase : Any ...
457
1
"""simple docstring""" def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): lowerCamelCase__ : Dict = len(_lowerCamelCase ) lowerCamelCase__ : Dict = len(_lowerCamelCase ) lowerCamelCase__ : Optional[int] = [[False for _ in range(m +...
696
"""simple docstring""" import os def lowerCamelCase_ ( ): with open(os.path.dirname(_lowerCamelCase ) + '/p022_names.txt' ) as file: lowerCamelCase__ : Union[str, Any] = str(file.readlines()[0] ) lowerCamelCase__ : int = names.replace('"' , '' ...
696
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
57
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ...
179
0
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, 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, r...
333
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class a_ : """simple docstring""" def __init__( self , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) ->int: if dst_width < 0 or dst_height < 0: ...
333
1
'''simple docstring''' from typing import TYPE_CHECKING import torch from ..models.auto import AutoModelForVisualQuestionAnswering, AutoProcessor from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class snake_case ( _a ): """simple d...
261
"""simple docstring""" def lowerCAmelCase_ ( UpperCamelCase__ : int ): """simple docstring""" assert ( isinstance(UpperCamelCase__ , UpperCamelCase__ ) and number_of_steps > 0 ), f'''number_of_steps needs to be positive integer, your input {number_of_s...
616
0
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class snake_ca...
303
def lowercase__( A = 1_0 , A = 1_0_0_0 , A = True ): assert ( isinstance(A , A ) and isinstance(A , A ) and isinstance(A , A ) ), "Invalid type of value(s) specified to function!" if min_val > max_val: raise ValueError('In...
303
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
381
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2StructConfig''', ...
381
1
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...
721
import requests def __lowerCAmelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )-> None: """simple docstring""" snake_case_ = {'''Content-Type''': '''application/json'''} snake_case_ = requests.post(SCREAMING_SNAKE_CASE , json={'''text''': messag...
531
0
def a__ ( _UpperCamelCase : int ,_UpperCamelCase : int ): return int((input_a, input_a).count(0 ) == 0 ) def a__ ( ): 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 ...
175
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json""", # See all CANINE models at https://huggingface.co/models?filter...
175
1
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def _a ( _SCREAMING_SNAKE_CASE : List[Any] ): _SCREAMING_SNAKE_CASE = int(_SCREAMI...
493
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterM...
493
1
def UpperCamelCase ( __magic_name__ : int , __magic_name__ : list ) -> str: """simple docstring""" _enforce_args(__magic_name__ , __magic_name__ ) if n == 0: return 0 lowercase__ = float("""-inf""" ) for i in range(1 , ...
15
"""simple docstring""" import argparse import os import re import packaging.version lowerCAmelCase__ ="examples/" lowerCAmelCase__ ={ "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(r"^__versio...
482
0
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, requ...
69
import unittest from transformers import DonutProcessor lowerCamelCase__ = """naver-clova-ix/donut-base""" class A__ ( unittest.TestCase ): def _lowerCamelCase ( self : Dict ): '''simple docstring''' ...
69
1
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): return [sentence[i : i + ngram_size] for i in range(len(SCREAMING_SNAKE_CASE_ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
413
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): _UpperCAmelCase : Optional[Any] = (DDPMScheduler,) def __lowerCamelCase ( self : Optional[int] ...
315
0
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, generate_identified_filename...
708
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { "google/pix2struct-textcaps-base": ( ...
367
0
import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : List[Any]...
141
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __low...
141
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ : List[str] = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not is_torch_av...
629
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, EfficientForme...
629
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python u...
116
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml f...
116
1
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase_ ( __snake_case ): _UpperCamelCase : Tuple = "ClapFeatureExtractor" _UpperCamelCase : Optional[int] = ("RobertaTokenizer", "RobertaTok...
712
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np UpperCamelCase = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 UpperCamelCase = typing.Union[np.floataa, int, float] # noqa: UP007 def __magic_name__ ( SC...
677
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.h...
371
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_co...
371
1
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets _lowerCamelCase = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplific...
700
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline _lowerCamelCase = '''path-to-your-trained-model''' _lowerCamelCase = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('''cuda''') _lowerCamelCase = '''A photo of sks...
401
0
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGen...
380
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer A__: Dict = {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'...
380
1
import pickle import numpy as np from matplotlib import pyplot as plt class _snake_case : def __init__( self , a , a , a , a , a , a=0.2 , a=0.2) -> Any: SCREAMING_SNAKE_CASE = bp_numa SCREAMING_SNAKE_CASE = bp_numa SCR...
718
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings a_ : List[str] = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model outp...
444
0
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER,...
100
from manim import * class _UpperCAmelCase ( A__ ): def snake_case_ ( self): A__ = Rectangle(height=0.5 , width=0.5) A__ = Rectangle(height=0.2_5 , width=0.2_5) A__ = Rectangle(height=0.4_6 , width=0.4_6).set_...
632
0
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
716
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class snake_case_ ( pl.LightningModule ): def __init__( self : Union[str, Any] , _snake_case : List[str] )...
240
0
from __future__ import annotations from typing import Any def _SCREAMING_SNAKE_CASE ( a ) -> None: create_state_space_tree(a , [] , 0 ) def _SCREAMING_SNAKE_CASE ( a , a , a ) -> None: if index == len(a ): print(a ) r...
239
def _SCREAMING_SNAKE_CASE ( a ) -> list: if len(a ) <= 1: return lst __A : Any = 1 while i < len(a ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A : str = lst[i]...
239
1
"""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_available(): from ...
553
"""simple docstring""" import functools def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ) or not all(isinstance(lowerCAmelCase_ , lowerCAmelCase_ ) for day in days )...
553
1
_UpperCAmelCase : Union[str, Any] = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCAmelCase : Any = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCAmelCase : Tuple = { 0: """Sunday""", 1: """Monday""", 2: """Tuesday""", 3: """Wednesday""", 4: """Thursday""...
362
"""simple docstring""" from __future__ import annotations def lowercase__(A , A ) ->list[int]: """simple docstring""" lowercase__ : Any= 0 lowercase__ : List[str]= len(A ) - 1 while i < j: i...
218
0
"""simple docstring""" def __lowercase ( a : int ) -> int: __snake_case : Tuple =abs(a ) __snake_case : Optional[Any] =0 while n > 0: res += n % 10 n //= 10 return res def __lowercase ( a : int ) ...
497
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffus...
497
1
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ ( A_ ): __UpperCAmelCase = (DDPMScheduler,) def UpperCamelCase_ ( self , **SCREAMING_SNAKE_CASE) ...
88
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Optional[Any] = { """configuration_funnel""": ["""FUNNEL_PRETRAIN...
142
0
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> list: UpperCAmelCase__ : int = len(lowerCAmelCase__ ) UpperCAmelCase__ : Dict = [] for i in range(len(lowerCAmelCase__ ) - pat_len + 1 ): UpperCAmelCa...
312
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> bool: UpperCAmelCase__ : List[Any] = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(2_7)) print(perfect_cube(4))
312
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''RUCAIBox/mvp''': '''https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json''', } class lowerCamelCase_ ( UpperCAmelCas...
167
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, UNCONDITIONAL_IMAGE_GENERA...
167
1
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __lowerCAmelCase = 2_99_79_24_58 # Symbols __lowerCAmelCase ,__lowerCAmelCase ,__lowerCAmelCase ,__lowerCAmelCase = symbols('''ct x y z''') def snake_case_ ( snake...
335
def snake_case_ ( snake_case ) -> int: if not isinstance(snake_case , snake_case ): raise TypeError('only integers accepted as input' ) else: lowercase__: str = str(abs(snake_case ) ) lowercase__: ...
335
1
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, ...
32
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
654
0
from __future__ import annotations from collections.abc import Iterator from typing import Any class A : def __init__( self : str , __UpperCAmelCase : Any ) -> Optional[int]: """simple docstring""" Upp...
716
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def a...
559
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( __UpperCAmelCase ) -> list[int]: if length <= 0 or not isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range...
159
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _A = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertConf...
159
1
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { 'vocab_file': 'vocab.txt', 'merges_file': 'bpe.codes', } _...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_available(): raise OptionalDepen...
627
0
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): __snake_case : List[str] = len(__lowerCamelCase ) __snake_case : Union[str, Any] = len(__lowerCamelCase ) __snake_case : Optional[Any] = [[False for ...
81
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokenization_ctrl...
237
0
UpperCAmelCase__ : List[str] = frozenset( [ "prompt", "height", "width", "guidance_scale", "negative_prompt", "prompt_embeds", "negative_prompt_embeds", "cross_attention_kwargs", ] ) UpperCAmelCase__ ...
676
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow UpperCAmelCase__ : Any = logging.getLogger() @unittest.skip...
676
1
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = [[0 for _ in range(__SCREAMING_SNAKE_CASE )] for _ in range(m + 1 )] for i in range(m + 1 ): lowercase = 1 for n in range(m + 1 ): for k in range(1 , __SCREAMING_SNAKE_CASE ): memo[n][k] += m...
84
import math def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = [True] * n lowercase = False lowercase = False lowercase = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): lowercase = i * 2 while index < n: l...
84
1
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class snake_case : def __init__( self : List[str] ) -> Tuple: '''simple docstring''' _A ...
700
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
621
0
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamelCase_ = "" lowerCamelCase_ = ( None...
6
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import R...
6
1
"""simple docstring""" from __future__ import annotations from typing import TypedDict class _lowercase ( UpperCamelCase_ ): '''simple docstring''' _A = 42 _A = 42 def a__ ( lowerCAmelCase : int ): '''simple do...
712
"""simple docstring""" import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def a__ ( lowerCAmelCase : List[Any] , lowerCAmelCase : An...
660
0
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar __UpperCamelCase = TypeVar('T') __UpperCamelCase = TypeVar('U') class lowerCamelCase__ ( Generic[T, U] ): """simple docstring""" def __init__...
551
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "bert-base-uncased": "https://huggingfac...
391
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature...
708
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : str = { "configuration_pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"], } try: if...
238
0
'''simple docstring''' from math import factorial, pi def UpperCamelCase__ ( __magic_name__ : float , __magic_name__ : int = 30 ) -> float: '''simple docstring''' if not isinstance(__magic_name__ , (int, float) ): raise ValueError("""maclaurin_sin...
38
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import torch i...
287
0
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class UpperCAmel...
450
from __future__ import annotations def lowerCamelCase_ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' create_state_space_tree(SCREAMING_SNAKE_CASE , [] , 0 , [0 for i in range(len(SCREAMING_SNAKE_CASE ) )] ) def lowerCamelCase_ ( SCREAMING_SNAKE_CASE , SCREAMIN...
450
1
import numpy as np def __lowercase( UpperCAmelCase__ ): """simple docstring""" return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
623
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_tokenizers, re...
623
1
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property ...
408
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_devic...
408
1
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig __A : Optional[Any] = logging.get_logger(__name__) __A : Dict = "T5Config" class l...
27
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_atte...
27
1
class lowercase ( SCREAMING_SNAKE_CASE__ ): pass class lowercase ( SCREAMING_SNAKE_CASE__ ): pass class lowercase : def __init__( self): lowercase = [ [], [], [], ] ...
716
# Copyright 2022 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...
633
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor...
600
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin __...
600
1
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase = [ '''word_e...
713
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
102
0
'''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_...
638
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTes...
638
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = { """configuration_informer""": [ """INFORMER_PRETRAINED_CONFIG_ARCHIVE...
706
"""simple docstring""" def a__ ( lowerCAmelCase__ ): if not head: return True # split the list to two parts UpperCAmelCase_ , UpperCAmelCase_ = head.next, head while fast and fast.next: UpperCAmelCase_ = ...
14
0