code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def _lowerCamelCase( lowercase__ ) -> list: '''simple docstring''' def merge(lowercase__ , lowercase__ ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right return list(_merg...
295
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_common import Mo...
295
1
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class _UpperCamelCase ( _A ): '''simple docstring''' @require_torch def lowerCAmelCase__ ( self : List[Any] ): ...
223
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers.ut...
223
1
import os def _UpperCAmelCase ( ): with open(os.path.dirname(SCREAMING_SNAKE_CASE__ ) + '/p022_names.txt' ) as file: __UpperCamelCase =str(file.readlines()[0] ) __UpperCamelCase =names.replace('"' , '' ).split(',' ) names.sort() ...
62
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) a_ = {name: getattr(transformers, name + '''Fast''') for name in SLOW_TO_FAST_CONVERTERS} de...
340
0
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __lowerCamelCase (UpperCAmelCase__ : int ): if ( (cp >= 0X4_e_0_0 and cp <= 0X9_f_f_f) or (cp >= 0X3_4_0_0 and cp <= 0X4_d_b...
369
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : int = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { '''microsoft/unispeech-sat-base-100h-libri-ft''': ( ''...
206
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, 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 ...
229
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : Tuple = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP...
218
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConfig""", ...
112
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __lowerCAmelCase ( lowercase : Union[str, Any] , lowercase : Optional[int]=False ) -> Union[str, Any]: """simple docstrin...
112
1
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_uti...
101
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer lowercase__ :List[Any] = logging.get_logger(__name__) lowercase__ :Optional[Any] ...
101
1
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class UpperCamelCase ( snake_case ): """simple docstring""" def __init__( self ,UpperCAmelCase_ ,UpperCAmel...
363
"""simple docstring""" UpperCAmelCase: str = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.g...
336
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple def a_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : float ): '''simple docstring''' lowercase__ : Union[str, Any] = namedtuple('result' ...
77
"""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_modeling...
77
1
'''simple docstring''' from collections.abc import Sequence from queue import Queue class a_ : def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=Non...
368
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) ...
183
0
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging __a = logging.get_logger(__name__) __a = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", # See all M-CTC-T models at https:...
66
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _snake_case ( A__ ): _lowercase : int = '''Speech2TextFeatureExtractor''' _lowercase : List[Any] = '''Speech2TextTokenizer''' def __init__( ...
137
0
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 Up...
370
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # sinc...
262
0
"""simple docstring""" import math def _snake_case ( lowercase__ ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 a...
96
import numpy as np import datasets _snake_case = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was introduced by Prof. P. C. Mah...
157
0
'''simple docstring''' import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_...
353
'''simple docstring''' import unittest from transformers import LiltConfig, 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_modeli...
187
0
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
340
from collections import defaultdict from math import gcd def _a ( UpperCamelCase_ : int = 1_500_000 ) -> int: """simple docstring""" lowerCAmelCase__ = defaultdict(UpperCamelCase_ ) lowerCAmelCase__ = 2 while 2 * euclid_m ...
340
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor lowerCamelCase_ : str = logging.get_logger(__name__) class __A ( _SCREAMING_SNAKE_CASE ): ...
364
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ ...
215
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaT...
94
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowerCamelCase :Tuple = logging.get_logger(__name...
206
0
from math import sqrt def UpperCAmelCase_ ( __UpperCAmelCase : int ) -> int: SCREAMING_SNAKE_CASE_ = 0 for i in range(1 , int(sqrt(__UpperCAmelCase ) + 1 ) ): if n % i == 0 and i != sqrt(__UpperCAmelCase ): ...
355
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def UpperCAmelCase_ ( __UpperCAmelCase : Optional[int] ) -> int: if not is_accelerate_available(): return method SCREAMING_SNAKE_...
210
0
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: int ): if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" ) return sum( divi...
112
'''simple docstring''' import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
112
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ : Dict = logging.get_logger(__name__) A_ : List[st...
349
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ : Union[str, Any] = logging.get_logger(__name__) A_ ...
349
1
from manim import * class snake_case_ ( lowerCamelCase__ ): def __UpperCamelCase ( self : int ) -> Union[str, Any]: lowercase__ : List[Any] = Rectangle(height=0.5 , width=0.5 ) lowercase__ : Tuple = Rec...
87
import numpy # List of input, output pairs _lowerCamelCase : Dict = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) _lowerCamelCase : str = (((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9), 1_5_0)) _lowerCame...
336
0
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig lowerCAmelCase_ : Union[str, Any] = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.js...
369
"""simple docstring""" from __future__ import annotations import math def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3...
248
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Any = logging.get_logger(__name__) a__ : Dict = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/re...
80
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_...
183
0
"""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_comm...
321
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
321
1
import warnings from functools import wraps from typing import Callable def A (__A : Callable ) -> Callable: """simple docstring""" @wraps(__A ) def _inner_fn(*__A : Dict , **__A : int ): warnings.warn( ...
51
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Optional[Any] =logging.get_logger(__name__) _UpperCAmelCase : str ={ """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json""", # See all ViT MAE mo...
262
0
from manim import * class lowerCAmelCase__( __lowercase ): '''simple docstring''' def UpperCamelCase_ ( self ) -> Any: _SCREAMING_SNAKE_CASE : List[Any] = Rectangle(height=0.5 , width=0.5 ) _SCREAMI...
325
from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ (__lowerCamelCase ): return DownloadCommand(args.model, args.cache_dir, args.force, args.trust_remote_code ) class lowerCAmelCase__( __lowercase ): '''simp...
325
1
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# _a : Optional[int]= [ # (stable-diffusion, HF Diffusers) ("time_embed.0.we...
172
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, B...
187
0
from math import pi def __lowerCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
350
from math import log from scipy.constants import Boltzmann, physical_constants lowerCAmelCase__ = 300 # TEMPERATURE (unit = K) def __lowerCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , ): if donor_conc <= 0: raise ValueError('Dono...
119
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from tran...
271
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ : Optional[Any] = { """configuration_llama""": ["""LLAMA_PRETRAINED_C...
215
0
import math import unittest def lowerCAmelCase_ ( __lowerCamelCase ): assert isinstance(__lowerCamelCase , __lowerCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
134
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
134
1
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .te...
184
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=_UpperCAmelCase ): """simple docstring""" __a : Dict = ['''keras_nlp'''] def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ ) -> Tuple: '''si...
210
0
"""simple docstring""" import itertools import math def _snake_case ( lowercase__ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
1
"""simple docstring""" import itertools import math def _snake_case ( lowercase__ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
1
1
'''simple docstring''' import numpy as np def __lowerCamelCase ( _lowercase ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
265
'''simple docstring''' from PIL import Image def __lowerCamelCase ( _lowercase , _lowercase ) -> Image: def brightness(_lowercase ) -> float: return 1_2_8 + level + (c - 1_2_8) if not -255.0 <= level <= 255.0: raise ValueError("""level must b...
265
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentPars...
364
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_uti...
327
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Accelera...
282
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) __snak...
248
0
"""simple docstring""" import math import sys def __lowercase ( _a ): if number != int(_a ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value of input must not be a negative number''' ) if number == ...
155
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase__ : str = { '''configuration_resnet''': ['''RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP...
155
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class a__ ( metaclass=SCREAMING_SNAKE_CASE__ ): _lowerCamelCase = ['transformers', 'torch', 'note_seq'] def __init__( self : Dict, *lowerCAmelCase : Dict, **lo...
255
"""simple docstring""" import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, ...
255
1
'''simple docstring''' import torch from transformers import AutoModel class _a ( torch.nn.Module ): def __init__( self ,_SCREAMING_SNAKE_CASE="sayef/fsner-bert-base-uncased" ) -> List[str]: super(_SCREAMING_SNAKE_CASE ,self ).__init__() ...
142
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ : Union[str, Any] = {'''configuration_plbart''': ['...
142
1
from manim import * class A__ ( lowerCAmelCase__ ): def a__ ( self : List[str] ) -> Optional[int]: """simple docstring""" __lowercase = Rectangle(height=0.5 , width=0.5 ) __lowercase = Rectangle(height=0.25 , w...
325
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("""ignore""", category=UserWarning, module="""torch.optim.lr_scheduler""") class A__ : def __init__( se...
325
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = """▁""" UpperCAmelCas...
362
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = {"""configuration_vit_msn""": ["""VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTMSNConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
267
0
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _SCREAMING_SNAKE_CASE : Dict = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _SCREAMING_SNAKE_CASE : Optional[Any] = typing...
85
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, UNetaDCon...
119
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
364
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Model...
141
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : list[int] ) -> list[int]: """simple docstring""" A__ : Tuple =len(__snake_case ) for i in range(__snake_case ): for j in range(i + 1, __snake_case ...
134
'''simple docstring''' import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Model...
134
1
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets a_ = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto acc...
359
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( snake_case_ : int ) ->str: '''simple docstring''' if not isinstance(snake_case_ ,snake_case_ ): raise TypeError('''Undefined for no...
291
0
'''simple docstring''' import itertools import math def lowerCAmelCase_ ( snake_case_ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # ...
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE_: Union[str, Any] =logging.get_logger(__name__) class __A ( UpperCamelCase__ ): def __init__(self : int , *__a : Dict , *...
1
1
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_c...
356
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax imp...
96
0
"""simple docstring""" from __future__ import annotations import math lowercase__ : List[str] = """2020.9.26""" lowercase__ : Optional[int] = """xcodz-dot, cclaus, dhruvmanila""" def UpperCamelCase_ ( lowerCAmelCase__ : float , lowerCAmel...
224
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging UpperCAmelCase = logging.get_logger(__na...
256
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel f...
227
'''simple docstring''' A : Dict = '''Alexander Joslin''' import operator as op from .stack import Stack def lowerCAmelCase__ ( lowerCamelCase : str ): _A : Dict = {'*': op.mul, '/': op.truediv, '+': op.add, '-': op.sub} _A : St...
227
1
"""simple docstring""" def lowercase (snake_case__ : list[list[int | float]] ) -> int: '''simple docstring''' lowerCAmelCase = len(snake_case__ ) lowerCAmelCase = len(matrix[0] ) lowerCAmelCase = min(...
155
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from a...
155
1
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline a =logging.get_logger(__name__) # pylint: disable=invalid-name class A_ ( SCREAMING_SNAKE_CASE ): def __...
113
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFC...
113
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase_ ) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): _UpperCAmelCase : str = fiel...
142
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) ...
142
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, lo...
135
'''simple docstring''' from __future__ import annotations from collections.abc import Callable lowerCamelCase :List[Any] = list[list[float | int]] def a ( lowerCamelCase__ , lowerCamelCase__ ): '''simple docstring''' A_ : int = len(lowerCamelCas...
135
1
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import...
172
lowerCamelCase_ = frozenset( [ '''prompt''', '''height''', '''width''', '''guidance_scale''', '''negative_prompt''', '''prompt_embeds''', '''negative_prompt_embeds''', '''cross_attention_kwargs''', ] ) lowerCamelCase_ = frozen...
244
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=UpperCamelCase__ ): """simple docstring""" _snake_case : Optional[int] = ["""speech"""] def __init__( self : Tuple , *lowerCAm...
368
'''simple docstring''' from cva import destroyAllWindows, imread, imshow, waitKey def a__ ( lowercase : str ) -> Optional[int]: """simple docstring""" _UpperCamelCase , _UpperCamelCase = img.shape[0], img.shape[1] # converting each pixel's color to its nega...
287
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, get_resize_output_image_size, normalize, rescale, resiz...
25
'''simple docstring''' from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCAmelCase = logging.get_logger(__name__) def __UpperCamelCase ( ...
141
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_albert import Alb...
361
from __future__ import annotations def __lowerCamelCase ( __magic_name__ : str , __magic_name__ : Any , __magic_name__ : List[Any] , __magic_name__ : str ): # noqa: E741 while r - l > 1: a__: Any =(l + r) // 2 if v[m] >...
42
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 from ..auto import CONFIG_MAPPING _a = logging.get_logger(__name__) _a = { """...
209
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase : Dict = logging.get_logger(__name__) def a__ ( snake_case__ ) ...
291
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow #...
200
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase...
200
1
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _a = logging.get_logger(__name__) _a = { 't5-small': 'https://huggingface.co/t5-small/resolve/main/confi...
17
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = {"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""} class lower...
96
0
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def A(__a: List[str] , __a: str=None ): lowerCAmelCase_ = None if token is not None: lowerCAmelCase_ = {"""Accept""": """application...
354
import datasets lowerCamelCase__ = '''\ @InProceedings{conneau2018xnli, author = "Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. and Schwenk, Holger ...
22
0
def a( A : float , A : int ) -> float: """simple docstring""" if digit_amount > 0: return round(number - int(A ) , A ) return number - int(A ) if __name__ == "__main__": print(decimal_isolate(1.53, 0)) print(de...
227
def a( A : list ) -> list: """simple docstring""" if any(not isinstance(A , A ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(A ) ): for i, (...
227
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Any = logging.get_logger(__name__) a : Dict = { 'roberta-base': 'https://huggingface.co/roberta-b...
358
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets a : Dict = datasets.logging.get_logger(__name__) a : Any = '\\n@InProceedings{moosavi2019minimum,\n ...
82
0
"""simple docstring""" import os from math import logaa def lowercase (SCREAMING_SNAKE_CASE_ : str = "base_exp.txt" ) -> int: SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = 0 for i, line in enumerate(open(os.path.join(os.path.d...
113
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase (SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : Any=False ) -> str: SCREAMING_SNAKE_CASE = ...
113
1
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, rescale, resize, t...
308
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 _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase : ...
308
1
"""simple docstring""" import qiskit def lowercase_ ( _lowerCamelCase: int , _lowerCamelCase: int ) -> qiskit.result.counts.Counts: '''simple docstring''' __lowerCamelCase : Optional[Any] = qiskit.Aer.get_backend("aer_simulator" ) ...
135
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTok...
135
1
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor A_ : Optional[int] = logging.getLogger(__name__) A_ : List[Any] = 50 # max width of l...
363
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable A_ : List[Any] = {'configuration_gpt_neox': ['GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoXConfig']} try: if not is_tokenizers_avail...
141
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smartaa_...
308
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, Hf...
308
1
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class UpperCamelCase ( lowercase__ ): ''...
360
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_...
252
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_torc...
310
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
42
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowercase ( metaclass=SCREAMING_SNAKE_CASE__ ): lowercase_ : Optional[Any] =['''note_seq'''] def __init__( self ,*A__ ,**A__): requires_backends(self ,['''note_seq''']) ...
356
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dist...
97
0
'''simple docstring''' 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 accelera...
200
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class lowercase__ ( unittest.TestCase ): '''simple docstring''' def UpperCAmelCase_ ( self ): _SCREAMING_SNAKE_CASE : str = [10, 20, 30, 40, 50, 60] ...
200
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class ...
363
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowerCamelCase (a_ :List[Any]) -> ...
172
0
import os from datetime import datetime as dt from github import Github _snake_case = [ "good first issue", "feature request", "wip", ] def lowerCAmelCase_ ( ): _A : Dict = Github(os.environ["""GITHUB_TOKEN"""] ) _A : Union[str...
26
'''simple docstring''' import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files" , [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "dataset_inf...
22
0
"""simple docstring""" UpperCAmelCase_ : Optional[Any] = '''\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/tr...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not...
62
0
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppToken...
50
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A__ = logging.get_logger(__name__) A__ = { """sail/poolformer_s12""": """https...
82
0
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class A_ ( nn.Module ): _lowerCamelCase : Union[str, Any] = 42 _lowerCamelCase ...
353
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils....
156
0
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, rescale, resize, ...
308
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def snake_case( ) -> int: '''simple docstring''' lowercase : List[str] = ArgumentP...
308
1
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class __lowercase : '''simple docstring''' def _...
350
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig'...
188
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def lowerCamelCase__ ( _a , _a): return math.sqrt(sum(pow(a - b , 2) for a, b in zip(_a , _a))) def lowerCamelCase__ ( _a , _a): if dataset.ndim != value_array...
76
'''simple docstring''' UpperCAmelCase = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' UpperCAmelCas...
141
0
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLayer, ...
350
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowercase( UpperCamelCase_ = True , *UpperCamelCase_ , **UpperCamelCase_ ) -> int: '''simple docstring''' if not is_tqdm_available(): ...
165
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline A__ : Union[str, Any] = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does not use value network ...
103
"""simple docstring""" _UpperCamelCase : List[str] = { 'meter': 'm', 'kilometer': 'km', 'megametre': 'Mm', 'gigametre': 'Gm', 'terametre': 'Tm', 'petametre': 'Pm', 'exametre': 'Em', 'zettametre': 'Zm', 'yottametre': 'Ym', } # Exponent of the factor(meter) _UpperCame...
220
0
"""simple docstring""" def __lowerCamelCase ( ) -> Optional[Any]: """simple docstring""" lowerCAmelCase_ : Optional[Any] = [] lowerCAmelCase_ : Dict = 1 while len(__UpperCamelCase ) < 1e6: constant.append(str(__UpperCamelCase ) ) i...
161
"""simple docstring""" def __lowerCamelCase ( __UpperCamelCase ) -> list: """simple docstring""" if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence lowerCAmelCase_ : Optional[Any] = gray_code_sequenc...
161
1
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSched...
144
'''simple docstring''' from datetime import datetime as dt import os from github import Github __snake_case = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def a ( ) -> List[s...
97
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase : int = """▁""" lowerCAmelCase : Optional[Any] = {"""...
359
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[int] = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: ...
127
0
"""simple docstring""" import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
54
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from tra...
172
0
from ...configuration_utils import PretrainedConfig class _UpperCAmelCase ( _UpperCAmelCase ): """simple docstring""" a_ = "bert-generation" def __init__( self : List[Any] , lowerCAmelCase_ : Optional[int]=5_0_3_5_8 , lowerCAmelCase_ : Dict=1_0_2_4 , lowerCAmelCas...
352
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def a_ ( lowerCAmel...
207
0
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, require...
15
from __future__ import annotations import math class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ ) -> None: __UpperCamelCase =size # approximate the overall size of segment tree with given value __UpperCame...
62
0
from __future__ import annotations def _lowerCAmelCase ( UpperCAmelCase : list[float] , UpperCAmelCase : list[float] ): '''simple docstring''' UpperCamelCase__ : List[str] =sorted(numsa + numsa ) UpperCamelCase__ : Optional[A...
360
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device _SCREAMING_SNAKE_CASE : str = False class __a (...
157
0
"""simple docstring""" import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig _a : str = { 'facebook/maskformer-swin-base-ade...
44
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
156
0
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def _A ( UpperCamelCase_ : Tuple, UpperCamelCase_ : Optional[Any], UpperCamelCase_ : Optional[Any]) -> Optional[Any]: '''simple ...
144
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, ...
144
1
"""simple docstring""" import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def lowercase ( A_ )-> List[Any]: '''simple docstring''' monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_w...
40
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUI...
188
0
'''simple docstring''' import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
366
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
160
0
'''simple docstring''' import os import sys import unittest _A : List[str] =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 impo...
41
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCamelCase (nn.Module ): lowerCamelCase__ : int lowerCame...
165
0
from dataclasses import dataclass, field from typing import Optional @dataclass class __a: """simple docstring""" lowerCAmelCase = field( default='''codeparrot/codeparrot''' , metadata={'''help''': '''Model name or path of model to be trained.'''} ) lowerCA...
235
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) f...
235
1
'''simple docstring''' 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, BertConf...
161
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xf...
161
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) _A = { 'configuration_speecht5': [ 'SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SPEECHT5_PRETRAINED_HIFIGAN_CONFI...
370
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowercase_ ( A__ ) -> bool: """simple docstring""" snake_case = int(number**0.5 ) return number == sq * sq def lowercase_ ( A__ ,...
137
0
import unittest from knapsack import greedy_knapsack as kp class __A( unittest.TestCase ): def SCREAMING_SNAKE_CASE_ ( self ) -> Any: '''simple docstring''' __a = [10, 20, 30, 40, 50, 60] __a = [2, 4, 6, 8, 10, 12] _...
6
from __future__ import annotations _SCREAMING_SNAKE_CASE : Optional[int] = [] def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_ ): """simple docstring""" for i in range(len(UpperCamelCase_ ) ): if board[ro...
127
0
"""simple docstring""" from __future__ import annotations UpperCAmelCase__ = 'Muhammad Umer Farooq' UpperCAmelCase__ = 'MIT' UpperCAmelCase__ = '1.0.0' UpperCAmelCase__ = 'Muhammad Umer Farooq' UpperCAmelCase__ = 'contact@muhammadumerfarooq.me' UpperCAmelCase__ ...
370
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCAmelCase__ : __a = 42 __a = 42 class lowerCAmelCase__ : ...
40
0
'''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 i...
41
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def __lowerCamelCase ( ) -> tuple[list[int], int]: """simple docstring""" _SCREAMING_SNAKE_CASE = [randint(-10_00 ...
306
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __UpperCamelCase ( ...
294
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Tuple = { 'configuration_distilbert': [ '...
294
1