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""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_av...
16
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) ...
16
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) _lowerCAmelCase : List[str] ...
340
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax imp...
340
1
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTest...
12
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUM...
12
1
'''simple docstring''' from __future__ import annotations class lowerCamelCase : def __init__( self, lowercase_ = 0 ) -> Optional[int]: snake_case = key def _lowerCamelCase ( self, lowercase_, lowercase_ ) -> list[str]: assert isinstance(lowercase_, lower...
364
'''simple docstring''' from pathlib import Path import fire def __magic_name__ ( A , A , A ) -> Union[str, Any]: snake_case = Path(A ) snake_case = Path(A ) dest_dir.mkdir(exist_ok=A ) for path in src_dir.iterdir(): snake_case = [...
332
0
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __lowerCAmelCase (lowercase_ , lowercase_ ): ...
2
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): lowercase :List[str] = "" for word_or_phrase in separated: if not isinstance(lowerCamelCase, lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separa...
236
0
import os from datetime import datetime as dt from github import Github lowerCamelCase = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '''wip''', ] def...
211
import random from .binary_exp_mod import bin_exp_mod def lowerCamelCase_ ( _a , _a=1_000 ): """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd lowerCAmelCase__ : int =...
211
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class A ( UpperCAmelCase_ ): __UpperCAmelCase : str = 'Speech2TextFeatureExtractor' __UpperCAmelCase : int = 'Speech2TextTokenizer' def __init__(self : ...
65
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ....
207
0
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils impo...
357
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common i...
100
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { '''camembert-base''': '''https://huggingface.co/camembert-base/resolve/ma...
340
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline a_ = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does not use value network '''scale_grad_by_...
340
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
73
"""simple docstring""" import qiskit def lowerCAmelCase_( lowercase_ : int , lowercase_ : int ) -> qiskit.result.counts.Counts: _lowerCamelCase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register ...
73
1
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCamelCase__ = Lock() def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ,...
86
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
0
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers UpperCAmelCase: List[Any] = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def __SCREAMING_SNAKE_CASE ( ): _lowercase : str = os.path.dirname(os.path.realpath(__UpperCA...
336
"""simple docstring""" import pprint import requests UpperCAmelCase: Tuple = """https://zenquotes.io/api""" def __SCREAMING_SNAKE_CASE ( ): return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __SCREAMING_SNAKE_CASE ( ): return requests.ge...
336
1
'''simple docstring''' from collections import Counter from timeit import timeit def lowerCAmelCase (__A = "" , ): """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''').lower()).values()) < 2 def lowerCAmelCase (__A = ""): """simple doc...
211
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = {"configuration_mmbt": ["MMBTConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependency...
211
1
from __future__ import annotations def _a ( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> None: '''simple docstring''' if (direction ...
358
def _a ( SCREAMING_SNAKE_CASE__ : str ) -> str: '''simple docstring''' if not all(char in "01" for char in bin_string ): raise ValueError("Non-binary value was passed to the function" ) if not bin_string: raise V...
191
0
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlitea import sqla...
49
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load...
100
0
'''simple docstring''' import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common im...
249
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common impor...
249
1
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a =logging.get_logger(__name__) a ={ """nielsr/canine-s""": 2048, } # Unicode defines 1,114,112 total “codepoints” a =1114112 # Below: Constants defini...
73
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> float: if discount_rate < 0: raise ValueError('Discount rate cannot be negative' ) if not cash_flows: raise ValueError('Cash flows list cannot be empty' ) __lowerCamelCase : int = sum( cash_...
73
1
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (lowerCAmelCase_ = 4 ): '''simple docstring''' __SCREAMING_SNAKE_CASE = abs(lowerCAmelCase_ ) or 4 return [[1 + x + y * row_size for x in range(lowerCAmelCase_ )] for...
195
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, ...
195
1
import os # Precomputes a list of the 100 first triangular numbers _lowerCamelCase : Any = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a__ ( ) -> Any: UpperCAmelCase : List[Any] = os.path.dirname(os.path.realpath(UpperCAmelCase ) ) UpperCAmelCase ...
336
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
336
1
from math import pi, sqrt, tan def _snake_case( SCREAMING_SNAKE_CASE__ : float ) -> float: '''simple docstring''' if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 de...
355
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_...
282
0
"""simple docstring""" from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from .....
241
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase_ = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
191
0
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats...
208
def _SCREAMING_SNAKE_CASE ( lowercase : Tuple , lowercase : Dict , lowercase : List[str] , lowercase : Dict , lowercase : Dict , lowercase : List[str] ): '''simple docstring''' if index == r:...
208
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'studio-ousia/luke-large'...
249
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
1
lowerCAmelCase__ : List[Any] ={'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} lowerCAmelCase__ : str =['a', 'b', 'c', 'd', 'e'] def a__ ( A__, A__, A__ ): SCREAMING_SNAKE_CASE_ : Optional[int] = start # add current...
162
lowerCAmelCase__ : Dict ='ABCDEFGHIJKLMNOPQRSTUVWXYZ' def a__ ( ): SCREAMING_SNAKE_CASE_ : Tuple = input('Enter message: ' ) SCREAMING_SNAKE_CASE_ : Any = input('Enter key [alphanumeric]: ' ) SCREAMING_SNAKE_CASE_ : ...
162
1
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): if digit_amount > 0: return round(number - int(__SCREAMING_SNAKE_CASE ) , __SCREAMING_SNAKE_CASE ) return number - int(__SCREAMING_SNAKE_CASE ) if __name__ == "__main__": print(decimal_isol...
195
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_dimen...
195
1
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "huggingface/informer-tourism-monthly": ( "https://huggingface.co/huggingface/i...
352
"""simple docstring""" import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config...
149
0
"""simple docstring""" import argparse import struct import unittest class lowerCAmelCase__ : '''simple docstring''' def __init__( self , lowercase ): _lowerCamelCase : List[Any] = data # Initialize hash values ...
96
import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sentencepiece @require_token...
282
0
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : int ): """simple docstring""" if num < 0: return False __magic_name__ : int = num __magic_name__ : int = 0 while num > 0: __magic_name__ : List[Any] = rev_num * 10 + (num...
370
'''simple docstring''' import socket def lowerCamelCase ( ): """simple docstring""" __magic_name__ : List[str] = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) __magic_name__ : Union[str, Any] = socket.gethostname() __magic_name__ : int ...
275
0
'''simple docstring''' class lowerCamelCase_ : """simple docstring""" def __init__( self : Optional[int] , _a : Dict ) -> Optional[Any]: # we need a list not a string, so do something to change the type __lowerCamelCase : List[Any] ...
208
'''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, E...
208
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_attention_mask f...
359
from math import ceil, sqrt def __lowerCamelCase ( lowerCamelCase__ = 1_000_000 ): """simple docstring""" lowercase__ : int = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowercase__ : List[str]...
121
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __lowerCamelCase = { '''configuration_efficientformer''': [ '''EFFICIENTFORMER_PR...
162
'''simple docstring''' import math import unittest def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: assert isinstance(UpperCAmelCase__, UpperCAmelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 ar...
162
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase :Optional[int] = logging.get_logger(__name__) lowerCA...
367
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : int ): """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): __magic_name__ : int = f'Input value of [number={number}] must be an integer' raise TypeError(lowerCAmelCase ) if nu...
275
0
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): __snake_case : str = len(A_ ) + 1 __snake_case : Dict = len(A_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with prefix s...
123
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCAmelCase_ ( A_ ,A_ ,A_): UpperCamelCase__: Dict = ("dense.weight", "attention.self.query", "attention.self.key", "attention.se...
149
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, t...
371
from math import factorial class _UpperCAmelCase : """simple docstring""" def __init__( self : Dict , lowerCAmelCase_ : Optional[int] , lowerCAmelCase_ : str ) -> Union[str, Any]: __lowerCAmelCase = real if isinstance(lowerCAmelCase_ , lowerCA...
207
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class __lowerCAmelCase ( _UpperCAmelCase ): ...
324
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import ena...
275
0
"""simple docstring""" def A_ ( _lowerCAmelCase : List[str] ): """simple docstring""" _a , _a = [], [] while len(_lowerCAmelCase ) > 1: _a , _a = min(_lowerCAmelCase ), max(_lowerCAmelCase ) start.append(_lowerCAmelCase ...
369
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def A_ ( _lowerCAmelCase : Dict, _lowerCAmelCase : List[str], _lowerCAm...
153
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Union[str, Any] = { "configuration_deberta": ["DEB...
28
import random from .binary_exp_mod import bin_exp_mod def lowerCamelCase__ ( a , a=10_00 ) -> Optional[int]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd _A: List[Any] = n - 1 _A: Dict = 0 while d % 2 ==...
121
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class snake_case__ ( _a ): _snak...
370
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() SCREAMING_SNAKE_CASE__:Dict = logg...
268
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_...
46
def _lowercase ( lowercase__ , lowercase__ ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__":...
275
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A : List[str] = { '''configuration_electra''': ['''ELE...
227
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaa...
227
1
A__ = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' A__ = [{'type': 'code', 'content': INSTALL_CONTENT}] A__ = { '{processor_...
230
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_commo...
207
0
import argparse import datetime def __magic_name__ ( __a : str ): '''simple docstring''' UpperCamelCase__ = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wednesday""", """4""": """Thursda...
178
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils impo...
178
1
"""simple docstring""" import functools def _snake_case ( lowercase__ : int , lowercase__ : Any ) -> List[Any]: '''simple docstring''' if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) or not all(isinstance(_SCREAM...
84
"""simple docstring""" from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase , UpperCamelCase = set(_SCREAMING_SNAKE_CASE ), [start] while stack: UpperCamelCase = stack.pop() ...
153
0
import numpy # List of input, output pairs UpperCamelCase__ : int = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) UpperCamelCase__ : Optional[int] = (((515, 22, 13), 555), ((61, 35, 49), 150)) UpperCamelCas...
330
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. A...
330
1
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "huggingface/autoformer-tourism-monthly": "https://huggingface.co/huggingface/autoformer-tourism-month...
35
"""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
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Ten...
157
"""simple docstring""" import argparse import os import re _SCREAMING_SNAKE_CASE : List[str] = """src/diffusers""" # Pattern that looks at the indentation in a line. _SCREAMING_SNAKE_CASE : Optional[int] = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in grou...
157
1
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class _lowercase ( lowerCAmelCase ): """simple docstring""" def __init__(self , lowerCamelCase_ , lowerCamelCase_ ): ""...
227
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) de...
227
1
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizer...
358
"""simple docstring""" from string import ascii_uppercase __magic_name__ = {str(ord(c) - 55): c for c in ascii_uppercase} def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): if isinstance(UpperCamelCase_ , UpperCamelCase_ ): raise TypeError("""int() can't convert no...
255
0
from __future__ import annotations lowercase = 1.6_021e-19 # units = C def __UpperCAmelCase ( a_ , a_ , a_ , ): if (conductivity, electron_conc, mobility).count(0) != 1: raise ValueError('You cannot supply more or less than 2 value...
178
from __future__ import annotations def __UpperCAmelCase ( a_ , a_ , a_ , a_): # noqa: E741 while r - l > 1: snake_case_ = (l + r) // 2 if v[m] >= key: snake_case_ = m else: ...
178
1
from sklearn.metrics import matthews_corrcoef import datasets __lowerCAmelCase = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true and...
359
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if not (isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )): raise ValueError("""longest_comm...
270
0
import numpy # List of input, output pairs a_ = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) a_ = (((515, 22, 13), 555), ((61, 35, 49), 150)) a_ = [2, 4, 1, 5] a_ = len(train_data) a_ = 0.0_09 ...
330
def a__ ( _UpperCamelCase : int ): __lowerCamelCase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
330
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_im...
371
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __UpperCamelCase : Dict = logging....
309
0
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _UpperCamelCase ( snake_case__, snake_case__, snake_case__ ) -> Tuple: __UpperCAmelCase : Tuple = ("dense.weight", "attention.self.query...
157
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, logging from .be...
157
1
def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = len(UpperCAmelCase_ ) while cur > 1: # Find the maximum number in arr lowercase__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi lowercase__ = ar...
353
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
0
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder lowerCAmelCase__ = """__DUMMY_TRANSFORMERS_USER__""" lowerCAmelCase__ = """Dummy User""" lowerCAmelCase__ = """hf_hZEmno...
68
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTra...
255
0
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_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, DPRQ...
339
from datetime import datetime as dt import os from github import Github SCREAMING_SNAKE_CASE__ : Any = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __magic_name__ ( ) -> Any: ...
339
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMv2...
90
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ : List[Any] = TypeVar("T") def __magic_name__ ( __lowerCAmelCase : int ) -> int: return (position - 1) // 2 def __magic_name__ ( __lowerCAmelCase : ...
270
0
import argparse import struct import unittest class SCREAMING_SNAKE_CASE : def __init__( self : str , lowerCAmelCase : Optional[int] ) -> List[Any]: """simple docstring""" __lowerCAmelCase : List[Any] = ...
357
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=a_ ) class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring""" lowerCamelCase : s...
139
0
'''simple docstring''' import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_p...
35
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 1_00 ) -> int: _lowerCAmelCase : Optional[Any] = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": ...
309
0
"""simple docstring""" import mpmath # for roots of unity import numpy as np class lowerCamelCase__ : """simple docstring""" def __init__( self : Union[str, Any] , UpperCamelCase : List[str]=None , UpperCamelCase : int=None ): '''simple docstring...
320
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cac...
320
1
'''simple docstring''' import argparse import hashlib # hashlib is only used inside the Test class import struct class a__ : def __init__( self : str , a : Dict ): """simple docstring""" __lowerCamelCase = data __lowerCamelCase = [0x67452301...
67
'''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
0
'''simple docstring''' def __a ( _UpperCamelCase: int , _UpperCamelCase: int ) -> str: """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(_UpperCamelCase , int(b / 2 ) ) * actual_power(_UpperCamelCas...
142
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset fro...
142
1
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_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, D...
339
import os import sys import unittest UpperCAmelCase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, re...
339
1
'''simple docstring''' def __UpperCAmelCase ( a_: float, a_: float ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 if __name__ == "__m...
17
'''simple docstring''' import baseaa def __UpperCAmelCase ( a_: str ): return baseaa.baaencode(string.encode("utf-8" ) ) def __UpperCAmelCase ( a_: bytes ): return baseaa.baadecode(a_ ).decode("utf-8" ) if __name__ == "__main__": ...
17
1
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def ...
70
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers...
139
0
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_deter...
38
"""simple docstring""" import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __UpperCamelCase = models.Se...
38
1
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def A_ ( _lowerCAmelCase : float, _lowerCAmelCase : float ): """simple docstring""" if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) ...
320
"""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 __snake_case = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell p...
320
1
class _UpperCAmelCase : def __init__( self : Optional[Any] ): snake_case_ : int = """""" snake_case_ : str = """""" snake_case_ : Dict = [] def _snake_case ( self : Tuple , lowercase_ : int , lowercase_ : int ): if m =...
371
"""simple docstring""" 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_CO...
155
0
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _a ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> Tuple: """simple do...
142
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , A : Any ) ->Optional[int]: lowerCamelCase__ : Optional[int] = data lowerCamelCase__ : Any = None class __SCREAMING_SNAK...
142
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowercase : Any = {'configuration_mra': ['MRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MraConfig']} ...
358
'''simple docstring''' def lowerCamelCase (_SCREAMING_SNAKE_CASE : int ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
294
0
"""simple docstring""" def _A ( UpperCamelCase_ : float, UpperCamelCase_ : float) -> float: '''simple docstring''' if density <= 0: raise ValueError("Impossible fluid density") if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus") return (bulk...
17
"""simple docstring""" import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder _a = '__DUMMY_TRANSFORMERS_USER__' _a = 'Dummy User' _a = 'hf_hZEmnoOEYISjraJtbySaKCNnSuYAvukaT...
17
1
"""simple docstring""" class snake_case : def __init__( self : List[str] , a__ : int , a__ : Any=None , a__ : Dict=None ) -> str: '''simple docstring''' _A = data _A = previous ...
163
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from...
163
1
# using dfs for finding eulerian path traversal def SCREAMING_SNAKE_CASE_ ( __magic_name__ : str , __magic_name__ : Union[str, Any] , __magic_name__ : Any , __magic_name__ : int=None ) -> Union[str, Any]: """simple docstring""" UpperCamelCase :Any ...
38
import re import string import numpy as np import datasets UpperCAmelCase_ : Dict = ''' Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. ''' UpperCAmelCase_ : Any = ''' Args: ...
38
1
"""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 class ...
364
"""simple docstring""" import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a__ ( snake_case__ ) -> List[str]: lowerCamelCase = [ """decoder.version""", """decoder.output_projecti...
168
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
18
"""simple docstring""" import argparse import json from tqdm import tqdm def lowercase () -> Dict: '''simple docstring''' lowerCAmelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( """--src_path""" , type=s...
155
0
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(a ) , """Tatoeba directo...
206
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : int = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { '''microsoft/unispeech-sat-base-100h-libri-ft''': ( ''...
206
1
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , ...
136
"""simple docstring""" import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_I...
294
0
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) ...
371
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common i...
55
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 BaseTransformersCLIC...
163
'''simple docstring''' from __future__ import annotations def _UpperCamelCase ( UpperCamelCase__ ): return [ord(UpperCamelCase__ ) - 9_6 for elem in plain] def _UpperCamelCase ( UpperCamelCase__ ): return "".join(chr(elem + 9_6 ) for...
163
1
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 from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( Aut...
364
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { """kakaobrain/align-base""": """http...
35
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowercase_ ( _lowerCamelCase : Union[dict, list, tuple, torch.Tensor]): ...
87
'''simple docstring''' import numpy as np class a : def __init__( self ) -> List[str]: _a = (0, 0) _a = None _a = 0 _a = 0 _a = 0 def __eq__( self , __magic_name__...
168
0
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( _lowerCamelCase: Optional[int] , _lowerCamelCase: List[Any] , _lowerCamelCase: O...
64
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json''', '''RWKV/rwkv-4-430m-pile''': '''https:/...
64
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCamelCase :Union[str, Any] = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
206
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowerCamelCase :str = TypeVar('''T''') class _lowerCAmelCase (...
206
1
'''simple docstring''' import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : Any =logging.get_logger(__name__) __lowerCAmelCase : Optional[Any] ...
362
'''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 transformers import ( ...
123
0
def UpperCamelCase (lowercase_: list ) -> Tuple: if len(UpperCAmelCase_ ) < 2: return collection def circle_sort_util(lowercase_: list , lowercase_: int , lowercase_: int ) -> bool: A__ : Dict = False if low == high: return swapped A__ ...
192
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils impo...
55
0
"""simple docstring""" from __future__ import annotations import time import numpy as np snake_case_ = [8, 5, 9, 7] snake_case_ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] snake_case_ = [ [3, 2, 1, 4], [0...
369
"""simple docstring""" import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging snake_case_ = logging.get_logger(__name__) def _lowerCAmelCase ( lowercase_ ): Uppe...
181
0
"""simple docstring""" import math def lowercase ( _snake_case : int ) ->bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ar...
102
'''simple docstring''' # Function to print upper half of diamond (pyramid) def __snake_case( _lowerCAmelCase ) -> Any: for i in range(0 , _lowerCAmelCase ): for _ in range(0 , n - i - 1 ): # printing spaces print(""" """ , end="""""" ) ...
35
0
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 SCREAMING_SNAKE_CASE : Dict = logging.g...
252
from __future__ import annotations from random import random class UpperCamelCase : '''simple docstring''' def __init__( self , UpperCamelCase_ = None ): lowercase_ :Tuple = value lowercase_ :Tuple = r...
252
1
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) fr...
64
"""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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging ...
64
1
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list , snake_case_ :int , snake_case_ :int , snake_case_ :int ): __UpperCAmelCase = [] __UpperCAmelCase , __UpperCAmelCase = input_li...
353
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowercase : int = logging.get_logger(__name__) _lowercase : Tuple ...
86
0
'''simple docstring''' import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel _UpperCamelCase = False _UpperCamelCase = True _UpperCamelCase = False if __name__ == "__main_...
254
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCAmelCase_ ( __lowerCamelCase ...
123
0
"""simple docstring""" from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENT...
182
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : List[str] = str(_UpperCamelCase ) return len(_UpperCamelCase ) == 9 and set(_UpperCamelCase ) == set('123456789' ) def __lowerCAmelCase (): for base_n...
182
1
import datasets from .evaluate import evaluate SCREAMING_SNAKE_CASE :List[str] = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv prepri...
15
'''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 --u...
181
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case__ : Union[str, Any] = { 'configuration_canine': ['CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CanineConfig'], 'tokeniz...
356
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
250
0
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import UNCONDITIO...
252
import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowerCamelCase ( lowerCamelCase__ : List[str] , lowerCamelCase__ : Optional[Any...
252
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = [ 'encoder.version', ...
355
from __future__ import annotations def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' snake_case_ = [] create_all_state(1 , UpperCamelCase__ , UpperCamelCase__ , [] , ...
200
0
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch ...
95
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Conf...
86
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import ...
198
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def UpperCamelCase ( _A : Tuple )-> Dict: ...
198
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __UpperCamelCase : Optional[Any] = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: ...
182
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
182
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ = {"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeiTConf...
30
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
30
1