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
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaForS...
25
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
1
# 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 ( ...
25
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
1
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken log...
25
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
25
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionConfig', ], 'proc...
25
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
1
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', 'merges_file': 'merges.txt', } a_ = { 'vocab_...
25
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
25
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a_ =...
25
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( BitConfig, ViTHybridC...
25
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
1
import math def lowerCamelCase__ ( _a = 100): SCREAMING_SNAKE_CASE : Tuple = sum(i * i for i in range(1 , n + 1)) SCREAMING_SNAKE_CASE : Optional[int] = int(math.pow(sum(range(1 , n + 1)) , 2)) return square_of_sum - sum_of_squares if __name__ == "_...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
print((lambda quine: quine % quine)('print((lambda quine: quine %% quine)(%r))'))
25
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
1
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
1
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation a_ ...
25
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
1
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCamelCase ( self : Dict ) -> Tuple...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig']} try: if not is_sen...
25
1
import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimensio...
25
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 ( unittest.TestCase ): '''simpl...
25
1
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: i...
25
1
import gc import threading import time import psutil import torch class _UpperCamelCase : '''simple docstring''' def __init__( self : Optional[Any] ) -> List[Any]: """simple docstring""" SCREAMING_SNAKE_CASE : int = psutil.Process() SCREAMING_...
25
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chi...
25
1
a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def lowerCamelCase__ ( ): SCREAMING_SNAKE_CASE : Union[str, Any] = input("Enter message: ") SCREAMING_SNAKE_CASE : Dict = input("Enter key [alphanumeric]: ") SCREAMING_SNAKE_CASE : str = input("Encrypt/Decrypt [e/d]: "...
25
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ = logging.getLogger(__...
25
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'microsoft/beit-base-patch16-224-pt22k': ( ...
25
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type=str, required=True, help='Pa...
25
1
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 ( unittest.TestCase ): '''simpl...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Op...
25
1
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCamelCase ( self : Tuple ) -> Dict: ...
25
from math import pi, sqrt, tan def lowerCamelCase__ ( _a): if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values") return 6 * side_length**2 def lowerCamelCase__ ( _a , _a , _a): if length < 0 or breadth < 0 or height < 0: raise Value...
25
1
import string def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Union[str, Any] = "" for i in sequence: SCREAMING_SNAKE_CASE : int = ord(_a) if 65 <= extract <= 90: output += chr(155 - extract) elif 97 <= extract <= 122: output += chr(219 - extract) else: ou...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlipQFormerConfig', 'InstructBlipVis...
25
1
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ = logging.get_logger(__name__) a_ = { 'Visual-Attention-Network/van-base': ( 'https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json' ), } class _UpperCamelCase (...
25
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = 2 SCREAMING_SNAKE_CASE : Optional[int] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_a) if n > 1: factors.append(_a) return factors ...
25
1
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: i...
25
from math import factorial, pi def lowerCamelCase__ ( _a , _a = 30): if not isinstance(_a , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstance(_a , _a) or accuracy <= 0: raise ValueError("maclaurin_sin() requires a...
25
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment, ...
25
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
1
import argparse import struct import unittest class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : bytes ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Tuple = data # Initialize hash values SCRE...
25
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
25
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
25
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/config.json', 'funnel-transformer/small-base': 'https://huggingface.co/funnel...
25
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
1
import os import unicodedata 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 a_ = logging.get_logger(__name__) a_ = {'vocab_file': 'spiece.mo...
25
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
25
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Optional...
25
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
1
a_ = range(2, 20 + 1) a_ = [10**k for k in range(ks[-1] + 1)] a_ = {} def lowerCamelCase__ ( _a , _a , _a , _a): SCREAMING_SNAKE_CASE : Dict = sum(a_i[j] for j in range(_a , len(_a))) SCREAMING_SNAKE_CASE : str = sum(...
25
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Op...
25
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
1
from __future__ import annotations import requests a_ = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories created_utc downs\nedited gilde...
25
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
1
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1337 , num_examples=42 , dataset_name="my_datas...
25
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
1
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig']} try: if not is_sen...
25
1
def lowerCamelCase__ ( _a = 4000000): SCREAMING_SNAKE_CASE : Optional[int] = [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : int = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_a) SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : List[str] = b, a + b ...
25
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 ( unittest.TestCase ): '''simpl...
25
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a_ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: a_ = ['BartphoTo...
25
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: i...
25
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_xlnet': ['XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLNetConfig']} try...
25
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chi...
25
1
import logging import os from .state import PartialState class _UpperCamelCase ( logging.LoggerAdapter ): '''simple docstring''' @staticmethod def __UpperCamelCase ( a : int ) -> Optional[int]: """simple docstring""" SCREAMING_SNAKE_CASE : Dict ...
25
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ = logging.getLogger(__...
25
1
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = 2 SCREAMING_SNAKE_CASE : Optional[int] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_a) if n > 1: factors.append(_a) return factors ...
25
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type=str, required=True, help='Pa...
25
1
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 lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : List[Any] = args.log_outputs SCREAMING_SNA...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Op...
25
1
def lowerCamelCase__ ( _a , _a): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
25
from math import pi, sqrt, tan def lowerCamelCase__ ( _a): if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values") return 6 * side_length**2 def lowerCamelCase__ ( _a , _a , _a): if length < 0 or breadth < 0 or height < 0: raise Value...
25
1
from collections.abc import Generator def lowerCamelCase__ ( ): SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Dict = 0, 1 while True: SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : List[Any] = b, a + b yield b def lowerCamelCase__ ( _a = 1000): SCREAMING_SNAKE...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlipQFormerConfig', 'InstructBlipVis...
25
1
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging a_ ...
25
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = 2 SCREAMING_SNAKE_CASE : Optional[int] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_a) if n > 1: factors.append(_a) return factors ...
25
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
25
from math import factorial, pi def lowerCamelCase__ ( _a , _a = 30): if not isinstance(_a , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstance(_a , _a) or accuracy <= 0: raise ValueError("maclaurin_sin() requires a...
25
1
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Any = [] SCREAMING_SNAKE_CASE : Union[str, Any] = [] SCREAMING_SNAKE_CASE : ...
25
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
1
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_cards - usef...
25
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
1
def lowerCamelCase__ ( _a , _a = False): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : List[Any] = f"Expected string as input, found {type(_a)}" raise ValueError(_a) if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : List[Any] = f"Expected b...
25
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
25
1
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): raise ValueError("multiplicative_persistence() only accepts integral values") if num < 0: raise ValueError("multiplicative_persistence() does not accept negative values") SCREAMING_SNAKE_CASE : int = 0 SCREAMING_SNAKE_C...
25
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
1
from collections import Counter from timeit import timeit def lowerCamelCase__ ( _a = "" , ): return sum(c % 2 for c in Counter(input_str.replace(" " , "").lower()).values()) < 2 def lowerCamelCase__ ( _a = ""): if len(_a) == 0: return True SCREAMING_SNAKE_CASE : List[An...
25
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
25
1
import heapq def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, so I used -1*len...
25
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
1
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTester fro...
25
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
1
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from tra...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import...
25
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from...
25
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfig'], 'convert_funnel_original...
25
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
1
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _UpperCamelCase ( __A )...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig']} try: if not is_sen...
25
1
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) a_ = { 'post_extract_proj': 'feature_projection.projection', 'encoder.pos_conv....
25
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 ( unittest.TestCase ): '''simpl...
25
1
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def lowerCamelCase__ ( _a=None , _a...
25
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: i...
25
1
class _UpperCamelCase : '''simple docstring''' def __init__( self : List[Any] ) -> Optional[int]: """simple docstring""" SCREAMING_SNAKE_CASE : Optional[int] = {} def __UpperCamelCase ( self : Dict ) -> None: """simp...
25
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chi...
25
1
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mixin ...
25
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ = logging.getLogger(__...
25
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType a_ ...
25
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type=str, required=True, help='Pa...
25
1
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Op...
25
1
import pytest a_ = '__dummy_dataset1__' a_ = '\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/"\nURLS = {"train": REPO_URL + "wikiann-bn-train.jsonl", "validation": REPO_URL + "wikiann-bn-validation.jsonl"}\...
25
from math import pi, sqrt, tan def lowerCamelCase__ ( _a): if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values") return 6 * side_length**2 def lowerCamelCase__ ( _a , _a , _a): if length < 0 or breadth < 0 or height < 0: raise Value...
25
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json' ), } class _UpperC...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlipQFormerConfig', 'InstructBlipVis...
25
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import Interp...
25
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = 2 SCREAMING_SNAKE_CASE : Optional[int] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_a) if n > 1: factors.append(_a) return factors ...
25
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _UpperCamelCase ( __A ): '''simple docstring''' lowerCamelCase__ =['image_processor', 'tokenizer'] lowerCamelCase__ ='ViTImageProcessor' lower...
25
from math import factorial, pi def lowerCamelCase__ ( _a , _a = 30): if not isinstance(_a , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstance(_a , _a) or accuracy <= 0: raise ValueError("maclaurin_sin() requires a...
25
1
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __A ): '''simple docstring''' lowerCamelCase__ =(PNDMScheduler,) lowerCamelCase__ =(('num_inference_steps', 50),) def __...
25
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
1
import math def lowerCamelCase__ ( _a , _a = 0 , _a = 0): SCREAMING_SNAKE_CASE : List[str] = end or len(_a) for i in range(_a , _a): SCREAMING_SNAKE_CASE : List[Any] = i SCREAMING_SNAKE_CASE : Any = array[i] while temp_index != star...
25
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_glpn': ['GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GLPNConfig']} try: if not is_vision_available(): raise OptionalDependencyNotAvailable() e...
25
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
25
1
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( _a , _a , _a): # Initialise PyTorch model SCREAMING_SNAKE_CASE : Optional[i...
25
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
1
def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = int(_a) if decimal in (0, 1): # Exit cases for the recursion return str(_a) SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : int = divmod(_a , 2) return binary_recursive(_a) + str(_a) def lowerCam...
25
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
25
1
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test...
25
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
1
def lowerCamelCase__ ( _a): if n == 1 or not isinstance(_a , _a): return 0 elif n == 2: return 1 else: SCREAMING_SNAKE_CASE : Optional[int] = [0, 1] for i in range(2 , n + 1): sequence.append(sequence[i - 1] + sequence[i - 2]) return sequence[n] def lowerC...
25
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
1
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor import ...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_v...
25
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
1
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a_ = '2.13.1' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('3.7'): raise ImportWarning( '...
25
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
1
import math def lowerCamelCase__ ( _a): 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 are not primes return False # All primes number are in format of 6k +/- 1 for i in range(...
25
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_reformer': ['REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ReformerConfig']} try: if not ...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig']} try: if not is_sen...
25
1
from __future__ import annotations def lowerCamelCase__ ( _a , _a = None , _a = None): if start is None: SCREAMING_SNAKE_CASE : List[str] = 0 if end is None: SCREAMING_SNAKE_CASE : List[Any] = len(_a) - 1 if start >= end: return SCREAMING_SNAKE_CASE...
25
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 ( unittest.TestCase ): '''simpl...
25
1
from __future__ import annotations def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : str = 0 SCREAMING_SNAKE_CASE : Tuple = len(_a) - 1 while i < j: if nums[i] + nums[j] == target: return [i, j] elif nums[i] + nums[j] < target: SCREAMING_SNAKE_CASE :...
25
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = 0 while b > 0: i...
25
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, Stab...
25
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chi...
25
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a_ = { 'configuration_roberta_prelayernorm': [ 'ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Rober...
25
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ = logging.getLogger(__...
25
1
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_safe i...
25
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type=str, required=True, help='Pa...
25
1
from pathlib import Path import fire def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[int] = Path(_a) SCREAMING_SNAKE_CASE : Dict = Path(_a) dest_dir.mkdir(exist_ok=_a) for path in src_dir.iterdir(): SCREAMING_SNAKE_CASE : List[Any]...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Op...
25
1
from string import ascii_uppercase a_ = {str(ord(c) - 55): c for c in ascii_uppercase} def lowerCamelCase__ ( _a , _a): if isinstance(_a , _a): raise TypeError("int() can't convert non-string with explicit base") if num < 0: raise ValueError("parameter must be positive int"...
25
from math import pi, sqrt, tan def lowerCamelCase__ ( _a): if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values") return 6 * side_length**2 def lowerCamelCase__ ( _a , _a , _a): if length < 0 or breadth < 0 or height < 0: raise Value...
25
1
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def lowerCamelCase__ ( _a , _a , _a): SCREAMING_SNAKE_CASE : Optional[Any] = { "en": "Machine learning is great, isn't it?", "ru": "Машинное обучение - это здорово, не так ли?", "de": ...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlipQFormerConfig', 'InstructBlipVis...
25
1
from ...configuration_utils import PretrainedConfig a_ = { 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co/google/tapas-base-finetuned-wtq/resol...
25
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = 2 SCREAMING_SNAKE_CASE : Optional[int] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_a) if n > 1: factors.append(_a) return factors ...
25
1
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
from math import factorial, pi def lowerCamelCase__ ( _a , _a = 30): if not isinstance(_a , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstance(_a , _a) or accuracy <= 0: raise ValueError("maclaurin_sin() requires a...
25
1
from __future__ import annotations def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Dict = [True] * limit SCREAMING_SNAKE_CASE : Union[str, Any] = False SCREAMING_SNAKE_CASE : Optional[int] = False SCREAMING_SNAKE_CASE : Any = True for i in r...
25
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
1
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
25
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _Uppe...
25
1
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Optional[Any] = [ "encoder.version", "decoder.version", "model.encoder.version", "model.decoder.vers...
25
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
25
1
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel a_ = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.self', 'self.proj': 'output.dense', 'attention....
25
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
1
from __future__ import annotations import typing from collections import Counter def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1): for perpendicular in range(_a , max_perimeter + 1): SCREAMING_...
25
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
25
1
import argparse import json 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 Acce...
25
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
1
from __future__ import annotations from collections.abc import Callable a_ = list[list[float | int]] def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : int = len(_a) SCREAMING_SNAKE_CASE : Matrix = [[0 for _ in range(size + 1)] for _ in range(_a)] SCR...
25
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a_ = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } try: if not is_torch_available(): raise OptionalDependencyNotAvail...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( ...
25
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
1
def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : list[list[str]] = [[] for _ in range(_a)] SCREAMING_SNAKE_CASE : Optional[Any] = key - 1 if key <= 0: raise ValueError("Height of grid can't be 0 or negative") if key == 1 or len(_a) <= key: return input_st...
25
def lowerCamelCase__ ( _a): if not isinstance(_a , _a): SCREAMING_SNAKE_CASE : Tuple = f"Input value of [number={number}] must be an integer" raise TypeError(_a) if number < 0: return False SCREAMING_SNAKE_CASE : Union[str, Any] = number * number while number >...
25
1
from __future__ import annotations from cmath import sqrt def lowerCamelCase__ ( _a , _a , _a): if a == 0: raise ValueError("Coefficient 'a' must not be zero.") SCREAMING_SNAKE_CASE : Tuple = b * b - 4 * a * c SCREAMING_SNAKE_CASE : Dict = (-b + sqrt(_a)...
25
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
25
1
from collections.abc import Iterable from typing import Any class _UpperCamelCase : '''simple docstring''' def __init__( self : List[str] , a : int | None = None ) -> Tuple: """simple docstring""" SCREAMING_SNAKE_CASE : List[Any] = value ...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig']} try: if not is_sen...
25
1