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
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowercase__ : Optional[int] ...
390
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeature...
64
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline __magic_name__: Tuple = { '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 'scale_grad...
324
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_C...
64
0
'''simple docstring''' import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowercase_ ( __A : Tuple ) -> Dict: """simple docstring""" def wrapper(*__A : Optional...
94
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def A__ ( ): SCREAMING_SNAKE_CASE__: U...
64
0
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int = 2_000_000 )-> Optional[Any]: _lowerCamelCase = [0 for i in range(n + 1 )] _lowerCamelCase = 1 _lowerCamelCase = 1 for i in range(2 , int(n**0.5 ...
650
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0'''))...
8
import numpy as np def A__ ( snake_case_ : str , snake_case_ : List[str] , snake_case_ : Dict , snake_case_ : Optional[int] , snake_case_ : Optional[int] ): SCREAMING_SNAKE_CASE__: List[Any]= int(np.ceil((x_end - xa) / h ) ) SCREAMING_...
64
0
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
615
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> List[Any]: SCREAMING_SNAKE_CASE__: Tuple= get_activation('''swish''' ) self.assertIsI...
64
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _a ( UpperCamel...
86
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase_ : Tuple = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> None: SCREAMING_SNAKE...
64
0
import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load_metric from .utils impo...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A : Optional[int] = logging.get_logger(__name__) A : Optional[Any] = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json', # See all ViT M...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __snake_case ( ) -> List[str]: lowercase : str = ArgumentParser( d...
607
def A__ ( snake_case_ : int ): if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE__: List[Any]= [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE__: List[str]= 1 if upper_limit > 0: SCREAMING_SNAKE_CASE_...
64
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Any = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', ...
448
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampl...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
0
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECK...
324
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
0
'''simple docstring''' from functools import lru_cache @lru_cache def lowercase_ ( __A : int ) -> List[Any]: """simple docstring""" if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ...
94
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ : Any = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', 'Blip2VisionConfig', ],...
64
0
"""simple docstring""" from math import sqrt def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> Tuple: _lowerCamelCase = 0 for i in range(1 , int(sqrt(snake_case_ ) + 1 ) ): if n % i == 0 and i != sqrt(snake_case_ ): ...
650
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase_ ) class _lowerCamelCase ( UpperCamelCase_ ): # `task` is not a ClassVar since we want it to be ...
64
0
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase__ : Optional[Any] = ...
8
import inspect import unittest class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> Any: try: import diffusers # noqa: F401 except ImportError: assert False def UpperCamelCase_ ( self ) -> List[str]: impo...
64
0
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGener...
615
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
64
0
from math import pi, sqrt, tan def __snake_case ( __UpperCamelCase : float ): """simple docstring""" if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values" ) return 6 * side_length**2 def __snake_case ( ...
86
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
64
0
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
37
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_device=False)...
64
0
from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( IMAGENET...
176
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
64
0
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCamelCase__ ( UpperCamelCa...
607
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase_ : Tuple = 3 def A__ ( snake_case_ : int ): print('''Generating primitive root of p''' ) while True: SCREAMING_SNAKE_CASE__: List[Any]= random.randrange(3 ...
64
0
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Optional[int] = { 'RUCAIBox/mvp': 'https://huggingfac...
448
from math import factorial def A__ ( snake_case_ : int , snake_case_ : 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 positiv...
64
0
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase__ : Tuple = 3 def __lowerCamelCase ( _UpperCamelCase : int ): '''simple docstring''' print('''Generating primitive root of p...
390
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeature...
64
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def UpperCamelCase ( _A, _A=False ): """simple docstring""" __magic_name__ : Optional[int] = OmegaConf.load(snake_case_ ) if display...
324
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_C...
64
0
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( __A : Optional[int] , __A : Optional...
94
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def A__ ( ): SCREAMING_SNAKE_CASE__: U...
64
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
650
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
0
'''simple docstring''' lowercase__ : Optional[Any] = tuple[float, float, float] lowercase__ : Dict = tuple[float, float, float] def _lowerCAmelCase ( __snake_case : Pointad , __snake_case : Pointad ) -> Any: ...
8
import numpy as np def A__ ( snake_case_ : str , snake_case_ : List[str] , snake_case_ : Dict , snake_case_ : Optional[int] , snake_case_ : Optional[int] ): SCREAMING_SNAKE_CASE__: List[Any]= int(np.ceil((x_end - xa) / h ) ) SCREAMING_...
64
0
__magic_name__ : Optional[Any] = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '.....
615
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> List[Any]: SCREAMING_SNAKE_CASE__: Tuple= get_activation('''swish''' ) self.assertIsI...
64
0
import math def __snake_case ( __UpperCamelCase : List[str] ,__UpperCamelCase : Optional[Any] ): """simple docstring""" if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(snake_case_ ) ...
86
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase_ : Tuple = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> None: SCREAMING_SNAKE...
64
0
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class A__ ( unittest.TestCase ): """simple docstring""" def _UpperCamelCase( self : List[Any] ): a__ : Tuple = get_activation("swish" ) self.assertIs...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
"""simple docstring""" import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __snake_case ( __A = 3 ) -> str: if isinstance(snake_case_ ,snake_case_ ): raise TypeError("""number...
607
def A__ ( snake_case_ : int ): if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE__: List[Any]= [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE__: List[str]= 1 if upper_limit > 0: SCREAMING_SNAKE_CASE_...
64
0
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class __SCREAMING_SNAKE_CASE : ...
448
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler,...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
0
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForMultipleCh...
324
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timeste...
94
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ : Any = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', 'Blip2VisionConfig', ],...
64
0
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : str , snake_case : str )-> Tuple: _lowerCamelCase = len(snake_case_ ) _lowerCamelCase = [] for i in range(len(snake_case_ ) - pat_len + 1 ): _lower...
650
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase_ ) class _lowerCamelCase ( UpperCamelCase_ ): # `task` is not a ClassVar since we want it to be ...
64
0
'''simple docstring''' import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbo...
8
import inspect import unittest class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> Any: try: import diffusers # noqa: F401 except ImportError: assert False def UpperCamelCase_ ( self ) -> List[str]: impo...
64
0
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ (UpperCamelCase_ ): lowercase_ : Any = "MCTCTFeatureExtractor" lowercase_ : Tuple = "AutoTokenizer" def __init__( self...
615
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
64
0
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature ...
86
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
64
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dimensi...
37
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_device=False)...
64
0
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class A : '''simple docstring''' __lowerCamelCase : Optional[Any] = None def a_ ( self : str ) -> ...
176
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
64
0
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification ...
607
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase_ : Tuple = 3 def A__ ( snake_case_ : int ): print('''Generating primitive root of p''' ) while True: SCREAMING_SNAKE_CASE__: List[Any]= random.randrange(3 ...
64
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 fr...
448
from math import factorial def A__ ( snake_case_ : int , snake_case_ : 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 positiv...
64
0
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowercase__ : List[Any] = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def __lowerCamelCase ( _UpperCamelCase : str = "mumbai" ...
390
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeature...
64
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 che...
324
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_C...
64
0
'''simple docstring''' # 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/LICENS...
94
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def A__ ( ): SCREAMING_SNAKE_CASE__: U...
64
0
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int | float | str )-> Dict: try: _lowerCamelCase = float(snake_case_ ) except ValueError: raise ValueError('Please enter a valid number' ) _lowerCamelCase ...
650
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example lowercase__ : Tuple = [ [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,...
8
import numpy as np def A__ ( snake_case_ : str , snake_case_ : List[str] , snake_case_ : Dict , snake_case_ : Optional[int] , snake_case_ : Optional[int] ): SCREAMING_SNAKE_CASE__: List[Any]= int(np.ceil((x_end - xa) / h ) ) SCREAMING_...
64
0
import numpy as np def a_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): lowerCAmelCase__ = int(np.ceil((x_end - xa) / h ) ) lowerCAmelCase__ = np.zeros((n + 1,) ) lowerCAmelCase__ = ...
615
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> List[Any]: SCREAMING_SNAKE_CASE__: Tuple= get_activation('''swish''' ) self.assertIsI...
64
0
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __a :Union[str, Any] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classifi...
86
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase_ : Tuple = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> None: SCREAMING_SNAKE...
64
0
from __future__ import annotations from collections.abc import Iterator from typing import Any class A__ : """simple docstring""" def __init__( self : List[Any] , lowerCamelCase__ : Union[str, Any] ): a__ : Any = data a__ : Node | None = None clas...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
"""simple docstring""" from itertools import permutations def __snake_case ( __A ) -> Optional[Any]: if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False lowercase :...
607
def A__ ( snake_case_ : int ): if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE__: List[Any]= [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE__: List[str]= 1 if upper_limit > 0: SCREAMING_SNAKE_CASE_...
64
0
'''simple docstring''' class __SCREAMING_SNAKE_CASE : def __init__( self ) ->List[str]: '''simple docstring''' __a = '''''' __a = '''''' __a = [] def __UpperCamelCase ( sel...
448
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=UpperCamelCase_ ): '''simple docstring''' lowerCAmelCase__ = ['''torch''', '''transformers''', '''onnx'''] def __init__( self : Tuple , *UpperC...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
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 ...
324
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
0
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switc...
94
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ : Any = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', 'Blip2VisionConfig', ],...
64
0
"""simple docstring""" import enum import shutil import sys A_ : Optional[int] =shutil.get_terminal_size() A_ : Union[str, Any] ={'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class __a ( enum.Enum ): SCREAMING_SNAKE_CASE__ : str = 0 SCRE...
650
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase_ ) class _lowerCamelCase ( UpperCamelCase_ ): # `task` is not a ClassVar since we want it to be ...
64
0
'''simple docstring''' def _lowerCAmelCase ( __snake_case : list , __snake_case : int = 0 ) -> Union[str, Any]: __A : Union[str, Any] = length or len(snake_case_ ) __A : Tuple = False for i in range(length - 1 ): ...
8
import inspect import unittest class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> Any: try: import diffusers # noqa: F401 except ImportError: assert False def UpperCamelCase_ ( self ) -> List[str]: impo...
64
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_a...
615
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
64
0
from __future__ import annotations from typing import Generic, TypeVar __a :Optional[Any] = TypeVar('T') class _a ( Generic[T] ): """simple docstring""" def __init__( self : Tuple , UpperCAmelCase : str ): A_ = d...
86
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
64
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impor...
37
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_device=False)...
64
0
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_s...
176
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
64
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from tr...
607
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase_ : Tuple = 3 def A__ ( snake_case_ : int ): print('''Generating primitive root of p''' ) while True: SCREAMING_SNAKE_CASE__: List[Any]= random.randrange(3 ...
64
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __UpperCamelCase : List[Any] = ...
448
from math import factorial def A__ ( snake_case_ : int , snake_case_ : 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 positiv...
64
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase__ : Tuple = TypeVar("T") class lowerCamelCase ( Generic[T] ): '''simple docstring''' def __init__( self : str ...
390
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeature...
64
0
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCamelCase ( _A, ...
324
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_C...
64
0
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel SCREAMING_SNAKE_CASE = HfApi() SCREAMING_SNAKE_CASE = {} # fmt: off SCREAMING_SNAKE_CASE = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1....
94
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def A__ ( ): SCREAMING_SNAKE_CASE__: U...
64
0
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __a ( UpperCamelCase_ ): def __init__( self , a__ , a__ ): _lowerCamelCase = params _lowerCamelCase ...
650
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
0
'''simple docstring''' # 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 ...
8
import numpy as np def A__ ( snake_case_ : str , snake_case_ : List[str] , snake_case_ : Dict , snake_case_ : Optional[int] , snake_case_ : Optional[int] ): SCREAMING_SNAKE_CASE__: List[Any]= int(np.ceil((x_end - xa) / h ) ) SCREAMING_...
64
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : List[Any] = logging.get_logger(__name__) __magic_name__ : Dict = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # ...
615
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> List[Any]: SCREAMING_SNAKE_CASE__: Tuple= get_activation('''swish''' ) self.assertIsI...
64
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __a :int = logging.get_logger(__name__) def __snake_case ( __UpperCamelCase : Any ,__UpperCamelCase :...
86
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase_ : Tuple = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> None: SCREAMING_SNAKE...
64
0
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCamelCase_ ( __a ) -> str: a__ : List[str] = {} a__ : List[str] = job['''started_at'''] a__ : int = job['''completed_at'''] a__ : str = da...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __lowerCamelCase ( __a :List[str] , __a :Optional[Any] , __a :Union[str, Any] , __a :Optional[int] , __a :Any ) -> ...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
"""simple docstring""" def __snake_case ( __A ) -> Dict: lowercase : Optional[Any] = int(snake_case_ ) if n_element < 1: lowercase : Union[str, Any] = ValueError("""a should be a positive number""" ) raise my_error lowerc...
607
def A__ ( snake_case_ : int ): if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE__: List[Any]= [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE__: List[str]= 1 if upper_limit > 0: SCREAMING_SNAKE_CASE_...
64
0
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) c...
448
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
0
'''simple docstring''' def __lowerCamelCase ( _UpperCamelCase : str ): '''simple docstring''' UpperCAmelCase_ = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) UpperCAmelCase_ = hex_num[0] == '''-''' ...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __magic_name__: int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: __magi...
324
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
0
'''simple docstring''' import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowercase_ ( __A : Dataset , __A : Dict[str, str] ) ...
94
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ : Any = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', 'Blip2VisionConfig', ],...
64
0
"""simple docstring""" from __future__ import annotations class __a : def __init__( self , a__ ): _lowerCamelCase = TypeError( 'Matrices must be formed from a list of zero or more lists containing at ' 'least one and the same n...
650
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase_ ) class _lowerCamelCase ( UpperCamelCase_ ): # `task` is not a ClassVar since we want it to be ...
64
0
'''simple docstring''' import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, X...
8
import inspect import unittest class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> Any: try: import diffusers # noqa: F401 except ImportError: assert False def UpperCamelCase_ ( self ) -> List[str]: impo...
64
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available()...
615
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
64
0
import os import pytest from attr import dataclass __a :Optional[Any] = 'us-east-1' # defaults region @dataclass class _a : """simple docstring""" _lowerCamelCase : Any = 4_2 _lowerCamelCase : Dict = 'arn:aws:iam:...
86
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
64
0
UpperCamelCase : List[str] = { 'Pillow': 'Pillow', 'accelerate': 'accelerate>=0.11.0', 'compel': 'compel==0.1.8', 'black': 'black~=23.1', 'datasets': 'datasets', 'filelock': 'filelock', 'flax': 'flax>=0.4.1', 'hf-doc-builder': 'hf-doc-builder>=0.3.0', 'huggingf...
37
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_device=False)...
64
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 tra...
176
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
64
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowerCAmelCase: List[Any] =logging.get_logger(__name__) class lowerCamelCase__ ( UpperCamelCase_ ): def __init__( self , *snak...
607
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase_ : Tuple = 3 def A__ ( snake_case_ : int ): print('''Generating primitive root of p''' ) while True: SCREAMING_SNAKE_CASE__: List[Any]= random.randrange(3 ...
64
0
'''simple docstring''' from __future__ import annotations from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self , lowerCamelCase , lowerCamelCase , lowerCamelCase = 0 ) ->None: '''simple docstring''' __a = ...
448
from math import factorial def A__ ( snake_case_ : int , snake_case_ : 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 positiv...
64
0
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration...
390
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeature...
64
0
import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer __magic_name__: int = l...
324
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_C...
64
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() SCREAMING_SNAKE_CASE = logging.get_logger(__name__) def lowercase_ ( __A : List[Any...
94
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def A__ ( ): SCREAMING_SNAKE_CASE__: U...
64
0
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
650
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
0
'''simple docstring''' def _lowerCAmelCase ( __snake_case : int ) -> Optional[int]: if not isinstance(snake_case_ , snake_case_ ): raise TypeError('Input value must be an \'int\' type' ) __A : Tuple = 0 while number: ...
8
import numpy as np def A__ ( snake_case_ : str , snake_case_ : List[str] , snake_case_ : Dict , snake_case_ : Optional[int] , snake_case_ : Optional[int] ): SCREAMING_SNAKE_CASE__: List[Any]= int(np.ceil((x_end - xa) / h ) ) SCREAMING_...
64
0
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_...
615
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> List[Any]: SCREAMING_SNAKE_CASE__: Tuple= get_activation('''swish''' ) self.assertIsI...
64
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokeniz...
86
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase_ : Tuple = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> None: SCREAMING_SNAKE...
64
0
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common im...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBen...
607
def A__ ( snake_case_ : int ): if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE__: List[Any]= [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE__: List[str]= 1 if upper_limit > 0: SCREAMING_SNAKE_CASE_...
64
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class __SCREAMING_SNAKE_CASE ( datasets.BeamBasedBuilder ): ...
448
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
0
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def __lowerCamelCase ( ...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
0