code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin,...
79
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
62
0
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 before tokenizers ...
351
def _UpperCamelCase ( snake_case__ ) -> int: __UpperCAmelCase : int = [0] * len(snake_case__ ) __UpperCAmelCase : Union[str, Any] = [] __UpperCAmelCase : str = [1] * len(snake_case__ ) for val...
342
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available UpperCamelCase__ = { """configuration_audio_spectrogram_transformer""": [ """AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """A...
92
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_mul...
310
0
def lowercase_ ( _lowerCamelCase : Optional[Any] , _lowerCamelCase : Tuple): return x if y == 0 else greatest_common_divisor(lowerCAmelCase__ , x % y) def lowercase_ ( _lowerCamelCase : Any , _lowerCamelCase : int): return (x * y) // greate...
359
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils impo...
333
0
'''simple docstring''' from __future__ import annotations from typing import Any class _snake_case ( _a ): pass class _snake_case : def __init__( self : Optional[int] ,SCREAMING_SNAKE_CASE__ : Any ): SCREAMING_SNAKE_CASE:A...
139
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers...
139
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ={ 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json', # See all W...
366
from maths.prime_check import is_prime def lowerCamelCase__ (__lowerCamelCase ): if not isinstance(__lowerCamelCase, __lowerCamelCase ): _SCREAMING_SNAKE_CASE : List[str] = f"""Input value of [number={number}] must be an integer""" raise TypeError(__l...
325
0
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...t...
313
from __future__ import annotations import math def UpperCAmelCase_( a__ , a__ ): """simple docstring""" if len(a__ ) != 2 or len(a[0] ) != 2 or len(a__ ) != 2 or len(b[0] ) != 2: raise Exception('''Matrices are not 2x2''' ) SCREAMING_SNAKE_CASE ...
313
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
58
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : List[str] = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], }...
58
1
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
248
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
0
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_dim...
364
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @requ...
39
0
from __future__ import annotations from collections.abc import Generator def lowerCAmelCase ( )-> Generator[int, None, None]: lowerCAmelCase_ : dict[int, int] = {} lowerCAmelCase_ : List[Any] = 2 while True: lowerCAmelCase_ : str = fact...
262
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[int] = { """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""], """processing_git...
265
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _snake_case : int = logging.get_logger(__name__) _snake_case : Dict = {'vocab_file': 'vocab.json', 'me...
207
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a_ ( lowerCAmelCase_ : Dict[str, torch.Tensor] ): __lowerCAmelCase = [] __lowerCAmelCase = [] __lowerCAm...
207
1
from __future__ import annotations def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Tuple = get_failure_array(_lowerCamelCase ) # 2) Step through text searching for pattern _lowerCAmelCase , _lowerC...
36
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_te...
79
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import ...
366
import sys 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 before to...
22
0
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowercase ( _lowerCAmelCase ): __SCREAMING_SNAKE_CAS...
285
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A = {"configuration_encoder_decoder": ["EncoderDecoderConfig"]} try: if not is_torch_available(): raise Op...
137
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers...
137
1
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTe...
97
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available ...
333
0
import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ConfigTester from ......
158
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): ...
158
1
"""simple docstring""" from math import isclose, sqrt def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ) -> tuple[float, float, float]: lowercase__ : Union[str, Any] = point_y / 4 / point_x lowercase__ ...
16
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
325
0
def __lowerCAmelCase ( a__ = 1000 ) -> int: __a , __a = 1, 1 __a = 2 while True: __a = 0 __a = fa + fa __a , __a = fa, f index += 1 for _ in str(a__ ): ...
367
import sys def __lowerCAmelCase ( a__ ) -> Optional[int]: __a = len(a__ ) __a = [[0 for x in range(a__ )] for x in range(a__ )] __a = [[0 for x in range(a__ )] for x in range(a__ )] for chain_length in range(2 , a__ ): for...
33
0
'''simple docstring''' from __future__ import annotations import math def lowerCamelCase ( __lowerCamelCase : int ) ->list[int]: if num <= 0: _SCREAMING_SNAKE_CASE = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__lowerCamelCas...
58
'''simple docstring''' 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 -...
58
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowercase ={} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: lo...
242
'''simple docstring''' from __future__ import annotations from random import choice def lowerCamelCase__ ( __lowerCamelCase : Optional[int] ): '''simple docstring''' return choice(__lowerCamelCase ) def lowerCamelCase__ ( __lowerCamelCase : ...
242
1
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> Union[str, Any]: snake_case__ : List[str] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def __s...
35
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _a = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
39
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteS...
358
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indic...
256
0
A__ : str = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' A__ : Optional[int] = [{'type': 'code', 'content': INSTALL_CONTENT}] A__ : Union[str, Any] ...
207
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
207
1
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 lowercase : str = 'src/diffusers' # Matches is_xxx_available() lowercase : str = re.compile(R'is\_([a-z_]...
365
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowercase : Any = logging.get_logger(__n...
151
0
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if...
104
'''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...
22
0
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 import logging logging....
368
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
115
0
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu f...
137
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger a_ : List[Any] = get_logger(__name__) class _snake_case ( enum.Enum ): _lowercase : Any = '''all_checks''' _lowercase ...
137
1
'''simple docstring''' import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging im...
280
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dim...
280
1
'''simple docstring''' from __future__ import annotations def __a(SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' _lowerCAmelCase = [] _lowerCAmelCase = [] _lowerCAmelCase = 0 _lowerCAmelCase = ...
158
'''simple docstring''' 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 pass...
158
1
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int = 200 ) -> int: _UpperCAmelCase : Dict = [1, 2, 5, 10, 20, 50, 100, 200] _UpperCAmelCase : Union[str, Any] = [0] * (pence + 1) _UpperCAmelCase : Tuple = 1 # base case: 1 way ...
189
from typing import Any class a : def __init__( self , A_ ): '''simple docstring''' _UpperCAmelCase : List[Any] = data _UpperCAmelCase : Any = None class a : def __init__( self ): ...
189
1
"""simple docstring""" import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 1_...
197
"""simple docstring""" def lowercase ( __snake_case : Optional[int] ): lowercase_ : int = 0 lowercase_ : Optional[Any] = len(__snake_case ) for i in range(n - 1 ): for j in range(i + 1 , __snake_case ): if arr[i] > arr[j]: ...
33
0
'''simple docstring''' def __magic_name__ ( A ) -> Optional[Any]: snake_case = min(SCREAMING_SNAKE_CASE__ ) # min() finds the minimum value snake_case = max(SCREAMING_SNAKE_CASE__ ) # max() finds the maximum value snake_case = max_val - min_val + 1...
367
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import Lear...
332
0
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase (_a ): lowerCamelCase__ : Dict = (IPNDMScheduler,) lowerCamelCase__ : Tuple ...
165
'''simple docstring''' 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_ (_a ): __lowerCAmelCase : Dict = ...
309
0
from __future__ import annotations from fractions import Fraction def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase )-> bool: '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def ...
78
from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...ut...
78
1
import argparse import json from tqdm import tqdm def _UpperCAmelCase ( ): __UpperCamelCase =argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=SCREAMING_SNAKE_CASE__ , default='biencoder-nq-dev.json' , help='Path...
62
"""simple docstring""" import logging from transformers import PretrainedConfig UpperCAmelCase = logging.getLogger(__name__) UpperCAmelCase = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", ...
256
0
"""simple docstring""" def A ( snake_case :int , snake_case :list ) -> str: _enforce_args(snake_case , snake_case ) if n == 0: return 0 __UpperCamelCase = float('-inf' ) for i in range(1 , n + 1 ): __UpperCamelCase = max( snake_case , prices[i - 1] +...
363
"""simple docstring""" import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncodin...
263
0
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class A_ ( SCREAMING_SNAKE_CASE_ ): """simple docstring""" __UpperCamelCase = (DDPMScheduler,) def ...
78
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availabl...
151
0
def lowerCamelCase_ ( lowerCAmelCase: list )-> list: def merge(lowerCAmelCase: list , lowerCAmelCase: list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right r...
357
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", """Pix2S...
260
0
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKING...
103
"""simple docstring""" from importlib import import_module from .logging import get_logger UpperCAmelCase : Any = get_logger(__name__) class lowerCamelCase__ : """simple docstring""" def __init__( self : Optional[int] , UpperCamelCase : List[A...
115
0
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def UpperCamelCase_( ): '''simple docstring''' snake_case_ = ArgumentParser( de...
92
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _snake_case ( unittest.TestCase , lowercase_ ): def lowerCAmelCase__ ( self ) -> Optional[int]: '''simple docstri...
92
1
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer lowercase__ = logging.get_logg...
241
"""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/LICENSE-2.0 # ...
241
1
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device _UpperCAmelCase : Union[str, Any] = False class a__ ( unit...
366
'''simple docstring''' from ..utils import DummyObject, requires_backends class a__ ( metaclass=__A ): """simple docstring""" __UpperCamelCase : int = ['torch', 'scipy'] def __init__(self , *__lowercase , **__lowercase ): ...
9
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMod...
189
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[int] =logging.get_logger(__name__) lowerCamelCase : Dict ={ '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface.co/facebook/s2t-wav2vec2-large-e...
189
1
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common imp...
93
def _a ( SCREAMING_SNAKE_CASE = 10_00 ): """simple docstring""" return sum(e for e in range(3 , SCREAMING_SNAKE_CASE ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f"""{solution() = }""")
93
1
def UpperCAmelCase_ ( __UpperCAmelCase : list[int] , __UpperCAmelCase : list[int] ) -> tuple[float, float]: # Check if the input is valid if not len(__UpperCAmelCase ) == len(__UpperCAmelCase ) == 3: raise ValueError('Please enter a valid...
225
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer lowerCamelCase__ : Union[str, Any] = logging.get_logger(__na...
225
1
from __future__ import annotations from math import ceil, floor, sqrt def A_ ( A__ = 200_0000 ) -> int: a__ : list[int] = [0] a__ : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_numbers.append(triangle_numb...
225
import re from filelock import FileLock try: import nltk lowercase : List[str] = True except (ImportError, ModuleNotFoundError): lowercase : Tuple = False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.download("""punkt""", quiet=True) def...
225
1
"""simple docstring""" import requests snake_case_ = """""" # <-- Put your OpenWeatherMap appid here! snake_case_ = """https://api.openweathermap.org/data/2.5/""" def _lowerCAmelCase ( lowercase_ = "Chicago" , lowercase_ = APPID ): return requests.ge...
78
"""simple docstring""" from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, S...
78
1
'''simple docstring''' import colorsys from PIL import Image # type: ignore def A (__lowerCamelCase :float , __lowerCamelCase :float , __lowerCamelCase :int ): _lowerCAmelCase = x _lowerCAmelCase = y for step in range(__lowerCamelCase ): # noqa: B00...
229
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _lowercase = datasets.logging.get_logger(__name__) _lowercase = """\ @InProceedings{moosavi2019minimum, author ...
229
1
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor __lowerCAmelCase = logging.get_logger(__name__) class __a ( lowerCAmelCase_ ): def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ ) -> ...
196
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available,...
289
0
import argparse import copy def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = {} with open(SCREAMING_SNAKE_CASE ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: lowercase__ = [] _list....
364
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _a : _lowercase : int _lowercase : TreeNode | None = None _lowercase : TreeNode | None = None lowerCAmelCase =...
93
0
"""simple docstring""" import math import tensorflow as tf from packaging import version def A ( snake_case__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = tf.convert_to_tensor(_SCREAMING_SNAKE_CASE ) SCREAMING_SNAKE_CASE__ = 0.5 * (1.0...
165
"""simple docstring""" from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _a ( lowerCAmelCase): """simple docstring""" def lowercase__ ( self : List[Any] , __Upper...
260
0
import argparse UpperCamelCase__ = 'docs/source/_static/js/custom.js' def lowerCAmelCase_ ( __A ) -> str: '''simple docstring''' with open(__A, encoding="utf-8", newline="\n" ) as f: UpperCAmelCase__ = f.rea...
357
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline,...
143
0
from __future__ import annotations from math import pi def _a ( SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ): if (inductance, frequency, reactance).count(0 ) != 1: raise Valu...
92
def _a ( SCREAMING_SNAKE_CASE_ : int = 1_00_00_00 ): __lowerCAmelCase = [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 , SCREAMING_S...
92
1
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_at...
116
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HAS...
116
1
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_avail...
39
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 _lowercase ( unittest.TestCase ): '''simple docstring''' def __magi...
9
0
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_deter...
145
from __future__ import annotations from collections.abc import Callable __UpperCAmelCase = list[list[float | int]] def lowercase__ ( __snake_case : Matrix , __snake_case : Matrix ): '''simple docstring''' UpperCAmelCase_ ...
145
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from t...
93
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE...
93
1
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _a ( _snake_case ): """simple docstring""" UpperCAmelCase , UpperCAmelCase = analyze_text(_snake_case ) ...
234
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _UpperCamelCase = {"""UserAgent""": UserAgent().random} def _a ( _snake_case ): """simple docstring""" U...
234
1
"""simple docstring""" from datetime import datetime as dt import os from github import Github __magic_name__ = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def _lowerCAmelCase ( ): __SCREAMING_SNAKE...
100
import os UpperCAmelCase__ = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} def A ( _UpperCAmelCase : str ) -> int: '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase = 0 while index < len(_UpperCAmelCase ) - 1...
339
0
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _a ( _lowerCamelCase , _lowerCamelCase...
13
'''simple docstring''' 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, ) if is_sentencepi...
13
1
'''simple docstring''' from __future__ import annotations class _lowercase : '''simple docstring''' def __init__( self : List[str] , SCREAMING_SNAKE_CASE__ : int ) -> None: __lowerCAmelCase = order # a_{0} ... a_{k} __...
229
'''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 i...
229
1
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): # Return True if there is node that has not iterated. _UpperCAmelCase : Optional[int] = [False] * len(lowerCamelCase_ ) _UpperCAmelCase : Union[str, Any] ...
368
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCamelCase__ = TypeVar('T') class lowerCAmelCase__ ( Generic[T] ): def __init__( self : Union[str, Any]...
322
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS,...
109
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_M...
93
0
"""simple docstring""" def lowerCAmelCase_ ( __A ) -> list: '''simple docstring''' if len(__lowerCAmelCase ) <= 1: return [tuple(__lowerCAmelCase )] UpperCAmelCase__ = [] def generate(__A, __A ):...
350
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
143
0
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 import logging logging.s...
21
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax...
143
0
"""simple docstring""" import os def UpperCAmelCase__ (): """simple docstring""" with open(os.path.dirname(snake_case__ ) + """/p022_names.txt""" ) as file: _snake_case : str = str(file.readlines()[0] ) _snake_case : Optional[Any] = names.replac...
132
"""simple docstring""" import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def UpperCAmelCase__ (snake_case__ : int = 3 ): """simple docstring""" if isinstance(snake_case__ , snake_case__ ): ...
132
1
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase = 4 ) -> list[list[int]]: """simple docstring""" A : str = abs(_lowerCAmelCase ) or 4 return [[1 + x + y * row_size for x in range(_lowerCAmelCase )] for y in range(_lowerCAmelCase )] ...
116
def __UpperCamelCase ( _lowerCAmelCase = 100_0000 ) -> int: """simple docstring""" A : str = limit + 1 A : Tuple = [0] * limit for first_term in range(1 , _lowerCAmelCase ): for n in range(_lowerCAmelCase , _lowerCAmelCa...
116
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowercase_ = logging.get_logger(__name__) lowercase_ = { "Intel/dpt-large": "https://huggingface.co/Intel/dpt-large/resol...
11
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowercase ( lowerCAmelCase__ : ...
11
1
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling...
145
'''simple docstring''' from __future__ import annotations __a = list[tuple[int, int]] __a = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0...
145
1
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester f...
353
"""simple docstring""" from __future__ import annotations def _lowerCamelCase( a , a , a , a , a , ): __a = len(a ) # If row is equal to the size of the board it means there are a queen in each row in # the current board (possible_board) if row == n: ...
268
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lo...
234
'''simple docstring''' import math def __lowerCAmelCase (__lowerCAmelCase ): return math.sqrt(__lowerCAmelCase ) * math.sqrt(__lowerCAmelCase ) == num def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : int = ...
234
1
'''simple docstring''' import os import string import sys a : List[str] = 1 << 8 a : Tuple = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLAG, 'left': 68 + ARROW_KEY_FL...
72
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Tuple ...
72
1
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def A_ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # In...
13
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.utils import load_numpy, slow...
13
1
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.u...
357
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case__ : Union[str, Any] = { 'configuration_blenderb...
250
0
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def _snake_case ( lowercase__ : Tuple ) -> Optional[Any]: '''simple docstring''' lower...
84
_a = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _a ( SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" __lowerCAmelCase: Optional[int] = 0 while number: # Increased Speed Slightly by checking every ...
322
0
'''simple docstring''' from math import pow, sqrt def UpperCAmelCase ( *a_ ) -> bool: """simple docstring""" A_ : List[str] = len(a_ ) > 0 and all(value > 0.0 for value in values ) return result def UpperCAmelCase ...
164
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from...
164
1
'''simple docstring''' import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _lowercase ( _lowercase , _lowercase ): @register_to_config def __init__( self...
41
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_de...
143
0
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils i...
367
import math def lowerCamelCase__ ( a__ : float , a__ : float ) -> float: if ( not isinstance(a__ , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("""power_factor must be a valid float...
261
0
"""simple docstring""" a :Any = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_...
132
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
132
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import...
350
"""simple docstring""" def snake_case_ ( A_ : float ): '''simple docstring''' if edge <= 0 or not isinstance(A_, A_ ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def ...
175
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-large/resolve/main/config.json', # See all DPT m...
11
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCAmelCase__ = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
11
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class _lowercase ( __a ): ...
85
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable __lowercase = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfi...
85
1
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( _A , _A , _A ): '''simple docstring''' s...
187
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def snake_case ( A__ ): UpperCAmelCase_ : Dict = SwinConfig(image_size=1_92 ) if "base" in mod...
268
0
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class UpperCAmelCase ( tf.keras.layers.Layer ): '''simple docstring''' def __...
357
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
124
0
"""simple docstring""" def snake_case_ ( A_ : list[list] ): '''simple docstring''' _lowerCamelCase : Optional[int] = current_set.copy() for row_index, row in enumerate(A_ ): _lowerCamelCase : Tuple = row[0] ...
72
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.c...
72
1
import cva import numpy as np class _snake_case : def __init__( self , _lowerCamelCase , _lowerCamelCase ): if k in (0.04, 0.06): a :Any = k a :str = window_size else: raise ValueError('''invalid k value''' ) ...
352
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) snake_case : Any = pytest.mark.integration @pytest.mark.parametrize('''path''' , ['''paws''', ''...
281
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :List[str] = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config....
159
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_avai...
250
0
"""simple docstring""" import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase__ ( __a ...
360
"""simple docstring""" from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvaila...
320
0
'''simple docstring''' import os def _A ( ): with open(os.path.dirname(lowercase__ ) + """/grid.txt""" ) as f: lowercase__ = [] # noqa: E741 for _ in range(20 ): l.append([int(lowercase__ ) for x in f.readline().split()] ) ...
164
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def _A ( lowercase__ ): return "".join(sorted(lowercase__ ) ) def _A ( lowercase__ ): return word_by_signature[signature(lowercase__ )] ...
164
1
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_SNAKE_CASE...
359
from ...configuration_utils import PretrainedConfig from ...utils import logging A : Dict = logging.get_logger(__name__) A : Dict = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models at https://h...
276
0
from __future__ import annotations from PIL import Image # Define glider example lowerCAmelCase__ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, ...
11
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _lowercase: Union[str, Any] = get_t...
227
0
def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> int: lowercase : Any = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): lowercase : Any = n - k # Calculate C(n,k) ...
364
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingface_...
285
0
'''simple docstring''' import os def _lowerCamelCase ( ) -> Tuple: with open(os.path.dirname(lowercase ) + "/grid.txt" ) as f: _a = [] # noqa: E741 for _ in range(20 ): l.append([int(lowercase ) for x in f.readline().split()] ) ...
63
from torch import nn class _lowercase ( nn.Module ): def __init__( self : Any , snake_case : Dict , snake_case : Union[str, Any] ) -> Dict: """simple docstring""" super().__init__() UpperCamelCase_ : List[Any] = class_size Upper...
175
0
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" lowerCAmelCase = len(_SCREAMING_SNAKE_CASE ) for _ in range(_SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 , ...
187
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as tr...
187
1
'''simple docstring''' import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer _SCREAMING_SNAKE_CASE : Union[str, Any] = logging.getLogger(__name__) def UpperCamelCase_( ): '''simple docstring''' sna...
85
'''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 _SCREAMING_SNAKE_CASE : Any = F...
85
1
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor _A = transforms.Compose( [ ...
117
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
117
1
"""simple docstring""" from __future__ import annotations import math def A__ ( UpperCamelCase , UpperCamelCase ): if len(UpperCamelCase ) != 2 or len(a[0] ) != 2 or len(UpperCamelCase ) != 2 or len(b[0] ) != 2: raise Exception("Matrices are...
292
def SCREAMING_SNAKE_CASE__ ( lowercase ) -> float: if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) snake_case : Optional[Any] = sum(lowercase ) / len(lowercase ) # Calculate the average return sum(abs(x -...
124
0
from typing import Any class _a : '''simple docstring''' def __init__( self , A__ ): A__ : Dict = data A__ : Optional[int] = None class _a : '''simple docstring''' def __init__( self ): ...
141
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort A_ : Union[str, An...
141
1