code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceCl...
61
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_avail...
61
1
'''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 from tran...
710
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowercase = logging.get_logger(__name__...
162
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer __UpperCamelCase : Union[str, Any] = {'''vocab_file''': '''vocab....
4
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ : Union[str, Any] = { """configuration_tapas""": ["""TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TapasConfig"""], """tokenization_tapas""": ["""TapasT...
548
0
def _snake_case (__lowercase): UpperCamelCase_ = int(__lowercase) if n_element < 1: UpperCamelCase_ = ValueError('a should be a positive number') raise my_error UpperCamelCase_ = [1] UpperCamelCase_ , UpperCamelCase_ , ...
618
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class _a ( unittest.TestCase ): """simple docstri...
618
1
import random def _snake_case ( __snake_case , __snake_case , __snake_case = False ): _UpperCamelCase = {i: [] for i in range(__snake_case )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: return complete_gr...
10
def __snake_case ( __UpperCamelCase : list ,__UpperCamelCase : int = 0 ): """simple docstring""" A_ = length or len(__UpperCamelCase ) A_ = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: ...
86
0
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, Wav...
718
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { 'configuration_albert': ['ALBERT_PRETRAINE...
142
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase_ = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_...
531
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_m...
531
1
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class SCRE...
703
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between che...
25
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowerCamelCase = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try:...
71
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase ( UpperCamelCase__ : int ): """simple docstring""" # A local function to see if a dot lands in the circle. de...
262
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): import ...
655
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 import Reg...
655
1
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __A = {'''UserAgent''': UserAgent().random} def __a ( lowerCAmelCase_ : int ) -> dict: '''simple docstring''' UpperCAmelCas...
593
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 e...
593
1
"""simple docstring""" import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_o...
393
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError("""Input value must be an 'int' type""" ) lowerCAmelCa...
393
1
"""simple docstring""" def _lowerCamelCase( a ): return " ".join( "".join(word[::-1] ) if len(a ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
528
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_comm...
528
1
'''simple docstring''' from math import isclose, sqrt def _lowerCamelCase ( lowercase : float , lowercase : float , lowercase : float ) -> tuple[float, float, float]: _a = point_y / 4 / point_x _a = 2 * normal_gradient / (...
521
'''simple docstring''' import math import sys def _lowerCamelCase ( lowercase : str ) -> str: _a = "" try: with open(lowercase , "rb" ) as binary_file: _a = binary_file.read() for dat in data: _a ...
521
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Tuple = { 'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'], } try: if not is_torch_available...
519
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_...
506
0
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class snake_ca...
102
# 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 ap...
102
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} t...
47
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTest...
179
0
"""simple docstring""" from __future__ import annotations import math class lowerCamelCase__ : def __init__( self : Optional[int] , _lowercase : int ): A = size # approximate the overall size of segment tree with given value A ...
716
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
91
0
'''simple docstring''' import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py a__ : Dict = '...
51
"""simple docstring""" import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors i...
470
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class UpperCAmelCase_ : lowerCamelCase : int lowerCamelCase : int class UpperCAmelCas...
513
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __snake_case ={ """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """C...
513
1
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class lowerCAmelCase_ ( a__ ): def __init__( self, SCREAMING_SNA...
40
def _SCREAMING_SNAKE_CASE ( a ) -> list: if len(a ) <= 1: return lst __A : Any = 1 while i < len(a ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A : str = lst[i]...
239
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin ...
350
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, Truncation...
350
1
"""simple docstring""" import math import sys def __magic_name__ ( _lowerCamelCase : str ): __a : Optional[int] = """""" try: with open(_lowerCamelCase , """rb""" ) as binary_file: __a : Union[str, ...
581
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType...
581
1
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-g...
155
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __snake_case ( ctypes.Structure ): '''simple docstring''' lowerCAmelCase__ = [("""size""", ctyp...
155
1
'''simple docstring''' import sys import turtle def __snake_case ( lowerCAmelCase : tuple[float, float] , lowerCAmelCase : tuple[float, float] ): return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def __snake_case ( lowerCAmelCase : tuple[float, float] , low...
396
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational...
396
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ : str = { """configuration_timesformer""": ["""TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimesformerConfig"""], } try: if not is_torch_availabl...
702
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import...
208
0
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _lowerCAmelCase = logging.get_logger("transformers.models.speecht5") def _snake_case ( __snake_case , __snake_case , __snake_case ): ...
10
"""simple docstring""" import datasets from .evaluate import evaluate lowerCAmelCase__ = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNL...
626
0
'''simple docstring''' import numpy as np def __UpperCAmelCase ( a_: List[Any], a_: Optional[int], a_: List[Any], a_: Any, a_: Tuple ): _UpperCAmelCase : List[Any] = int(np.ceil((x_end - xa) / h ) ) _UpperCAmelCase : str ...
257
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __a = logging.get_logger(__name__) class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Dict , *lowerCA...
257
1
"""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 ...
223
"""simple docstring""" import math class lowerCAmelCase_ : """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE__=0 ) -> str: # a graph with Node 0,1,...,N-1 """simple docstring""" SCREAMING_SNAKE_CASE__ : ...
223
1
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under ...
704
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils imp...
176
0
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow, ) from trans...
216
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_shapes...
216
1
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torc...
721
"""simple docstring""" import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, lo...
439
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase = {'''configuration_van''': ['''VAN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VanConfig''']} try: if not is_torch_available(): ...
119
'''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, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmel...
119
1
'''simple docstring''' import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, )...
385
'''simple docstring''' from manim import * class _lowerCAmelCase ( __A ): """simple docstring""" def UpperCAmelCase_ ( self ) -> List[str]: A_ : Optional[Any] = Rectangle(height=0.5 , width=0.5 ) A_ : List[str]...
385
1
'''simple docstring''' class lowerCAmelCase__ : '''simple docstring''' def __init__( self : str , a__ : List[Any] , a__ : Optional[Any] , a__ : int ): UpperCAmelCase = name UpperCAmelCase = ...
51
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective...
638
0
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def UpperCAmelCase ( A__ ) -> Any: _snake_case : int = SwinConfig(image_size=1_92 ) if "base" in model_name: _s...
519
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ = { '''configuration_blip_2''': [ '''BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Blip2Config''', '''Blip2QFormerConfig''', '''Blip2Visio...
519
1
'''simple docstring''' from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils i...
210
'''simple docstring''' import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling...
210
1
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipel...
706
__UpperCamelCase : List[Any] = 256 # Modulus to hash a string __UpperCamelCase : Union[str, Any] = 100_0003 def _a ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str ): """simple docstring""" UpperCamelCase__ : Optio...
106
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) class a ( UpperCamelCase_ ): __lowercase = """encoder-decoder""" __lowercase = True ...
416
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xfo...
416
1
'''simple docstring''' import argparse import json import os import re from collections import OrderedDict from os.path import basename, dirname import fairseq import torch from fairseq import hub_utils from fairseq.data.dictionary import Dictionary from transformers import FSMTConfig, FSMTForConditionalGenera...
721
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp impor...
691
0
'''simple docstring''' import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup __snake_case: Tuple = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" " (KHTML, like Gecko) Chrome/70.0.3538.102 Sa...
577
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms imp...
71
0
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available lowerCAmelCase__ = logging.getLogger(__name__) @dataclass class a__ ...
626
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class a__ : """simple docstring""" __lowerCamelCase = field( metadata={'h...
626
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
194
a_ : str = 6_55_21 def __a ( __UpperCAmelCase ): a__ = 1 a__ = 0 for plain_chr in plain_text: a__ = (a + ord(__UpperCAmelCase )) % MOD_ADLER a__ = (b + a) % MOD_ADLER return (b << 16) | a
194
1
'''simple docstring''' from sklearn.metrics import fa_score import datasets SCREAMING_SNAKE_CASE_ = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' SCREAMING_SNAKE_CASE_ = '\nArgs:\n ...
717
'''simple docstring''' from __future__ import annotations SCREAMING_SNAKE_CASE_ = 10 def UpperCamelCase__ ( _lowercase : list[int] ) -> list[int]: __UpperCAmelCase: Union[str, Any] = 1 __UpperCAmelCase: Optional[Any] = max(_lowercase ) while placement <= ma...
466
0
def lowercase ( _lowerCAmelCase ): if num <= 0: raise ValueError("""Input must be a positive integer""" ) UpperCAmelCase__ = [True] * (num + 1) UpperCAmelCase__ = 2 while p * p <= num: if primes[p]: for i in range(p * p , num + 1 , _lowerCAmelCase...
392
import numpy # List of input, output pairs snake_case__ : Optional[Any] = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) snake_case__ : str = (((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9),...
392
1
"""simple docstring""" from string import ascii_uppercase __SCREAMING_SNAKE_CASE = {str(ord(c) - 55): c for c in ascii_uppercase} def A_ ( __lowercase , __lowercase ): if isinstance(__lowercase , __lowercase ): raise TypeError('int() can\'t convert non-string with explicit base...
710
"""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_sentencepiece_available(): from ..ta.tok...
395
0
"""simple docstring""" import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel A: Optional[int] = False A: List[Any] = True A: List[Any] = False if __name__ == "__main__...
160
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...tes...
160
1
'''simple docstring''' from __future__ import annotations import math def a_ ( lowerCamelCase : int , lowerCamelCase : int , lowerCamelCase : bool , lowerCamelCase : list[int] , lowerCamelCase : float ): if depth < 0: raise Va...
711
'''simple docstring''' import warnings warnings.warn( """memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: """ """`from accelerate import find_executable_batch_size` to avoid this warning.""", FutureWarning, )
513
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:Tuple = { """configuration_distilbert""": [ """DISTILBERT_PRETRAINE...
662
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class __snake_case: '''simple docstring''' _UpperCAmelCase ...
708
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase : ...
237
0
def _snake_case ( ): return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] _lowerCAmelCase = generate_large_matrix() _lowerCAmelCase = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], [1, 0]], [[7, 7, 6]], ...
10
import string def lowerCamelCase_ ( lowerCAmelCase: str )-> str: _snake_case : str = '' for i in sequence: _snake_case : Tuple = ord(lowerCAmelCase ) if 65 <= extract <= 90: output += chr(1_55 - extract ) elif 97 <= extract <= 1...
411
0
'''simple docstring''' import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger a__ = get_logger(__name__) class _lowerCAmelCase ( enum.Enum ): """simple docstring""" _lowercase : Tuple ...
713
def _UpperCAmelCase ( a : int = 400_0000 ): snake_case__ = [0, 1] snake_case__ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 snake_case__ = 0 ...
99
0
from importlib import import_module from .logging import get_logger _lowercase : Optional[Any] =get_logger(__name__) class UpperCamelCase_ : def __init__( self : str , lowerCamelCase : Optional[int] , lowerCamelCase ...
364
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __a = logging.get_logger(__name__) class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Any ,...
494
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
507
"""simple docstring""" import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _A = """src/transformers""" # This is to ma...
507
1
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def __lowercase ( __lowerCAmelCase : str , __lowerCAmelCase : str=1 ): if n_shave_prefix_segments >= 0: return ".".join(path.split('.' )[n_...
335
'''simple docstring''' import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { 'vocab...
433
0
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex UpperCAmelCase = logging.getLogger(__name__) class __snake_case: '''simple docstring'...
713
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common imp...
344
0
"""simple docstring""" def lowercase_ ( _lowerCamelCase: List[Any] ) -> Tuple: '''simple docstring''' if not head: return True # split the list to two parts __lowerCamelCase , __lowerCamelCase : List[Any] = head.next, head while fast and fa...
646
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __A = logging.get_logger(__name__) __A = { '''SenseTime/deformable-detr''': '''https://huggingface.co/sensetime/deformable-detr/resolve/main/config.j...
646
1
"""simple docstring""" import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( UpperCamelCase , UpperCamelCase , UpperCamelCase , U...
720
"""simple docstring""" import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import di...
158
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowercase_ ( metaclass=__lowerCAmelCase ): '''simple docstring''' UpperCAmelCase : Union[str, Any] = ['''transformers''', '''torch''', '''note_seq'''] def __init__( self : str , ...
7
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowercase_ ( __lowerCAmelCase ): '''simple docstring''' UpperCAmelCase : Optional[int] = (KDPMaDis...
7
1
import itertools import string from collections.abc import Generator, Iterable def __lowerCAmelCase ( __snake_case , __snake_case ): __lowerCAmelCase = iter(__snake_case ) while True: __lowerCAmelCase = tuple(itertoo...
702
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Ac...
290
0
import warnings from ..trainer import Trainer from ..utils import logging __magic_name__ : Union[str, Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ (_a ): def __init__( self : Optional[int] , __lowerCamelCase : Dict=None ,...
615
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __magic_name__ : Optional[int] = get_te...
615
1
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mix...
708
from decimal import Decimal, getcontext from math import ceil, factorial def __a ( __UpperCAmelCase : int ) -> str: """simple docstring""" if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise TypeError("Undefined for non-integers" ) ...
253
0
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeli...
467
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class UpperCAmelCase ( nn.Module ): def __init__( self : int , __lowerCamelCase : int = 1_6 , __lowerCamelCase ...
467
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase__ = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } ...
6
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowerCAmelCase__ = 3 def __UpperCAmelCase ( lowerCamelCase_) -> int: print('Generating primitive root o...
6
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.default_...
332
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. _UpperCAmelCase = 1_0 def __magic_name__ ( lowercase , lowercase , ...
409
0
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, re...
253
from decimal import Decimal, getcontext from math import ceil, factorial def __a ( __UpperCAmelCase : int ) -> str: """simple docstring""" if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise TypeError("Undefined for non-integers" ) ...
253
1
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerT...
83
import pprint import requests __UpperCAmelCase = 'https://zenquotes.io/api' def __UpperCamelCase ( ) -> list: '''simple docstring''' return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __UpperCamelCase ( ) -> list: '''simple docs...
600
0
"""simple docstring""" # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's eas...
482
"""simple docstring""" from collections import deque class __lowerCAmelCase : """simple docstring""" def __init__( self : Optional[Any] , _snake_case : str , _snake_case : int , _snake_case : int ) -> None: "...
482
1
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class a__ : '''simple do...
90
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ ( unittest.TestCas...
67
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import Hugg...
185
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
185
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
"""simple docstring""" import baseaa def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baadecode(_UpperCamelCase ).decode("utf-...
636
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __magic_name__ ( unittest.TestCase): def _UpperCAmelCase ( self : List[Any] ): UpperCAmelCase ...
707
def __UpperCamelCase ( _lowerCAmelCase = 10 ): """simple docstring""" if not isinstance(_lowerCAmelCase , _lowerCAmelCase ) or n < 0: raise ValueError("Invalid input" ) UpperCAmelCase = 10**n UpperCAmelCase = 2_84_33 * (pow(2 , 7_83_...
405
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, BatchEncoding, PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) _...
346
"""simple docstring""" def a__ ( ) -> list[list[int]]: return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] __A = generate_large_matrix() __A = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, ...
346
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Optional[Any] = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_A...
705
from functools import lru_cache @lru_cache def _lowerCAmelCase ( __magic_name__ :int ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doc...
407
0
from decimal import Decimal, getcontext from math import ceil, factorial def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> str: '''simple docstring''' if not isinstance(lowercase_ , lowercase_ ): raise TypeError('''Undefined for non-integers...
462
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableUn...
462
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow, ...
718
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor lowerCAmelCase__ : Dict = logging.get_logger(__name__) class __snake_case ( _lowerCamelCase ): def __init__( self , *__UpperCamelCase , **__Up...
699
0
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils...
553
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __lowercase ( __snake_case ): _A = (DEISMultistepSc...
461
0
"""simple docstring""" import argparse from collections import defaultdict import yaml UpperCamelCase : Tuple = "docs/source/en/_toctree.yml" def __snake_case ( UpperCamelCase__ ) -> List[str]: """simple docstring""" A = defaultdict(UpperCa...
715
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf UpperCamelCase : Optional[Any] ...
91
0
"""simple docstring""" from __future__ import annotations def A ( snake_case__ , snake_case__ , snake_case__ , ): '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError("""You cannot supply more or less than ...
196
"""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...
196
1
lowerCamelCase__ = 9.80665 def lowerCAmelCase__ ( a__ , a__ , a__ = g ) ->float: '''simple docstring''' if fluid_density <= 0: raise ValueError("Impossible fluid density" ) if volume < 0: raise ValueError("Impossible Object volume" ) if gravity <= 0: ...
701
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf, ...
82
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : str ): '''simple docstring''' return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": ...
135
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, Truncati...
135
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig lowerCamelCase : Any = { 'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/config.json', 'albert-large-v1': 'https://huggingface...
303
from math import ceil def lowercase__( A = 1_0_0_1 ): snake_case__ : Dict = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): snake_case__ : str = 2 * i + 1 snake_case__ : Any = 2 * i snake...
303
1
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase_ ( __lowerCamelCase )...
79
'''simple docstring''' # Copyright 2021 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/LI...
536
0
'''simple docstring''' import os from collections.abc import Iterator def UpperCAmelCase_ ( A = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(A ): _a : List[Any] = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] ...
424
'''simple docstring''' from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase_ : str = TypeVar("T") class a ( Generic[T] ): '''simple docstring''' __lowerCAmelCase : deque[T] # Cache store of keys ...
424
1
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def _snake_case ( A , A ) -> str | Literal[False]: lowerCAmelCase__ = list(A ) lowerCAmelCase__ = list(A ) ...
90
'''simple docstring''' def _snake_case ( A ) -> int: if n == 1 or not isinstance(A , A ): return 0 elif n == 2: return 1 else: lowerCAmelCase__ = [0, 1] for i in range(2 , n...
90
1
import qiskit def _A ( __snake_case :int , __snake_case :int ) -> qiskit.result.counts.Counts: """simple docstring""" __SCREAMING_SNAKE_CASE = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q re...
214
import re def _A ( __snake_case :str ) -> str: """simple docstring""" if len(re.findall("[ATCG]" , __snake_case ) ) != len(__snake_case ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , ...
214
1
from ..utils import DummyObject, requires_backends class _a ( metaclass=UpperCAmelCase__ ): """simple docstring""" A_ = ["""flax"""] def __init__( self , *_UpperCAmelCase , **_UpperCAmelCase ) -> Optional[Any]: requi...
23
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''huggingface/informer-tourism-monthly''': ( '''https://hugg...
95
0
"""simple docstring""" def lowerCAmelCase__ ( lowerCamelCase__ ) -> Tuple: # noqa: E741 lowerCamelCase = len(__A ) lowerCamelCase = 0 lowerCamelCase = [0] * n lowerCamelCase = [False] * n lowerCamelCase ...
708
"""simple docstring""" from __future__ import annotations class UpperCAmelCase__ : def __init__( self : Any , snake_case : list[list[int]] ) -> Union[str, Any]: '''simple docstring''' A = TypeError( 'Matrices must...
109
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import to...
479
def _lowerCamelCase( __snake_case ) -> float: if edge <= 0 or not isinstance(__snake_case , __snake_case ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def _lowerCamelCase( __snake_case ) -> float: ...
524
0
"""simple docstring""" from typing import Any import numpy as np def lowerCamelCase_ ( _lowerCamelCase ): return np.array_equal(_lowerCamelCase , matrix.conjugate().T ) def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): lowerCamelCase__ : U...
714
"""simple docstring""" def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(_lowerCamelCase ) * abs(_lowerCamelCase ) if __name__ == "__main__": import doctest ...
696
0
"""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/...
118
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE...
118
1
def _UpperCAmelCase ( UpperCamelCase: str ): """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(UpperCamelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("doctest").testmod()
376
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", # See all M-CTC-T models at https://huggingfac...
376
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, Dat...
170
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHeadsM...
170
1
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, requir...
712
"""simple docstring""" import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_, SCREAMING_SNAKE_CASE_=1_0_0_0 ): if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd SCREAMING...
406
0
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.model...
64
from __future__ import annotations import math def a_ ( UpperCamelCase_ : float , UpperCamelCase_ : int ) -> float: """simple docstring""" lowerCamelCase = u for i in range(1 , UpperCamelCase_ ): lowerCamelCase = temp * (u - ...
246
0
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def a (_lowerCAmelCase , _lowerCAmelCase=None ): SCREAMING_SNAKE_CASE_ = None if token is not None: SCREA...
89
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class __magic_name__ ( __UpperCAmelCase): '''simple docs...
89
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( lowercase__ = 1_0_0_0_0_0_0 ) -> Any: lowerCAmelCase__ : Tuple = limit + 1 lowerCAmelCase__ : List[Any] = [0] * limit for first_term in range(1 , __UpperCamelCase ): for n in range(__UpperCamelCase , _...
453
'''simple docstring''' import copy import re class lowerCamelCase__: UpperCamelCase : Dict = "hp" UpperCamelCase : Optional[Any] = {} UpperCamelCase : str = None @classmethod def __magic_name__ ( cls , __UpperCAmelC...
566
0
from collections import defaultdict def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): __a = first_str.lower().strip() __a = second_str.lower().strip() # Remove whitespace __a = first_str.replace(' ' , '' ) __a = ...
702
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import...
246
0
def UpperCamelCase ( __lowerCamelCase : Union[str, Any] ): return "".join(chr(ord(_UpperCAmelCase ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
204
'''simple docstring''' def a ( _UpperCAmelCase , _UpperCAmelCase ) -> int: """simple docstring""" return int(input_a == input_a == 0 ) def a ( ) -> None: """simple docstring""" print('Truth Table of NOR Gate:' ) pri...
697
0
from collections import defaultdict from math import ceil, sqrt def UpperCAmelCase_ ( _UpperCAmelCase = 1_0_0_0_0_0_0 , _UpperCAmelCase = 1_0 ): lowerCamelCase_: defaultdict = defaultdict(_UpperCAmelCase ) for outer_width in range(3 , (t_limit // 4) + 2 ...
584
from graphs.minimum_spanning_tree_kruskal import kruskal def UpperCAmelCase_ ( ): lowerCamelCase_: str = 9 lowerCamelCase_: Tuple = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2]...
584
1