code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
from math import factorial class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : Optional[int] , a : Dict ) -> Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = real if isins...
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 tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common 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
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNetaDCon...
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_clap': [ 'CLAP_PRETRAINED_MODEL_ARCHIVE_LIST', 'ClapAudioConfig', 'ClapConfig', 'ClapTextConfig', ], 'processing_clap': ['...
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 dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modeling_...
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 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
# 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 from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__A ) class _UpperCamelCase ( __A ): '''simple docstring''' lowerCamelCase__ =field(default='t...
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 ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json' ), ...
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 unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _UpperCamelCase ( __A ): '''simple docstring''' def __UpperCamelCase ( self : int ) -> List[str]: """simple docstring""" return [ ...
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
def lowerCamelCase__ ( _a , _a): return 1 if input_a == input_a else 0 def lowerCamelCase__ ( ): assert xnor_gate(0 , 0) == 1 assert xnor_gate(0 , 1) == 0 assert xnor_gate(1 , 0) == 0 assert xnor_gate(1 , 1) == 1 if __name__ == "__main__": print...
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 PIL import Image def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = image.size SCREAMING_SNAKE_CASE : Tuple = 0 SCREAMING_SNAKE_CASE : Tuple = image.load() for i in range(_a): for j in range(_a): 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
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTest...
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 argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : List[Any] = torch.load(_a ...
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 cva import destroyAllWindows, imread, imshow, waitKey def lowerCamelCase__ ( _a): # getting number of pixels in the image SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : str = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(_a): for j in ra...
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 itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils...
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 mpmath # for roots of unity import numpy as np class _UpperCamelCase : '''simple docstring''' def __init__( self : Any , a : Any=None , a : List[Any]=None ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE : Optional[int] = ...
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
# 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
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 argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def lowerCamelCase__ ( _a): # encoder.embeddings are double copied in original FLAVA return sum(param.float()....
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 argparse import datetime def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : List[str] = { "0": "Sunday", "1": "Monday", "2": "Tuesday", "3": "Wednesday", "4": "Thursday", "5": "Friday", "6": "Saturday", } SCREAMING_SNAKE_CASE : List[str] ...
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 logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, A...
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
def __lowercase ( snake_case, snake_case, snake_case ): """simple docstring""" if len(snake_case ) != len(snake_case ): raise ValueError('''The length of profit and weight must be same.''' ) if max_weight <= 0: raise ValueError('''max_weight must greater...
0
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
0
def _A ( _lowercase ) -> list: """simple docstring""" __UpperCamelCase = len(_lowercase ) for i in range(1 , _lowercase ): __UpperCamelCase = collection[i] __UpperCamelCase = 0 __UpperCamelCase = i - 1 while low <= high: ...
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
0
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied...
2
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
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLD...
3
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
0
"""simple docstring""" import os from collections.abc import Iterator def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : str = "." ): for dir_path, dir_names, filenames in os.walk(_UpperCAmelCase ): lowerCAmelCase = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] for filename i...
4
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
0
'''simple docstring''' import functools def A (__lowerCamelCase :list[int] , __lowerCamelCase :list[int] ): # Validation if not isinstance(__lowerCamelCase , __lowerCamelCase ) or not all(isinstance(__lowerCamelCase , __lowerCamelCase ) for day in days )...
5
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_bert': ['RoCBertTokenizer...
6
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
0
"""simple docstring""" def _snake_case ( _snake_case : int , _snake_case : int ) -> int: '''simple docstring''' while second != 0: _A = first & second first ^= second _A = c << 1 return first if __name__ ==...
7
# 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
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscale...
8
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json''', # See all Donut...
9
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
0
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 At...
10
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
0
'''simple docstring''' import math lowercase_ = 10 lowercase_ = 7 lowercase_ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCAmelCase (__A = 20): """simple docstring""" _a = math.comb(__A , __A) _a = math.comb(NUM_BALLS ...
11
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
0
def UpperCamelCase ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' return "\n".join( F'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=1_0...
12
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
0
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig...
13
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
0
class UpperCAmelCase_ : """simple docstring""" def __init__( self , _a , _a=None , _a=None ) -> List[str]: _a : List[Any] = data _a : List[str] = previous _a : ...
14
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
0
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor A : Union[str, Any] = logging.get_logger(__name__) class A ( UpperCAmelCase__ ): '''simple docstring''' def __init__(self ...
15
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
0
def __a ( A__ : int = 1000 ): SCREAMING_SNAKE_CASE = 3 SCREAMING_SNAKE_CASE = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __name__ ...
16
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
0
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_M...
18
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
0
"""simple docstring""" from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class _UpperCAmelCase: pass
19
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
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ (lowercase__ ): snake_case =(PNDMScheduler,) snake_case =(('num_inference_steps', 50),) def __UpperCamelCase ( self , **low...
20
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
0
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate UpperCAmelCase_ : List[Any] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataR...
21
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
0
'''simple docstring''' from __future__ import annotations import bisect def snake_case_ (UpperCamelCase : list[int] , UpperCamelCase : int , UpperCamelCase : int = 0 , UpperCamelCase : int = -1 ): '''simple docstring''' if h...
22
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
0
import itertools import string from collections.abc import Generator, Iterable def _snake_case (__lowercase , __lowercase): UpperCamelCase_ = iter(__lowercase) while True: UpperCamelCase_ = tuple(itertools.islice(__lowercase , __lowercase)) ...
23
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
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json...
24
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
0
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import Reg...
26
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
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __A : Opti...
27
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
0
'''simple docstring''' from __future__ import annotations class _a : '''simple docstring''' def __init__( self, A = 0 ): '''simple docstring''' SCREAMING_SNAKE_CASE : ...
28
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
0
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_g...
29
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
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
30
# 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
0
import numpy as np def UpperCAmelCase_ ( __UpperCAmelCase : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
31
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
0
from pathlib import Path import numpy as np from PIL import Image def A__ ( SCREAMING_SNAKE_CASE_ : np.ndarray ) -> np.ndarray: """simple docstring""" _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = rgb[:, :, 0], rgb[:, :, 1],...
32
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
0
import argparse import os import re lowerCamelCase__ : Optional[int] = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowerCamelCase__ : List[Any]...
33
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
0
"""simple docstring""" import operator def __snake_case ( _lowercase ,_lowercase = False ,_lowercase = None ): """simple docstring""" UpperCamelCase = operator.lt if reverse else operator.gt UpperCamelCase = solution or [] if not arr: ...
34
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
0
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( _UpperCAmelCase ): lowerCamelCase : List[Any] = (DDIMParallelScheduler,) lowerCamelCase : Union[str, Any] = (('''eta''', 0.0), ('''num_inference_st...
35
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
0
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipe...
36
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
0
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from...
37
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
0
'''simple docstring''' 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 A_ : ...
38
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
0
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import require_lza,...
39
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
0
def UpperCamelCase ( snake_case__ : Optional[int] ) -> str: UpperCamelCase : List[str] = [0] * len(snake_case__ ) UpperCamelCase : int = [] UpperCamelCase : Optional[int] = [1] * len(snake_case__ ) fo...
40
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
0
'''simple docstring''' from __future__ import annotations import pandas as pd def _A ( A__ , A__ , A__ ): """simple docstring""" __lowercase = [0] * no_of_processes __lowercase = [0] * no_of_processes # Copy the burst time into remaining_time[] for ...
41
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
0
'''simple docstring''' import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_token...
42
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
0
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
43
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
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_...
44
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
0
def A ( lowercase__ : int ) -> Optional[Any]: stooge(lowercase__ , 0 , len(lowercase__ ) - 1 ) return arr def A ( lowercase__ : Union[str, Any] , lowercase__ : Dict , lowercase__ : str ) -> List[str]: if i >= h: return # If first element is smaller than the last the...
45
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
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging loggin...
46
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
0
def UpperCAmelCase__ ( lowerCamelCase_ : int = 1_0_0_0_0_0_0 ): __a : Optional[Any] = 1 __a : Tuple = 1 __a : Dict = {1: 1} for inputa in range(2 , lowerCamelCase_ ): __a : str = ...
47
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
0
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split UpperCAmelCase__ : Tuple = datasets.load_iris() UpperCAmelCase__ : Any = np.array(data["data"]) UpperCAmelCase__ : Union[str, Any] ...
48
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
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_...
49
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
0
'''simple docstring''' import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophet...
50
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
0
'''simple docstring''' from collections import deque class lowerCAmelCase__ : '''simple docstring''' def __init__( self : List[Any] , a__ : str , a__ : int , a__ : int ): UpperCAmelCase = process_name #...
51
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
0
"""simple docstring""" 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_mem...
52
# 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
0
# Function to print upper half of diamond (pyramid) def a_ ( lowerCAmelCase_ : Optional[int] ): for i in range(0, lowerCAmelCase_ ): for _ in range(0, n - i - 1 ): # printing spaces print(' ', end='' ) for _ in range(0, i + 1 ...
53
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
0
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class A ( tf.keras.layers.Layer ): def __init__( s...
54
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
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import StableDiff...
55
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
0
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_do...
56
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
0
import tensorflow as tf from ...tf_utils import shape_list class _lowerCAmelCase( tf.keras.layers.Layer ): """simple docstring""" def __init__( self , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCa...
57
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
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCAmelCase : int = logging.get_logger(__name__) __lowe...
58
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
0
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
59
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
0
def lowerCamelCase_ ( _UpperCamelCase ) -> bool: """simple docstring""" return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''') ) def lowerCamelCase_ ( _UpperCamelCase ) -> bool: """simple docstring""" ...
60
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
0
from math import pi, sqrt, tan def _A ( lowerCAmelCase_ : float ): """simple docstring""" if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values" ) return 6 * side_length**2 def _A ( lowerCAmelCase_ : floa...
61
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
0
def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = set() # edges = list of graph's edges SCREAMING_SNAKE_CASE : List[Any] = get_edges(lowercase ) # While there are still elements in edges lis...
62
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
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowerCamelCase__ ( __lowerCamelCase : int ): __UpperCAmelCase : Optional[Any] = prime_factors(__lowerCamelCase ) if is_square_free(__lowerCamelCase ...
63
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
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_tokenization_common ...
64
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
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __UpperCAmelCase = logging.get_logger(__name__) class __lowercase ( __lowerCamelCase ): def __init__( self : Optional[Any] ...
65
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
0
from __future__ import annotations UpperCamelCase = list[list[int]] # assigning initial values to the grid UpperCamelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], ...
66
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
0
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_imag...
67
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
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
68
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
0
'''simple docstring''' from collections.abc import Callable def __UpperCAmelCase ( _UpperCAmelCase : Callable[[float], float] , _UpperCAmelCase : float , _UpperCAmelCase : float ) -> float: __snake_case = a __snake_case = b if function(_UpperCAmelCas...
69
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
0
def _SCREAMING_SNAKE_CASE ( lowercase : int = 10 ): '''simple docstring''' if not isinstance(lowercase , lowercase ) or n < 0: raise ValueError('Invalid input' ) lowerCamelCase_ = 10**n lowerCamelCase_ = 2_84...
70
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
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
71
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
0
'''simple docstring''' from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotA...
72
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
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Optional[Any] = logging.get_logger(__name__) class _snake_case ( A__ ): _lowercase : int = '''encoder-decoder''' _lowercase : Dict = True def...
73
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
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: if not is_torch_available(): ...
74
# 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
0
'''simple docstring''' import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py UpperCamelCase__ = '''src/transformers'...
75
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
0
"""simple docstring""" import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging a_ = logging.get_log...
76
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
0
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class a__ ( nn.Module ): def __init__( self : Any , UpperCamelCase_ : int = 16 , UpperCamelCase_ : int = 88 , UpperCam...
77
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
0
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_...
78
from 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
0
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 .atten...
79
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
0
from math import isclose, sqrt def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = point_y / 4 / point_x __lowercase = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) __lowercase ...
80
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
0