code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available SCREAMING_SNAKE_CASE__ : Dict = { """configuration_gpt_neo""": ["""GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoConfig""", """GPTNeoOnnxConfig"""], } t...
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
122
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQue...
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
122
0
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar("""T""") class lowerCamelCase__ ( Generic[T]): """simple docstring""" def __init__( self : Tuple , __lowerCAmelCase : ...
2
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase__ = 4 lowerCamelCase__ = 3 class __magic_name__ (__lowercase ): pass...
122
0
'''simple docstring''' import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase : List[str] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( sna...
3
import torch from torch import nn class __magic_name__ (nn.Module ): def __init__( self , _a , _a , _a , _a , _a=1 , _a=False ) -> str: super().__init__() lowerCAmelCase_ = n_token lowerCAmelCase_ = d_embed lowerCAme...
122
0
"""simple docstring""" import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaT...
4
from collections import defaultdict class __magic_name__ : def __init__( self , _a , _a ) -> Tuple: lowerCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are set to -1 lowerCAm...
122
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, ...
5
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow...
122
0
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 .tokenization_big_bird impor...
6
def A(__a: int = 50 ): lowerCAmelCase_ = [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_length + 1 ): ways_number[row_length] += ways_number[ row_length...
122
0
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a = logging.get_logger(__name__) a = { '''vocab_file''': '''vocab.json''', ...
7
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 lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
0
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants lowercase__ : List[str] = Mapping[str, np.ndarray] lowercase__ ...
8
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
122
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ = {'''processing_layoutxlm''': ['''LayoutXLMProcessor''']} tr...
9
from math import factorial def A(__a: int , __a: int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n...
122
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDConditi...
10
from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def A(__a: str , __a: str ): lowerCAmelCase_ = len(__a ) lowerCAmelCase_ = ...
122
0
'''simple docstring''' def lowerCAmelCase (__A = 1 , __A = 1_000): """simple docstring""" _a = 1 _a = 0 for divide_by_number in range(__A , digit + 1): _a = [] _a = numerator for _ in...
11
from itertools import product def A(__a: int , __a: int ): lowerCAmelCase_ = sides_number lowerCAmelCase_ = max_face_number * dice_number lowerCAmelCase_ = [0] * (max_total + 1) lowerCAmelCase_ = 1 lowerCAmelCase_ =...
122
0
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _snake_case ( UpperCAmelC...
12
from ..utils import DummyObject, requires_backends class __magic_name__ (metaclass=__lowercase ): lowerCamelCase__ = ['''speech'''] def __init__( self , *_a , **_a ) -> str: requires_backends(self , ["speech"] ) class __magic_name__ (metacl...
122
0
'''simple docstring''' from collections import namedtuple import requests from lxml import html # type: ignore A__ : Tuple = namedtuple("""covid_data""", """cases deaths recovered""") def UpperCAmelCase__ ( UpperCAmelCase_ : str = "https://www.worldometers.info/coronavir...
13
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '...
122
0
def __UpperCAmelCase ( __a : Union[str, Any] ) -> int: """simple docstring""" if not head: return True # split the list to two parts _a , _a : Optional[Any] = head.next, head while fast and fast.next: _a : ...
14
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNeta...
122
0
from ...configuration_utils import PretrainedConfig A : Optional[int] = { 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co/goog...
15
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ...
122
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() __A : int = logging.get_logger(__name__) __A : str = [ ['attention', 'attn'], ['encoder_a...
16
from __future__ import annotations def A(__a: list[int] , __a: list[int] , __a: int ): lowerCAmelCase_ = list(range(len(__a ) ) ) lowerCAmelCase_ = [v / w for v, w in zip(__a , __a )] index.sort(key=lambda __a : ratio[i] , ...
122
0
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 transformers.models.mbart.modeling_mbart impo...
17
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try:...
122
0
'''simple docstring''' import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def __a(SCREAMING_SNAKE_CASE_ : Optional[int] ): '''simple docstring''' _lowerCA...
18
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase__ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
122
0
"""simple docstring""" # Imports import numpy as np class _UpperCAmelCase: def __init__( self , __a=None , __a=None , __a=None , __a=None , __a=None) -> Dict: '''simple docstring''' self.s...
19
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependency...
122
0
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput ...
20
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the r...
122
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __A ( UpperCamelCase__ ): UpperCamelCase = (PNDMScheduler,) UpperCamelCase = (("""num_inference_steps""", 50),) d...
21
import unittest import numpy as np from datasets import load_dataset 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 ...
122
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : List[Any] = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig']...
22
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
122
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer snake_case__ : Dict = logging.get_...
23
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
122
0
'''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 _UpperCamelCase (_lowerCamelCase : Tuple )-> List[str]: '''simple...
24
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase__ = 4 lowerCamelCase__ = 3 class __magic_name__ (__lowercase ): pass...
122
0
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
import torch from torch import nn class __magic_name__ (nn.Module ): def __init__( self , _a , _a , _a , _a , _a=1 , _a=False ) -> str: super().__init__() lowerCAmelCase_ = n_token lowerCAmelCase_ = d_embed lowerCAme...
122
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __UpperCamelCase = logging.get_logger(__name__) class _A ( __lowercase ): def __init__( self : int , *__magic_name__ ...
26
from collections import defaultdict class __magic_name__ : def __init__( self , _a , _a ) -> Tuple: lowerCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are set to -1 lowerCAm...
122
0
from math import factorial class lowerCamelCase: '''simple docstring''' def __init__( self , snake_case_ , snake_case_ ): _A = real if isinstance(snake_case_ , snake_case_ ): _A = [1...
27
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow...
122
0
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class _a ( unittest.TestCase ): '''simple docstring''' def UpperCamelCase_ ( self ): '''simple docstring''' ...
28
def A(__a: int = 50 ): lowerCAmelCase_ = [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_length + 1 ): ways_number[row_length] += ways_number[ row_length...
122
0
"""simple docstring""" import requests from bsa import BeautifulSoup def lowercase ( lowerCAmelCase__ = "AAPL" ): lowerCamelCase_ = f"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}" lowerCamelCase_ = BeautifulSoup(requests.get(lowerCAmelCase__ ).text ,'''html.parser''' ...
29
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 lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
0
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_uti...
30
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
122
0
import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_checkpoint_callback, get_ea...
31
from math import factorial def A(__a: int , __a: int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n...
122
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltCLIPTextConfig", ...
32
from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def A(__a: str , __a: str ): lowerCAmelCase_ = len(__a ) lowerCAmelCase_ = ...
122
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def SCREAMING_SNAKE_CASE ( __lowerCAmelCase = 3 ) -> qiskit.result.counts.Counts: if isinstance(__lowerCAmelCase , __lowerCAmelCase ): ...
33
from itertools import product def A(__a: int , __a: int ): lowerCAmelCase_ = sides_number lowerCAmelCase_ = max_face_number * dice_number lowerCAmelCase_ = [0] * (max_total + 1) lowerCAmelCase_ = 1 lowerCAmelCase_ =...
122
0
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'google/umt5-small': '...
34
from ..utils import DummyObject, requires_backends class __magic_name__ (metaclass=__lowercase ): lowerCamelCase__ = ['''speech'''] def __init__( self , *_a , **_a ) -> str: requires_backends(self , ["speech"] ) class __magic_name__ (metacl...
122
0
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS...
35
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '...
122
0
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class _A ( snake_case ): '''simple docstring''' __lowerCamelCase : List[str] = CustomTokenizer pass
36
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNeta...
122
0
def UpperCamelCase_ ( ) -> int: return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(__a , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f"""{solution() = }""")
37
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ...
122
0
'''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 impor...
38
from __future__ import annotations def A(__a: list[int] , __a: list[int] , __a: int ): lowerCAmelCase_ = list(range(len(__a ) ) ) lowerCAmelCase_ = [v / w for v, w in zip(__a , __a )] index.sort(key=lambda __a : ratio[i] , ...
122
0
lowerCAmelCase_ = range(2, 20 + 1) lowerCAmelCase_ = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase_ = {} def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): ...
39
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try:...
122
0
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 __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''hustvl/yolos-small...
40
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase__ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
122
0
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from trans...
41
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependency...
122
0
'''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 A_ = logging.get_logger(__name__) A_ = {"vocab_file": "vocab.json", "merges...
42
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the r...
122
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileViTConfig', ...
43
import unittest import numpy as np from datasets import load_dataset 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 ...
122
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : Any = ...
44
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
122
0
from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0...
45
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
122
0
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> set[str]: '''simple docstring''' _lowerCamelCase, _lowerCamelCase : List[Any] = set(_lowerCamelCase ), [start] while stack...
46
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase__ = 4 lowerCamelCase__ = 3 class __magic_name__ (__lowercase ): pass...
122
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} t...
47
import torch from torch import nn class __magic_name__ (nn.Module ): def __init__( self , _a , _a , _a , _a , _a=1 , _a=False ) -> str: super().__init__() lowerCAmelCase_ = n_token lowerCAmelCase_ = d_embed lowerCAme...
122
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device UpperCAmelCase__ : str = False class A ( unittest.TestCase ...
48
from collections import defaultdict class __magic_name__ : def __init__( self , _a , _a ) -> Tuple: lowerCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are set to -1 lowerCAm...
122
0
"""simple docstring""" def lowercase__ ( snake_case_ :List[str] , snake_case_ :Optional[Any] ): return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase__ ( snake_case_ :str , snake_case_ :Dict=0 ): return sorted(s...
49
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow...
122
0
'''simple docstring''' import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from .....
50
def A(__a: int = 50 ): lowerCAmelCase_ = [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_length + 1 ): ways_number[row_length] += ways_number[ row_length...
122
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : List[Any] = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.j...
51
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 lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
0
"""simple docstring""" import baseaa def __A ( a_ :str) -> bytes: return baseaa.baaencode(string.encode('''utf-8''')) def __A ( a_ :bytes) -> str: return baseaa.baadecode(a_).decode('''utf-8''') if __name__ == "__main__": A = '''...
52
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
122
0
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _UpperCAmelCase ( unittest.TestCase ): """simple docst...
53
from math import factorial def A(__a: int , __a: int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n...
122
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_ge...
54
from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def A(__a: str , __a: str ): lowerCAmelCase_ = len(__a ) lowerCAmelCase_ = ...
122
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def UpperCAmelCase ( a_ ) -> Optional[Any]: """simple docstring""" ...
55
from itertools import product def A(__a: int , __a: int ): lowerCAmelCase_ = sides_number lowerCAmelCase_ = max_face_number * dice_number lowerCAmelCase_ = [0] * (max_total + 1) lowerCAmelCase_ = 1 lowerCAmelCase_ =...
122
0
'''simple docstring''' def _a (lowercase__ : str , lowercase__ : str ) -> Dict: """simple docstring""" assert x is not None assert y is not None __snake_case = len(lowercase__ ) __snake_case = len(lowercase__ ) ...
56
from ..utils import DummyObject, requires_backends class __magic_name__ (metaclass=__lowercase ): lowerCamelCase__ = ['''speech'''] def __init__( self , *_a , **_a ) -> str: requires_backends(self , ["speech"] ) class __magic_name__ (metacl...
122
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : int = {'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']} try: if not is_torch_available(): ...
57
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '...
122
0
"""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 utils/c...
58
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNeta...
122
0
from math import ceil def lowerCAmelCase_ ( __a , __a ) -> Union[str, Any]: """simple docstring""" lowerCamelCase__: str =list(range(0 , __a ) ) lowerCamelCase__: Dict =[item for sublist in list(device_map.values() ) for...
59
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ...
122
0
from ....utils import logging lowerCAmelCase_ = logging.get_logger(__name__) class __lowerCAmelCase ( _a ): def __init__(self , __magic_name__ , __magic_name__=None , __magic_name__=2048 ) -> Union[str, Any]: '''simple docstring''' snake...
60
from __future__ import annotations def A(__a: list[int] , __a: list[int] , __a: int ): lowerCAmelCase_ = list(range(len(__a ) ) ) lowerCAmelCase_ = [v / w for v, w in zip(__a , __a )] index.sort(key=lambda __a : ratio[i] , ...
122
0
def _A ( lowerCAmelCase_ : Optional[int] , lowerCAmelCase_ : List[str] , lowerCAmelCase_ : Tuple , lowerCAmelCase_ : List[Any] , lowerCAmelCase_ : str , lowerCAmelCase_ : List[str] ): """simple docstring""" if index == r: for j ...
61
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try:...
122
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class SCREAMING_SNAKE_CASE ( unittest.TestCase , lowerCAmelCase ): '''simple docstring''' def _A ( self : List[Any] ): SCREAMING_SNAKE_CASE ...
62
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase__ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
122
0
def lowerCamelCase__ ( __lowerCamelCase : int = 100 ): __UpperCAmelCase : List[str] = 0 __UpperCAmelCase : List[str] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squar...
63
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependency...
122
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file, and thus...
64
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the r...
122
0
"""simple docstring""" from __future__ import annotations from cmath import sqrt def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' if a == 0: raise ValueError("""Coefficient 'a' must not be zero.""" ) Upp...
65
import unittest import numpy as np from datasets import load_dataset 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 ...
122
0
import os import sys import unittest UpperCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, r...
66
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
122
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import Templat...
67
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
122
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A = { "configuration_bridgetower": [ "BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP", "BridgeTowerConfig", "BridgeTowerTextConfig", "...
68
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase__ = 4 lowerCamelCase__ = 3 class __magic_name__ (__lowercase ): pass...
122
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def __UpperCAmelCase ( _UpperCAm...
69
import torch from torch import nn class __magic_name__ (nn.Module ): def __init__( self , _a , _a , _a , _a , _a=1 , _a=False ) -> str: super().__init__() lowerCAmelCase_ = n_token lowerCAmelCase_ = d_embed lowerCAme...
122
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCamelCase : Dict = { "config...
70
from collections import defaultdict class __magic_name__ : def __init__( self , _a , _a ) -> Tuple: lowerCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are set to -1 lowerCAm...
122
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class...
71
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow...
122
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Dict = { '''facebook/xglm-564M''': '''https://huggingface.co/facebook/xglm-564M/resolve/main/config.json''', # See all XGLM ...
72
def A(__a: int = 50 ): lowerCAmelCase_ = [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_length + 1 ): ways_number[row_length] += ways_number[ row_length...
122
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a_ : List[str] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else:...
73
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 lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
0
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts...
74
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
122
0
'''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, convert_to_rgb, get_resize_output_image_size, normalize, re...
75
from math import factorial def A(__a: int , __a: int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n...
122
0
"""simple docstring""" # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc...
76
from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def A(__a: str , __a: str ): lowerCAmelCase_ = len(__a ) lowerCAmelCase_ = ...
122
0
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase = 1 , UpperCamelCase = 1000 ) -> int: """simple docstring""" __UpperCAmelCase : int = 1 __UpperCAmelCase : Tuple = 0 for divide_by_number in range(U...
77
from itertools import product def A(__a: int , __a: int ): lowerCAmelCase_ = sides_number lowerCAmelCase_ = max_face_number * dice_number lowerCAmelCase_ = [0] * (max_total + 1) lowerCAmelCase_ = 1 lowerCAmelCase_ =...
122
0
'''simple docstring''' 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_...
78
from ..utils import DummyObject, requires_backends class __magic_name__ (metaclass=__lowercase ): lowerCamelCase__ = ['''speech'''] def __init__( self , *_a , **_a ) -> str: requires_backends(self , ["speech"] ) class __magic_name__ (metacl...
122
0
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig SCREAMING_SNAKE_CASE__ : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Any = """T5Config...
79
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '...
122
0
from math import isqrt def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , lowerCamelCase , lowerCamelCase ): ...
80
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNeta...
122
0
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _snake_case : Dict = logging.get_logger(__name__) _snake_case : Union[str, Any] = { "vocab_file": ...
81
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ...
122
0
"""simple docstring""" from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow f...
82
from __future__ import annotations def A(__a: list[int] , __a: list[int] , __a: int ): lowerCAmelCase_ = list(range(len(__a ) ) ) lowerCAmelCase_ = [v / w for v, w in zip(__a , __a )] index.sort(key=lambda __a : ratio[i] , ...
122
0
"""simple docstring""" lowerCAmelCase__ = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 10: '''a''', 11: '''b''', 12: '''c''', 13: '''d''', 14: '''e''', ...
83
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try:...
122
0
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCAmelCase = 0 UpperCAmelCase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], ...
84
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase__ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
122
0
from __future__ import annotations def _a ( lowercase__ : list ): '''simple docstring''' if not nums: raise ValueError('List is empty' ) return sum(lowercase__ ) / len(lowercase__ ) if __name__ == "__main__": import doctest doctest.testmod(...
85
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependency...
122
0
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline __a :Union[str, Any] = logging.get_logger(__name__) # pylint: disable=invalid-name class _a ( snake_case_ )...
86
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the r...
122
0
import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from transformers.configurat...
87
import unittest import numpy as np from datasets import load_dataset 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 ...
122
0
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def _snake_case ( __snake_case : d...
88
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
122
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : str = { "facebook/xglm-564M": "https://huggingface.co/facebook/xglm-564M/resolve/main/config.json", # See all ...
89
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
122
0
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import tr...
90
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowerCamelCase__ = 4 lowerCamelCase__ = 3 class __magic_name__ (__lowercase ): pass...
122
0
"""simple docstring""" from __future__ import annotations class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Optional[int] ,A_ : str ,A_ : str ) -> int: A , A = text, pattern A , A = len(A_ ), len(A_ ) def _SCRE...
91
import torch from torch import nn class __magic_name__ (nn.Module ): def __init__( self , _a , _a , _a , _a , _a=1 , _a=False ) -> str: super().__init__() lowerCAmelCase_ = n_token lowerCAmelCase_ = d_embed lowerCAme...
122
0
'''simple docstring''' 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_modelin...
92
from collections import defaultdict class __magic_name__ : def __init__( self , _a , _a ) -> Tuple: lowerCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are set to -1 lowerCAm...
122
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" return number | (1 << position) def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" return number & ~(1 << position)...
93
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow...
122
0
'''simple docstring''' def lowercase_ ( __A : int , __A : int ) -> int: """simple docstring""" return 1 if input_a == input_a else 0 def lowercase_ ( ) -> None: """simple docstring""" assert xnor_gate(0 , 0 )...
94
def A(__a: int = 50 ): lowerCAmelCase_ = [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_length + 1 ): ways_number[row_length] += ways_number[ row_length...
122
0
"""simple docstring""" def snake_case ( A__ ,A__ ): print("\nThe shortest path matrix using Floyd Warshall algorithm\n" ) for i in range(A__ ): for j in range(A__ ): if dist[i][j] != float("inf" ): print(int(dist[i][j] ) ,end="\t" ) else: ...
95
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 lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
0
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( SCREAMING_SNAKE_CASE_ ): UpperCAmelCase__ = "ClapFeatureExtractor" UpperCAmelCase__ = ("RobertaTokenizer", "R...
96
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
122
0
__a = 0 # The first color of the flag. __a = 1 # The second color of the flag. __a = 2 # The third color of the flag. __a = (red, white, blue) def a ( snake_case__: list ): '''simple docstring''' if not sequence: return [] ...
97
from math import factorial def A(__a: int , __a: int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n...
122
0
'''simple docstring''' from __future__ import annotations import queue class __lowerCAmelCase : """simple docstring""" def __init__( self : str , lowerCAmelCase__ : Optional[int] ) -> str: '''simple docstring''' _UpperCamelC...
98
from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def A(__a: str , __a: str ): lowerCAmelCase_ = len(__a ) lowerCAmelCase_ = ...
122
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_d...
99
from itertools import product def A(__a: int , __a: int ): lowerCAmelCase_ = sides_number lowerCAmelCase_ = max_face_number * dice_number lowerCAmelCase_ = [0] * (max_total + 1) lowerCAmelCase_ = 1 lowerCAmelCase_ =...
122
0