code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from __future__ import annotations class _lowerCamelCase : def __init__( self , lowerCAmelCase = 0 ) -> List[str]: SCREAMING_SNAKE_CASE__: Tuple= key def UpperCamelCase_ ( self , lowerCAmelCase , lowerCAmelCase ) -> list[str]: assert isinstance(lo...
64
from __future__ import annotations def a__ ( A__, A__ = None, A__ = None ): if start is None: SCREAMING_SNAKE_CASE_ : List[str] = 0 if end is None: SCREAMING_SNAKE_CASE_ : Optional[Any] = len(A__ ) - 1 if start >= end:...
101
0
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class SCREAMING_SNAKE_CASE ( a_ ): """simple doc...
218
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring...
218
1
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ...
38
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder __UpperCamelCase : Optional[Any] = '__DUMMY_TRANSFORMERS_USER__' __UpperCamelCase : Optional[Any] = 'Dummy User' __UpperCa...
519
0
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): ...
519
import sys UpperCAmelCase_ = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''66896648950445244523161731...
519
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_availa...
460
'''simple docstring''' # Copyright 2022 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/LICENS...
135
0
'''simple docstring''' from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUE...
344
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/faceb...
344
1
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
568
# 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...
568
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase :Any = { """configuration_lxmert""": ["""LXMERT_PRETRAINE...
701
'''simple docstring''' 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_atten...
179
0
"""simple docstring""" 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...
169
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/c...
169
1
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY_...
710
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 : Any = logging.get_logger(__name__) __A : Dict = { 'hustvl/yolos-small': 'https...
75
0
def a__ ( A__, A__ ): def get_matched_characters(A__, A__ ) -> str: SCREAMING_SNAKE_CASE_ : Dict = [] SCREAMING_SNAKE_CASE_ : Any = min(len(_stra ), len(_stra ) ) // 2 for i, l in enumerate(_stra ): SCREAMIN...
101
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, b...
101
1
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging _A = { "...
713
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _A = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2), 7: (7, 1), 8: (4, 2), 9: (3, ...
279
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase = { '''configuration_albert''': ['''ALBERT_PRE...
40
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) # TODO Update this _lowercase = { """facebook/esm-1b""": """https://huggingface....
443
0
"""simple docstring""" from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface...
194
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torc...
194
1
from __future__ import annotations class lowercase_ : def __init__( self : List[str] , snake_case__ : str , snake_case__ : str ): """simple docstring""" SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = text, patt...
360
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): ...
360
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez impor...
701
from pathlib import Path import numpy as np from PIL import Image def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : np.ndarray ) -> np.ndarray: __lowercase , __lowercase , __lowercase = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2_989 * r + 0.5_870 * g + 0.1_140...
688
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
682
"""simple docstring""" import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_avai...
682
1
"""simple docstring""" def A_ ( __lowercase ): assert column_title.isupper() UpperCamelCase_ : List[str] =0 UpperCamelCase_ : List[Any] =len(__A ) - 1 UpperCamelCase_ : Any =0 while index >= 0: UpperCamelCase_ : Tuple =(ord(column_title[i...
701
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = { 'facebook/dpr-ctx_encoder-single-nq-base': ( 'https://huggingface.co/facebook/dpr-ctx_encoder...
395
0
"""simple docstring""" def __snake_case ( UpperCamelCase__ = 10**9 ) -> int: """simple docstring""" A = 1 A = 2 A = 0 A = 0 A = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter ...
690
"""simple docstring""" from __future__ import annotations def __snake_case ( UpperCamelCase__ ) -> list[int]: # This function is recursive """simple docstring""" A = len(UpperCamelCase__ ) # If the array contains only one element, we return it (it's th...
690
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """SenseTime/deformable-detr""": """https://huggingface.co/senseti...
707
"""simple docstring""" class A__ : def __init__( self ): __lowerCAmelCase : Optional[int] = 0 __lowerCAmelCase : Any = 0 __lowerCAmelCase : List[Any] = {} def __lowerCamelCase ( self , _SCREAMING_SNAKE_CASE ): if vertex not in self.ad...
549
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass SCREAMING_SNAKE_CASE_ = (3, 9, -1_1, 0, 7, 5, 1, -1) SCREAMING_SNAKE_CASE_ = (4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class ...
597
'''simple docstring''' import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ ): __a : List[str] = [ 'encoder.version', 'dec...
597
1
"""simple docstring""" def snake_case ( UpperCamelCase__ : Any , UpperCamelCase__ : Union[str, Any] ) -> Optional[int]: lowerCamelCase : Union[str, Any] = """""" for i in table: res += inp[i - 1] return res def snake_cas...
706
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCamelCase :str = get_tests_dir...
42
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers ...
510
'''simple docstring''' from collections.abc import Callable class __UpperCamelCase : def __init__( self , __a = None ): '''simple docstring''' __a : list = [] # Stores indexes of each item for supporting updates and deletion. __a :...
476
0
"""simple docstring""" import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.swit...
715
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class snake_case : def __init__( self :Dict , _lowerCamelCase :List[str] ): __SCREAMING_SNAKE_CASE : Union[str, Any] = str(id_ ) __SCREAMING_SNAKE_CAS...
401
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart ...
227
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def ...
227
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : List[Any] = logging.get_logger(__name__) lowerCAmelCase : List[Any] = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-...
533
"""simple docstring""" from ..utils import DummyObject, requires_backends class __magic_name__ ( metaclass=UpperCAmelCase__ ): '''simple docstring''' __UpperCamelCase = ["note_seq"] def __init__( self , *_a , **_a ): """simple docstri...
533
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase__ : List[str] = logging.get_logger(__name__) UpperCamelCase__ : List[Any] = { """Visual-Attention-Network/van-base""": ( """https://huggingf...
578
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDep...
387
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _UpperCAmelCase (UpperCamelCase_ : int ): '''simple docstring''' _lowerCAmelCase = prime_factors(_lowerCamelCase ) if is_square_free(_lowerCamelCase ): r...
719
import numpy as np def _UpperCAmelCase (UpperCamelCase_ : np.array ): '''simple docstring''' return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
196
0
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import T...
167
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_big_bird import B...
167
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 In...
235
def snake_case (UpperCamelCase : list , UpperCamelCase : list , UpperCamelCase : int ): '''simple docstring''' lowerCamelCase__ = len(UpperCamelCase ) lowerCamelCase__ = [[0] * n for i in range(UpperCamelCase )] for i in range(UpperCame...
235
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: if not...
485
def lowerCamelCase ( UpperCamelCase : int , UpperCamelCase : int ) -> float: return base * power(UpperCamelCase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') A = ...
544
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrajectoryTransformerConfig", ], } try: if ...
658
import string def A ( _lowerCamelCase ): '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): _lowerCAmelCase : str = "" for symbol in message: if symbol in string.asc...
658
1
def snake_case__ ( UpperCAmelCase : int ): if not isinstance(UpperCAmelCase , UpperCAmelCase ): raise TypeError("only integers accepted as input" ) else: lowerCAmelCase__ :str = str(abs(UpperCAmelCase ) ) lowerCAmelCa...
145
from math import isclose, sqrt def snake_case__ ( UpperCAmelCase : float , UpperCAmelCase : float , UpperCAmelCase : float ): lowerCAmelCase__ :Optional[int] = point_y / 4 / point_x lowerCAmelCase__ :Tuple = 2 * normal_gradient / (1 + norm...
145
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _a : List[str] = { """configuration_bert""": ["""BERT...
714
"""simple docstring""" import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transfo...
87
0
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Versio...
683
# 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.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import ...
670
0
"""simple docstring""" import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union a =re.compile(r'^(?P<major>\d+)' r'\.(?P<minor>\d+)' r'\.(?P<patch>\d+)$') @total_ordering @dataclass class __UpperCAmelCase : A__ : ...
719
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ) -> str: '''simple docstring''...
132
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Optional[int] = { 'configuration_roformer': ['ROFORMER_PRETRAINED...
556
from typing import TYPE_CHECKING from ...utils import _LazyModule a : int = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys a : int = _...
556
1
'''simple docstring''' def __UpperCamelCase ( _lowerCAmelCase ): """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], ...
703
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig __lowerCAmelCase ={ "facebook/maskformer-swin-base-ade": ( "https://hugging...
405
0
from __future__ import annotations import typing from collections import Counter def lowerCAmelCase_ ( lowercase: int ) -> typing.Counter[int]: '''simple docstring''' _UpperCamelCase: typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): for perp...
271
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def lowerCAmelCase_ ( lowercase: str , lowercase: complex , lowercase: str = "x" , lowercase: float = 10**-10 , lowercase: int = 1 , ) -> complex: '''simple docstri...
271
1
import numpy as np def a__ (__lowercase :np.ndarray , __lowercase :float ) -> np.ndarray: return np.where(vector > 0 , __lowercase , (alpha * (np.exp(__lowercase ) - 1)) ) if __name__ == "__main__": import doctest doctest.testm...
332
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _UpperCamelCase : Dict =logging.get_logger(__name__) _UpperCamelCase : Optional[Any] ={ 'facebook/xmod-bas...
332
1
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
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, require...
479
0
'''simple docstring''' __UpperCAmelCase = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) __UpperCAmelCase = froz...
220
'''simple docstring''' from pathlib import Path import numpy as np from PIL import Image def SCREAMING_SNAKE_CASE_ ( snake_case_ : np.ndarray ) -> np.ndarray: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[Any] ...
220
1
def a (lowerCAmelCase__ ): __a = len(lowerCAmelCase__ ) while cur > 1: # Find the maximum number in arr __a = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi __a = arr[mi::-1] + arr[mi + 1 : len(lowerCAmelCase__ )] # Reverse whole list ...
99
'''simple docstring''' def __snake_case ( ): lowerCamelCase_ = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] lowerCamelCase_ = 6 lowerCamelCase_ = 1 lowerCamelCase_ = 1901 lowerCamelCase_ = 0 while year < 2001: day += 7 if (year % 4 == 0 an...
675
0
_lowerCAmelCase = [ "DownloadConfig", "DownloadManager", "DownloadMode", "StreamingDownloadManager", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
71
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _snake_case ( __snake_case , __snake_case , __snake_case = 1 / sqrt(2 ) ): _UpperCamelCase = tau * frequency / samplerate _UpperCamelCase = sin(__snake_case ) _UpperCamelCase ...
71
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepa...
8
'''simple docstring''' import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _lowerCAmelCase ( __snake_case : str , __snake_case : str , **__snake_case : List[Any] ) -> Any: __A : Optiona...
8
1
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class _a ( SCREAMING_SNAKE_CASE__ ): """simple ...
719
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, ...
220
0
'''simple docstring''' import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Token...
24
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slow ...
410
0
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class __lowercase ( unittest.TestCase ): def ...
711
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __lowercase : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotA...
357
0
SCREAMING_SNAKE_CASE__ = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def A ( __UpperCamelCase ) -> int: A__ = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared += DIGITS_SQUARED[numb...
9
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbone...
418
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available(): raise ...
583
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_...
583
1
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): f...
382
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py lowerCamelCase__ = '''src/diffusers''' # Matches is_xxx_available() lowerCamelCase__ = re.compile(r''...
381
0
# Copyright 2022 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 app...
720
import argparse import hashlib # hashlib is only used inside the Test class import struct class A_ : def __init__( self : List[str] , snake_case__ : Union[str, Any] ): lowercase = data lowercase = [0X6_7_4_5_2_3_0_1, 0Xe_f_c_d_a_b...
72
0
"""simple docstring""" import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP UpperCamelCase__ :Union[str, Any] = Fal...
355
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVec...
355
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase : Any = logging.get_logger(__name__) __UpperCAmelCase : Any = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # See all BioGPT models at http...
704
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase : str = logging.get_logger(__name__) __UpperCAmelCase : List[Any] = { 'YituTech/conv-bert-ba...
249
0
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_utils import FrozenDict fro...
611
class a : def __init__( self : Union[str, Any] , snake_case__ : str ): """simple docstring""" __lowerCAmelCase = arr.split("," ) def UpperCAmelCase__ ( self : str ): """simple docstring""" __lowerCAmelCase ...
611
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCamelCase = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], 'configuration_maskformer_swin'...
713
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCamelCase__ ( UpperCAmelCase ): """simple docstring""" @staticmethod @abstractmethod def snake_case__ ( snake_case ): '''simple docstring''' raise NotImp...
185
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
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> int: if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" )...
504
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: list[int] , SCREAMING_SNAKE_CASE: str ): """simple docstring""" _lowerCAmelCase = int(SCREAMING_SNAKE_CASE ) # Initialize Result _lowerCAmelCase = [] ...
491
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_avai...
491
1
import os import re import shutil import sys import tempfile import unittest import black A__ : Dict = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies # noqa: E402 # This is the refere...
183
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_...
183
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): i...
711
from collections import deque from .hash_table import HashTable class lowerCAmelCase__ ( _lowerCamelCase ): def __init__( self : Dict , *__UpperCamelCase : Tuple , **__UpperCamelCase : List[Any] ) -> Union[str, Any]: super().__init__(*__UpperC...
224
0
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuratio...
636
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
1
"""simple docstring""" import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import...
625
"""simple docstring""" import colorsys from PIL import Image # type: ignore def snake_case__ ( __lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : Optional[Any] =x lowerC...
625
1
'''simple docstring''' from bisect import bisect from itertools import accumulate def __a ( _UpperCamelCase: Any , _UpperCamelCase: Optional[int] , _UpperCamelCase: List[Any] , _UpperCamelCase: List[str] ) -> Tuple: """simple docstring""" ...
185
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase : Union[str, Any] = logging.getLogger(__name__) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json" ), # See all Vivit models ...
720
from __future__ import annotations from collections import deque class __lowercase : def __init__( self : Dict , __lowerCamelCase : list[str] ) -> List[str]: '''simple docstring''' lowercase = [] self.adlis...
479
0
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports snake_case_ : Optional[Any] = ''' import os ''' snake_case_ : Optional[Any] = ''' def foo(): import os return False ''' snake_case_ : str = ''' def fo...
138
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common...
450
0
'''simple docstring''' import argparse from collections import defaultdict import yaml UpperCamelCase__ ='docs/source/en/_toctree.yml' def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE : Any = defaultdict(snake_case__ ) for doc in model_doc: ...
706
def lowerCamelCase__ (__lowerCamelCase = 10**9 ): _SCREAMING_SNAKE_CASE : List[str] = 1 _SCREAMING_SNAKE_CASE : Any = 2 _SCREAMING_SNAKE_CASE : List[Any] = 0 _SCREAMING_SNAKE_CASE : Dict = 0 _SCREAM...
381
0
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __magic_name__ (unittest.TestCase ): '''simple docstring''' ...
33
from copy import deepcopy class __magic_name__ : '''simple docstring''' def __init__( self:int , _a:list[int] | None = None , _a:int | None = None ): if arr is None and size is not None: snake_case__ = size snake_case__ = ...
33
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A: str = logging.get_logger(__name__) A: Optional[Any] = { "uw-madison/mra-base-512-4": "https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json", } class ...
713
"""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: List[An...
359
0
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table impor...
317
def snake_case_ (__A : list[int] , __A : list[int] ) -> None: __lowerCAmelCase : Union[str, Any] = len(__A ) print("""The following activities are selected:""" ) # The first activity is always selected __lowerCAmelCase : str = 0 print(__A ...
651
0
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class snake_case_ : """simple docstring""" pass
455
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case_ (lowercase__ ): """simple docstring""" _lowerCamelCase = """ClapFeatureExtractor""" _lowerCamelCase = ("""RobertaTokenizer""", """RobertaTokeniz...
455
1
"""simple docstring""" import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch f...
238
"""simple docstring""" import argparse import datetime def UpperCamelCase ( _lowerCAmelCase : str ) -> str: _UpperCAmelCase : List[str] = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """We...
238
1
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar SCREAMING_SNAKE_CASE_ : Any = TypeVar('T') class a ( Generic[T] ): """simple docstring""" def __init__( self: List[str] , UpperCamel...
500
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ : Any = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', ...
500
1
from datetime import datetime as dt import os from github import Github A : Optional[Any] = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def UpperCamelCase__ ( ) -> Dict: _...
287
"""simple docstring""" from maths.prime_check import is_prime def _snake_case ( snake_case__ : int ): if not isinstance(snake_case__ , snake_case__ ): A = F'Input value of [number={number}] must be an integer' raise TypeError(snake_case__ ) if is_prime(snake_case__ ) and is_prime(...
91
0
'''simple docstring''' from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, ...
708
'''simple docstring''' import re def __lowerCamelCase ( _UpperCamelCase : str ): '''simple docstring''' return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def __lowerCamelCase ( _UpperCamelCase : str ): '''simple d...
43
0
def a (lowerCAmelCase__ ): if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
99
"""simple docstring""" import warnings warnings.warn( "memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: " "`from accelerate import find_executable_batch_size` to avoid this warning.", FutureWarning, )
624
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, ...
713
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def A__ ( __A ): '''simple docstring''' _lowerCamelCase : Tuple = {} ...
15
0
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Any , lowerCAmelCase...
494
'''simple docstring''' def __UpperCAmelCase ( a_: int ): if not isinstance(a_, a_ ): _UpperCAmelCase : List[str] = f"""Input value of [number={number}] must be an integer""" raise TypeError(a_ ) if number < 0: return False _UpperCAmelCase : Unio...
494
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, Wa...
213
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torc...
213
1
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments a : Optional[int] = logging.getLogger(__name__) @dataclass class _a ( _lowerCAmelCase ...
556
from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[Any] = logging.get_logger(__name__) class _a ( _lowerCAmelCase ): A = '''timm_backbone''' def __init__(self, SCREAMING_SNAKE_CASE_=None, SCREAMING_SNAKE...
556
1
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipelin...
703
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer...
123
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
30
from __future__ import annotations def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> list[str]: '''simple docstring''' if nth_term == "": return [""] __UpperCAmelCase = int(SCREAMING_SNAKE_CASE ) __UpperCAmelCase ...
303
0
"""simple docstring""" from math import pi, sqrt, tan def __snake_case ( SCREAMING_SNAKE_CASE: float ): """simple docstring""" if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) r...
491
"""simple docstring""" 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_attenti...
491
1
"""simple docstring""" import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __A (_SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" lowerCAmelCase__ :List[Any] = [ 'decoder....
93
'''simple docstring''' 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) _UpperCa...
284
0
"""simple docstring""" def A_ ( _lowerCAmelCase : Union[str, Any] ): """simple docstring""" _a = [0] * len(_lowerCAmelCase ) _a = [] _a = [] _a = 0 for values in graph.values(): for i in values: ...
285
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCamelCase ( a__ ): '''simple docstring''' A_ : Optional[int] = ['image_processor', 'tokenizer'] A_ : Union[str, ...
285
1
"""simple docstring""" 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_ = { """facebook/xmod-base""": """https://huggi...
29
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
369
0
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ....
674
"""simple docstring""" import os from math import logaa def _UpperCAmelCase ( lowerCamelCase__ = "base_exp.txt" ): """simple docstring""" lowerCAmelCase__ = 0 lowerCAmelCase__ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase__ ...
674
1
'''simple docstring''' import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_...
349
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase = "cpu" , _lowerCamelCase = None ) -> None: '''simple docstring''' _lowerCamelCase : Any = torch.loa...
46
0
"""simple docstring""" import re from filelock import FileLock try: import nltk _snake_case : Dict = True except (ImportError, ModuleNotFoundError): _snake_case : Union[str, Any] = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) ...
718
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTok...
524
0
"""simple docstring""" from collections.abc import Sequence def UpperCAmelCase ( snake_case : Union[str, Any] = None ): if nums is None or not nums: raise ValueError('''Input sequence should not be empty''' ) _lowerCAmelCase:Optional[int] = nums[0] ...
227
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_pr...
207
0
"""simple docstring""" import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils i...
95
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowercase ( _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' def is_in_circle(_SCREAMING_SNAKE_...
95
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _A ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" @staticmethod @abstractmethod def lowercase ( A_ : ArgumentParser ) -> ...
564
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE: Optional[int] = 2_9_9_7_9_2_4_5_8 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE: ...
360
0
'''simple docstring''' import numpy as np import qiskit def _SCREAMING_SNAKE_CASE ( A : int = 8 , A : int | None = None ) -> str: """simple docstring""" __snake_case : str = np.random.default_rng(seed=A ) ...
709
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
61
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = "▁" _a = {"vocab_file": "spiece.model"} _a ...
481
# 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 app...
481
1
"""simple docstring""" # 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 TensorFor...
703
"""simple docstring""" from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures...
505
0
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTe...
39
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''huggingface/informer-tourism-monthly''': ( '''https://huggingface.co/hug...
39
1
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaT...
645
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vi...
645
1
"""simple docstring""" import enum import shutil import sys snake_case , snake_case = shutil.get_terminal_size() snake_case = {'''UP''': '''A''', '''DOWN''': '''B''', '''RIGHT''': '''C''', '''LEFT''': '''D'''} class UpperCAmelCase ( enum.Enum ): ...
103
from PIL import Image def A__ ( _a : Image , _a : float ): '''simple docstring''' def brightness(_a : int ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError("""level must be between -255.0 (black) and...
385
0
"""simple docstring""" from math import isclose, sqrt def _a ( _snake_case , _snake_case , _snake_case ): """simple docstring""" UpperCAmelCase = point_y / 4 / point_x UpperCAmelCase = 2 * normal_gradient / (1 + normal_gradient * normal_grad...
74
"""simple docstring""" import math def _a ( _snake_case ): """simple docstring""" 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...
74
1
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user ...
79
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=a_ ) class lowerCAmelCase_ ( a_ ): __UpperCAmelCase = field(default='imag...
349
0
def __UpperCamelCase ( _lowerCAmelCase ) -> List[Any]: """simple docstring""" A : Union[str, Any] = [int(lowerCamelCase_ ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(lowerCamelCase_ ) == 4 and all(0 <= int(lowerCamelCase_ ) <= 254 for octet in oct...
712
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""" )
520
0