code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str ,_lowerCamelCase : str ) -> float: def get_matched_characters(_lowerCamelCase : str ,_lowerCamelCase : str ) -> str: _lowerCAmelCase : Any = [] _lowerCAmelCase : List[Any] = min(len(_s...
663
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils imp...
663
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils im...
663
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _a : Tuple = logging.get_logger(__name__) class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *a__ , **a__ ): warnin...
663
1
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list[int] ,_lowerCamelCase : int ) -> bool: if len(_lowerCamelCase ) == 0: return False _lowerCAmelCase : Tuple = len(_lowerCamelCase ) // 2 if a_list[midpoint] ==...
663
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
1
"""simple docstring""" import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import versi...
663
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
663
1
"""simple docstring""" from collections import defaultdict def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str ,_lowerCamelCase : str ) -> bool: _lowerCAmelCase : List[Any] = first_str.lower().strip() _lowerCAmelCase : Union[str, Any] = second_str.lower().strip() #...
663
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
1
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: _a : str = None try: import msvcrt except ImportError: _a : List[str] = None try: import fcntl except ImportError: _a : int = None ...
663
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
1
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we h...
663
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
1
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _a : int = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not is_torch_av...
663
"""simple docstring""" 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_si...
663
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any] = logging.get_logger(__name__) _a : int = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.jso...
663
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
1
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class __A ...
663
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.util...
663
1
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_de...
663
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A ( SCREAMING_...
663
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common imp...
663
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : List[str] = { 'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'], } try: if not is_torch_availab...
663
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : int = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AltCLIPConfig', 'AltCLIPTe...
663
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva _a : Union[str, Any] = '' _a : Optional[Any] = '' _a : List[str] = '' _a : Optional[Any] = 1 # (0 is vertical, 1 is horizontal) def SCREAMING_SNA...
663
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
1
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore _a : Union[str, Any] = namedtuple('covid_data', 'cases deaths recovered') def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str = "https://www.worldometers.info/coronavirus/" ) ...
663
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __A : _UpperCamelCase : int _UpperCamelCase : Node | None = None _Upp...
663
1
"""simple docstring""" import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoToke...
663
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __A ( unittest.TestCase ): def __A ( self ): _lowerCAmelCa...
663
1
"""simple docstring""" _a : Optional[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _a :...
663
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Tuple ) -> Dict: _lowerCAmelCase : List[str] = int(_lowerCamelCase ) assert noofclusters < len(...
663
1
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ,_lowerCamelCase : List[Any] ,_lowerCamelCase : List[str]=1...
663
"""simple docstring""" _a : Optional[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _a :...
663
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _a : Dict = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvNextCo...
663
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
1
"""simple docstring""" import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.te...
663
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
663
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
663
1
"""simple docstring""" import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTeste...
663
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils imp...
663
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) ...
663
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _a : Tuple = logging.get_logger(__name__) class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *a__ , **a__ ): warnin...
663
1
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list[int] ) -> int: if not nums: return 0 _lowerCAmelCase : Union[str, Any] = nums[0] _lowerCAmelCase : Any = 0 for num in nums[1:]: _lowerCAmelCase , ...
663
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
1
"""simple docstring""" import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertToke...
663
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
663
1
"""simple docstring""" import os def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(_lowerCamelCase ) ,_lowerCamelCase ) ) as input_file: _lowerCAmelCase : Dict = [ [int(_lowerCamelCase ) for eleme...
663
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
1
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Tuple = logging.get_logger(__name__) _a : str = { "microsoft/unispeech-sat-base-100h-libri-ft": ( "https://huggingface.co/microsoft/unis...
700
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
0
"""simple docstring""" from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked ...
701
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
0
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_...
702
"""simple docstring""" 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_si...
663
0
"""simple docstring""" from typing import Any def SCREAMING_SNAKE_CASE ( _lowerCamelCase : List[str] ) -> list[Any]: if not input_list: return [] _lowerCAmelCase : Tuple = [input_list.count(_lowerCamelCase ) for value in input_list] _lowerCAmelCase : List[Any] ...
703
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _a : List[str] = logging.get_logger(__name__) _a : Any = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dpt-large/resolve/main/confi...
704
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.util...
663
0
"""simple docstring""" import os def SCREAMING_SNAKE_CASE ( ) -> str: with open(os.path.dirname(_A ) + """/p022_names.txt""" ) as file: _lowerCAmelCase : List[Any] = str(file.readlines()[0] ) _lowerCAmelCase : List[Any] = names.replace("""\"""" ,"""""" ...
705
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A ( SCREAMING_...
663
0
"""simple docstring""" import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _a : Any = { 'facebook/mask2former-swin-small-coco-instance': ( 'https://huggingface.co/facebook/...
706
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common imp...
663
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig class __A ( UpperCAmelCase_ ): _UpperCamelCase : Union[str, Any] = 'bert-generation' def __init__( self , a__=50358 , a__=1024 , a__=24 , a__=16 , a__=4096 ...
707
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : int = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AltCLIPConfig', 'AltCLIPTe...
663
0
"""simple docstring""" from typing import TYPE_CHECKING import torch from ..models.auto import AutoModelForVisualQuestionAnswering, AutoProcessor from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class __A ( __A ): _UpperCamelCase ...
708
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
709
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __A : _UpperCamelCase : int _UpperCamelCase : Node | None = None _Upp...
663
0
"""simple docstring""" from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( 'stable diffusion controlnet', '0.22.0', 'Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.f...
710
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __A ( unittest.TestCase ): def __A ( self ): _lowerCAmelCa...
663
0
"""simple docstring""" import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, ...
711
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Tuple ) -> Dict: _lowerCAmelCase : List[str] = int(_lowerCamelCase ) assert noofclusters < len(...
663
0
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ,_lowerCamelCase : List[Any] ) -> Union[str, Any]: _lowerCAmelCase : int = int(__lowerCAmelCase ) assert noofclusters < ...
712
"""simple docstring""" _a : Optional[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _a :...
663
0
"""simple docstring""" import numpy as np import datasets _a : Dict = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was int...
713
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Optional[int] = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', ...
714
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
663
0
"""simple docstring""" from __future__ import annotations _a : Optional[int] = "Muhammad Umer Farooq" _a : Optional[Any] = "MIT" _a : Any = "1.0.0" _a : Tuple = "Muhammad Umer Farooq" _a : Union[str, Any] = "contact@muhammadumerfarooq.me" _a : Union[str, Any...
715
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
663
0
"""simple docstring""" import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand _a : List[Any] = ( '4S 3H 2C 7S 5H', '9D 8H 2C 6S 7H', '2D 6D 9D TH 7D', 'TC 8C 2S JH 6C', 'JH 8S TH AH QH', 'TS KS 5S 9S AC', 'KD 6S...
716
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils imp...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : str = { 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTConfig', 'GroupViTOnnxCo...
717
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _a : Tuple = logging.get_logger(__name__) class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *a__ , **a__ ): warnin...
663
0
"""simple docstring""" import argparse import os from accelerate.test_utils import execute_subprocess_async def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any]=None ) -> Any: if subparsers is not None: _lowerCAmelCase : Optional[Any] = subparsers.add_parser("""t...
718
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel...
719
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Tuple ) -> list: _lowerCAmelCase : Optional[Any] = len(_lowerCamelCase ) for i in range(1 ,_lowerCamelCase ): _lowerCAmelCase : List[str] = collection[i] _lowerCAmelCase : Tuple ...
720
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
0
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __A ( unittest.TestCase ): def __A ( self ): debug_launcher(test_script.main ) def __...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependenc...
700
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Optional[int] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDe...
701
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : Union[str, Any] = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization...
702
"""simple docstring""" 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_si...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Optional[Any] = { """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConfig""", """CLIPSegTex...
703
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _a : Optional[int] = logging.get_logger(__name__) class __A ( lowercase__ ): def __init__( self , *a__ , **a__ ): warnings.warn( ...
704
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.util...
663
0
"""simple docstring""" from __future__ import annotations _a : int = '#' class __A : def __init__( self ): _lowerCAmelCase : dict = {} def __A ( self , a__ ): _lowerCAmelCase : Optional[Any] = self._trie ...
705
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A ( SCREAMING_...
663
0
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSchedu...
706
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common imp...
663
0
"""simple docstring""" import os from datetime import datetime as dt from github import Github _a : Dict = [ 'good first issue', 'feature request', 'wip', ] def SCREAMING_SNAKE_CASE ( ) -> str: _lowerCAmelCase : Optional[int] = Github(os.environ["""GITHUB_TOK...
707
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : int = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AltCLIPConfig', 'AltCLIPTe...
663
0
"""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=_UpperCAmelCase ) class __A ( _UpperCAmelCase ): _UpperCamelCase = field(default="i...
708
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_com...
709
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __A : _UpperCamelCase : int _UpperCamelCase : Node | None = None _Upp...
663
0
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOu...
710
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __A ( unittest.TestCase ): def __A ( self ): _lowerCAmelCa...
663
0
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils imp...
711
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Tuple ) -> Dict: _lowerCAmelCase : List[str] = int(_lowerCamelCase ) assert noofclusters < len(...
663
0
"""simple docstring""" import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline _a : Union[str, Any] = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use valu...
712
"""simple docstring""" _a : Optional[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _a :...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[int] ) -> int: if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""" ) for cell_n in range(1 ,len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] ...
713
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
0
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed fr...
714
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
663
0
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_model...
715
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
663
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class __A ( unittest.TestCase ): ...
716
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils imp...
663
0
"""simple docstring""" import numpy as np def SCREAMING_SNAKE_CASE ( _lowerCamelCase : np.array ) -> List[str]: return 1 / (1 + np.exp(-vector )) def SCREAMING_SNAKE_CASE ( _lowerCamelCase : np.array ) -> Tuple: return vector * sigmoid(1.7_02 * vector ) if __name_...
717
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _a : Tuple = logging.get_logger(__name__) class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *a__ , **a__ ): warnin...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Tuple ,_lowerCamelCase : Optional[int] ) -> Dict: if discount_rate < 0: raise ValueError("""Discount rate cannot be negative""" ) if not cash_flows: raise ValueError("""Cash flows list cannot be empty""" ) _low...
718
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
0
"""simple docstring""" import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str = 3 ) -> Optional[Any]: if isinstance(lowercase__ ,lowercase__ ): raise Typ...
719
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
663
0
"""simple docstring""" 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 c...
720
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
0
"""simple docstring""" import argparse import datetime import io import itertools import json import math import os import platform import re import shlex import subprocess import sys from pathlib import Path from statistics import fmean import pandas as pd import torch from tqdm import tqdm import transformers ...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
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 logging.set...
700
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
0
"""simple docstring""" import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __A ( SCREAMING_SNAKE_CASE_ ): _UpperCamelCase : Optional[Any] = '' _UpperCamelCase : str ...
701
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
0
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, ...
702
"""simple docstring""" 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_si...
663
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _a : List[str] = logging.get_logger(__name__) class __A ( a__ ): def __init__( self , *a__ , **a__ ): warnings.warn( """T...
703
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
0
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf i...
704
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.util...
663
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Dict = logging.get_logger(__name__) _a : List[str] = { 'camembert-base': 'https://h...
705
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A ( SCREAMING_...
663
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class __A ( metaclass=SCREAMING_SNAKE_CASE_ ): _UpperCamelCase : int = ["torch", "transformers", "onnx"] def __init__( self , *a__ , **a__ ): requires_backends(self , ...
706
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common imp...
663
0
"""simple docstring""" from __future__ import annotations import requests def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ) -> dict: _lowerCAmelCase : List[Any] = f"https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty" return requests.get(lowercase_ ).json(...
707
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : int = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AltCLIPConfig', 'AltCLIPTe...
663
0
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : List[Any] ) -> np.ndarray: _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase : str = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return ...
708
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
0
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerat...
709
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __A : _UpperCamelCase : int _UpperCamelCase : Node | None = None _Upp...
663
0
"""simple docstring""" _a : Optional[int] = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Tuple ,_lowerCamelCase : Optional[int] ...
710
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __A ( unittest.TestCase ): def __A ( self ): _lowerCAmelCa...
663
0
"""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...
711
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Tuple ) -> Dict: _lowerCAmelCase : List[str] = int(_lowerCamelCase ) assert noofclusters < len(...
663
0
"""simple docstring""" import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _a : List[Any] = logging.get_logger(__name__) _a : Optional[int] = { 'post_extract...
712
"""simple docstring""" _a : Optional[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _a :...
663
0
"""simple docstring""" from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _a : Union[str, Any] = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw ...
713
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
0
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
714
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
663
0
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class __A ( UpperCamelCase__ ): def __A ( self , a__ ): with open(__A , encoding="""utf-8""" ) as input_file: _lo...
715
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
663
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any] = logging.get_logger(__name__) class __A ( __UpperCAmelCase ): _UpperCamelCase : str = '''encoder-decoder''' _UpperCamelCase : ...
716
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils imp...
663
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : Any = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization_mvp': ['Mvp...
717
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _a : Tuple = logging.get_logger(__name__) class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *a__ , **a__ ): warnin...
663
0
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _a ...
718
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list[int] ) -> Dict: if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) _lowerCAmelCase : Any = sum(_lowerCamelCase ) / len(_lowerCamelCase ) # Calculate the avera...
719
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
663
0
"""simple docstring""" # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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...
720
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
0
"""simple docstring""" from __future__ import annotations _a : Union[str, Any] = 1.60_21e-19 # units = C def SCREAMING_SNAKE_CASE ( _lowerCamelCase : float ,_lowerCamelCase : float ,_lowerCamelCase : float ,) -> tuple[str, float]: if (conductivity, electron_conc, mobilit...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
0
"""simple docstring""" import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.schedulers.scheduling_utils import SchedulerMixin from diffusers.utils impor...
700
"""simple docstring""" from PIL import Image def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image ,_lowerCamelCase : int ) -> Image: _lowerCAmelCase : Any = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamelCase : int ) -> int: return int(128 + facto...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> Dict: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowerCamelCase ,_lowerCamelCase ): raise TypeError("""Input value must be a 'int' type""" ) return bin(...
701
"""simple docstring""" class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A ( SCREAMING_SNAKE_CASE_ ): pass class __A : def __init__( self ): _lowerCAmelCase : Union[str, Any] = [ [], [], [], ...
663
0
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list[int] ) -> bool: return len(set(SCREAMING_SNAKE_CASE_ ) ) == len(SCREAMING_SNAKE_CASE_ ) if __name__ == "__main__": import doctest doctest.testmod()
702
"""simple docstring""" 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_si...
663
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[int] ,_lowerCamelCase : List[str] ) -> int: return abs(SCREAMING_SNAKE_CASE_ ) if a == 0 else greatest_common_divisor(b % a ,SCREAMING_SNAKE_CASE_ ) def SCREAMING_SNAKE_CASE ( _lowerCamelCase :...
703
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
0
"""simple docstring""" from manim import * class __A ( __A ): def __A ( self ): _lowerCAmelCase : Optional[int] = Rectangle(height=0.5 , width=0.5 ) _lowerCAmelCase : List[Any] = Rectangle(height=0.2_5 , width=0.2_5 ) ...
704
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.util...
663
0
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[int] ,_lo...
705
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A ( SCREAMING_...
663
0