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
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin snake_case : List[str] = get_tests_d...
94
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acceler...
94
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) SCREAMING_SNAKE_CASE_: str ={ 'configuration_speecht5': [ 'SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
356
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class __A : @property def _lowercase (self : int ...
106
0
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask ...
17
"""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/LICENS...
173
0
"""simple docstring""" def _lowerCamelCase( lowercase__ ) -> list[int]: '''simple docstring''' __lowercase= len(lowercase__ ) for i in range(lowercase__ ): for j in range(i + 1 , lowercase__ ): if numbers[j] < numbers[i]: __lowercase, ...
367
from __future__ import annotations import numpy as np def _lowerCamelCase( lowercase__ ) -> str: '''simple docstring''' return np.maximum(0 , lowercase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
304
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_SCREAMING_SNAKE_CASE ) class lowerCamelCase (_SCREAMING_SNAKE_CASE ): """simple docstring""" lowerCamelCase__ = field(default...
118
"""simple docstring""" from __future__ import annotations import math def _A ( lowercase ): """simple docstring""" if num <= 0: a =f'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(lowercase ) a =[Tr...
81
0
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, ...
335
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 ...
335
1
"""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_co...
249
'''simple docstring''' import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_mode...
141
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokeniz...
353
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCamelCase = { "configuration_conditional_detr": [ "CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MA...
13
0
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_ge...
47
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { '''configuration_rag''': ['''RagConfig'''], '''retrieval_rag''': ['''RagRetriever'''], ...
106
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ : Any = logging.get_logger(__name__) A_ : Optional[int] = { "facebook/data2vec-text-base": "https://huggingface.co...
351
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class _a (__magic_name__ ): '''simple docstring''' UpperCAmelCase__: Optional[Any] = '''MCTCTFeatureExtractor''' UpperCAmelCase__: Optional[int] = '''...
141
0
def _A ( _lowercase , _lowercase ) -> bool: """simple docstring""" __UpperCamelCase = len(_lowercase ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0)...
310
'''simple docstring''' def __UpperCAmelCase ( A : int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence UpperCAmelCase_ : int = gr...
304
0
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 cached_property from ...test...
328
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqLM, AutoTokeniz...
328
1
"""simple docstring""" import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline SCREAMING_SNAKE_CASE_ : Dict = { 'n_samples': 6_4, 'horizon': 3_2, 'num_inference_steps': 2_0, 'n_guide_steps': 2, # can set to 0 for faster ...
335
"""simple docstring""" class a : """simple docstring""" def __init__( self: Dict ): """simple docstring""" A__ = {} def UpperCamelCase ( self: List[str] ): """simple docstring""" ...
335
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch...
184
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase = True , UpperCamelCase = math.inf , UpperCamelCase = -math.inf , UpperCamelCase = math.inf ...
184
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import rand...
70
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase : Union[str, Any] = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attenti...
13
0
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/c...
104
'''simple docstring''' from __future__ import annotations def _A (lowerCAmelCase__ :int ) -> list[int]: '''simple docstring''' _a = 2 _a = [] while i * i <= n: if n % i: i += 1 ...
104
1
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import...
86
'''simple docstring''' def __UpperCamelCase ( lowercase__ : Union[str, Any]=2_81_23 ): '''simple docstring''' __lowercase =[1] * (limit + 1) for i in range(2, int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1, l...
141
0
'''simple docstring''' def a_ ( lowerCamelCase : int , lowerCamelCase : float , lowerCamelCase : float ): return round(float(moles / volume ) * nfactor ) def a_ ( lowerCamelCase : float , lowerCamelCase : floa...
55
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common im...
55
1
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowercase__ : Optional[int] = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n ...
328
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from a...
328
1
'''simple docstring''' __UpperCAmelCase :dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_9344, "knot": 1.852, } __UpperCAmelCase :dict[str, float] = { "km/h": 1.0, "m/s": 0.2_7777_7778, "mph": 0.6_2137_1192, "knot": 0.5...
367
'''simple docstring''' def _a ( _lowercase : int = 600851475143 ): '''simple docstring''' try: __UpperCAmelCase : str = int(_lowercase ) except (TypeError, ValueError): raise TypeError('''Parameter n must b...
240
0
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_attent...
184
import math import os import sys def lowercase_ ( _A : str ): """simple docstring""" lowerCamelCase__ : str = "" try: with open(_A , "rb" ) as binary_file: lowerCamelCase__ : Union[str, Any] = binary_...
184
1
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils ...
91
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils ...
91
1
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def _A ( A__ ): """simple docstring""" __lowercase = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x...
104
'''simple docstring''' def _A ( A__ = 10 , A__ = 22 ): """simple docstring""" __lowercase = range(1 , A__ ) __lowercase = range(1 , A__ ) return sum( 1 for power in powers for base in bases if len(str(base**power ) ) == pow...
104
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_:Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[str] = { """microsoft/unispeech-large-1500h-cv""": ( """https://huggingfac...
115
from argparse import ArgumentParser from .env import EnvironmentCommand def __UpperCamelCase ( ) -> Dict: """simple docstring""" A : str = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args>]""" ) A : int = ...
115
1
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a_ : Union[str, Any] = TypeVar("""KEY""") a_ : Tuple = TypeVar("""VAL""") @dataclass(frozen=lowercase , slots=lowercase )...
55
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class snake_case ( l...
55
1
"""simple docstring""" from __future__ import annotations def _A (__a , __a ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : Dict = get_failure_array(__a ) # 2) Step through text searching for pattern SCREAMING_SNAKE_CASE_ , ...
318
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffus...
318
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A : List[str] = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP'...
33
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fro...
240
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'facebook/convnextv2-tiny-1k-224': 'https://hugg...
366
def lowerCAmelCase_ ( UpperCamelCase_ ) -> int: UpperCamelCase_ = len(UpperCamelCase_ ) UpperCamelCase_ = len(matrix[0] ) UpperCamelCase_ = min(UpperCamelCase_ , UpperCamelCase_ ) for row in range(UpperCamelCase...
328
0
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig 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_ba...
91
"""simple docstring""" import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, ...
91
1
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): if not arr: return None, None, ...
357
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def lowerCAmelCase_ ( __lowerCamelCase ): __snake_case : Any = [] __snake_case : Optional[Any] = ...
134
0
"""simple docstring""" from collections.abc import Callable def lowerCamelCase ( _UpperCamelCase : Callable[[float], float] , _UpperCamelCase : float , _UpperCamelCase : float ) -> float: '''simple docstring''' __UpperCAmelCase :...
115
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowerCamelCase__ ( ctypes.Structure ): """simple docstring""" __a = ...
115
1
"""simple docstring""" from collections.abc import Callable import numpy as np def _A ( _a : Callable , _a : float , _a : float , _a : float , _a : float ): """simple docstring""" A = int...
77
"""simple docstring""" class lowerCamelCase__ : '''simple docstring''' def __init__( self ) -> Any: A = 0 A = 0 A = {} def UpperCamelCase__ ( self ,lowerCamelCase_ ) ...
77
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase : Tuple = logging.get_logger(__name__) __lowercase : Tuple = { '''fac...
318
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : str = logging.get_logger(__name__) __lowercase : Tuple = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class __lowercase ( _lowercas...
318
1
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor __a :List[str] = logging.get_logger(__name__) class _a ( snake_case_ ): """simple docstring""" def __init__( self : str , *UpperCAmelCase : ...
329
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __a :Optional[Any] = logging.get_logger(__name__) class _a ( snake_case_ ): """simple docstring""" def __init__( self : List[str] , *UpperCAmelCas...
329
1
def __snake_case ( __UpperCamelCase : int ,__UpperCamelCase : list[int] ,__UpperCamelCase : int ): """simple docstring""" def count_of_possible_combinations(__UpperCamelCase : int ) -> int: if target < 0: ...
312
import math def A_ ( snake_case : int ) -> bool: '''simple docstring''' return math.sqrt(snake_case ) * math.sqrt(snake_case ) == num def A_ ( snake_case : int ) -> bool: '''simple docstring''' ...
328
0
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from...
357
'''simple docstring''' import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...t...
311
0
import logging from transformers.configuration_utils import PretrainedConfig lowercase__ : List[str] = logging.getLogger(__name__) class UpperCAmelCase ( lowercase_ ): '''simple docstring''' lowerCAmelCase_ = '''masked_bert''' ...
187
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case : Union[str, Any] = logging.get_logger(__name__) __snake_case : int = { ...
134
0
from typing import Union import fire import torch from tqdm import tqdm def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase = "cpu" , __lowerCamelCase = None ): __a = torch.load(__a , map_location=__a ) for k, v in tqdm(state_dict.items() ): ...
350
def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): # Return True if there is node that has not iterated. __a = [False] * len(__lowerCamelCase ) __a = [] queue.append(__lowerCamelCase ) ...
197
0
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
77
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_...
77
1
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = {'''vocab_file''': '''vocab.json'''} _UpperCamelCase = { ...
365
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transfo...
335
0
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging lowerCAmelCase__ :str = logging.get_logger(__name__) def lowerCAmelCase__ ( a__: Any ...
329
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ :Dict = logging.get_logger(__name__) lowerCAmelCase__ :Optional[int] = {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''} class __a ( UpperCAmelCas...
329
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ , A_ ): while second != 0: lowerCAmelCase__ : List[Any] = first & second first ^= second lowerCAmelCase__ : Optional[Any] = c << 1 return first if __name__ == "__main__": import doctest ...
74
"""simple docstring""" from __future__ import annotations import math __UpperCamelCase : Dict = '''2020.9.26''' __UpperCamelCase : Tuple = '''xcodz-dot, cclaus, dhruvmanila''' def __SCREAMING_SNAKE_CASE ( A_ , A_ , A_ , A_ , A_ ): if n...
74
1
import re from ..utils import cached_file # docstyle-ignore _lowercase : str ="\nHuman: <<task>>\n\nAssistant: " _lowercase : int ="huggingface-tools/default-prompts" _lowercase : List[str] ={"chat": "chat_prompt_template.txt", "run": "run_prompt_template.txt"} de...
170
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def lowercase ( __magic_name__ ): '''simple docstring''' for param in module.parameters(): UpperCAmelCase : Any = False def lowercase ...
311
0
'''simple docstring''' def __lowercase ( __lowercase , __lowercase ) -> bool: '''simple docstring''' return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
368
'''simple docstring''' 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, TensorFlowBe...
174
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) ...
84
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : List[Any] =logging.get_logger(__name__) __lowerCAmelCase : Union[str, Any] ={ """s-JoL/Open-Llama-V1""": """https://huggingface.co/s-J...
197
0
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, TruncationStrategy from ...ut...
371
from collections import defaultdict from math import ceil, sqrt def lowercase__ ( __snake_case : int = 1_000_000 , __snake_case : int = 10 ): '''simple docstring''' UpperCAmelCase_ : defaultdict = defaultdict(__snake_case ) ...
145
0
'''simple docstring''' from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward f...
158
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC SCREAMING_SNAKE_CASE_ : str = parse(importlib.metadata.version('torch')) def _snake_case ( Uppe...
335
0
"""simple docstring""" class UpperCAmelCase_ : def __init__( self : Optional[Any] ) -> None: _UpperCamelCase = {} # Mapping from char to TrieNode _UpperCamelCase = False def _UpperCamelCase ( self : List[str] , ...
54
"""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, nest...
54
1
"""simple docstring""" from math import pow, sqrt def _snake_case ( *snake_case__ : float ): A = len(snake_case__ ) > 0 and all(value > 0.0 for value in values ) return result def _snake_case ( snake_case__ : float , snake_case__ : float ...
74
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowercase = {'''configuration_deit''': ['''DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DeiTConfig''...
74
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) _A = { """configuration_speecht5""": [ """SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SPEECHT5_PRETRAINED_HIFIGA...
369
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _A = { """configuration_layoutlmv3""": [ """LAYOUTLMV3_P...
166
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nic...
103
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Optional[Any] = { """config...
174
0
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging ...
371
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) fr...
3
0
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_utils_ba...
18
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class A__ : """simple docstring""" def __init__( self : Any , lowerCAmelCase__ : Any ) -> Dict: """simple docstring""" _UpperCAmelCase ...
145
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase = 100 , ) -> Optional[int]: snake_case_ = x_start snake_case_ = fnc(lowerCamelCase_ ) ...
358
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( 'files' , [ ['full:README.md', 'dataset_infos.json'], ['empty:README.md', 'dataset_infos...
312
0
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, 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 ...
54
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a__ : Tuple = False class UpperCamelCase_ ( unittest.Test...
54
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration lowerCAmelCase_ = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'''), ('''kernel''', '''wei...
279
import random from .binary_exp_mod import bin_exp_mod def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase=1_000 ) -> str: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd snake_case_ ...
279
1
import unittest from typing import Dict, List, Optional, Union 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_i...
103
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", }...
166
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.t...
250
import sys def _a ( lowerCamelCase: Tuple ) -> Tuple: '''simple docstring''' __A = len(lowerCamelCase ) __A = [[0 for x in range(lowerCamelCase )] for x in range(lowerCamelCase )] __A = [...
250
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 .to...
44
'''simple docstring''' import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( snake_case__ , snake_case__ ): '''simple docstring''' A : str = BeautifulSoup(requests.get(snake_case__ , params=snake_case__ ).content ...
3
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusCo...
181
"""simple docstring""" def _lowerCAmelCase ( ): for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def _lowerCAmelCase ( lowercase_ ): UpperCAmelCase = 1 UpperCAmelCase = 2 while i * i <= n: UpperC...
181
1
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.t...
0
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Pa...
312
0
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_com...
306
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...
306
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class __lowerCAmelCase ( unittest.Test...
279
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 torc...
279
1
"""simple docstring""" def a__ ( __SCREAMING_SNAKE_CASE ) -> float: if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) __lowerCAmelCase: Optional[int] = sum(__SCREAMING_SNAKE_CASE ) / len(__SCREAMING_SNAKE_CASE ) # Calculate ...
364
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available()...
108
0
'''simple docstring''' import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib im...
250
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class a__ ( unittest.TestCase ): def _lowerCamelCase ( self ): """simple docstring""" _lowercase : ...
250
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case : List[str] = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']} ...
281
import math def __lowerCamelCase ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): """simple docstring""" return math.pow(UpperCAmelCase_ , 2 ) - a def __lowerCamelCase ( UpperCAmelCase_ : float ): """simple docstring"""...
281
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ = {'''configuration_reformer''': ['''REFORMER_PRET...
181
'''simple docstring''' import re from filelock import FileLock try: import nltk UpperCamelCase__ = True except (ImportError, ModuleNotFoundError): UpperCamelCase__ = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', qu...
181
1
def __lowerCamelCase ( snake_case__ = 1 ,snake_case__ = 10_00 ): """simple docstring""" _SCREAMING_SNAKE_CASE = 1 _SCREAMING_SNAKE_CASE = 0 for divide_by_number in range(UpperCAmelCase_ ,digit + 1 ): _SCREAMING_SNA...
357
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase = { '''configuration_layoutlmv3''': [ '''L...
125
0
from __future__ import annotations from random import random from typing import Generic, TypeVar _SCREAMING_SNAKE_CASE = TypeVar("""KT""") _SCREAMING_SNAKE_CASE = TypeVar("""VT""") class SCREAMING_SNAKE_CASE_ ( Generic[KT, VT] ): def __init__( sel...
327
from __future__ import annotations import math def UpperCamelCase ( __magic_name__ : list , __magic_name__ : list ) -> list: """simple docstring""" if len(__magic_name__ ) != 2 or len(a[0] ) != 2 or len(__magic_name__ ) != 2 or len(b[...
305
0
"""simple docstring""" import math 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 @datac...
357
def lowerCamelCase_ ( _UpperCamelCase ) -> int: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: raise ValueError('''multipl...
279
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise OptionalDependencyNotAvaila...
26
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''facebook/dpr-ctx_encoder-single-nq-base''': ( '''https://huggingface.co/facebook/dpr-ctx_encoder-...
108
0
'''simple docstring''' import math from collections import defaultdict 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 KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput de...
237
'''simple docstring''' # 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 ...
237
1
import warnings from ..trainer import Trainer from ..utils import logging snake_case : Union[str, Any] = logging.get_logger(__name__) class _snake_case ( snake_case ): def __init__( self , _a=None , **_a ): warnings.warn( "`SageMakerTrainer...
281
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> bool: '''simple docstring''' __magic_name__ : Union[str, Any] = len(_snake_case ) + 1 __magic_name__ : List[str] = len(_snake_case ) + 1 # dp is a 2d matrix where dp[i][j] denotes wh...
281
1
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.te...
241
"""simple docstring""" from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .m...
241
1
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 logging.set_verbosity_info() UpperCamelCa...
92
'''simple docstring''' import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor...
125
0
"""simple docstring""" import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqd...
353
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __magic_name__ (__lowercase ): lowerCamelCase__ = ['''image_processor''', '''tokenizer'''] lowerCamelCase__ = '''ViTImageProcessor''' lowerCamel...
22
0
import unittest import numpy as np def a ( snake_case__: Optional[Any] , snake_case__: List[str] , snake_case__: List[Any] , snake_case__: Any = None , ): '''simple docstring''' lowercase_ = np.shape(_UpperCamelCase ) ...
30
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowerCAmelCase_ = { '''linear''': PIL.Image.Resampling.BILINEAR, '''bilinear''': PIL.Image.Resampling.BILINEAR, ...
279
0
'''simple docstring''' from numpy import exp, pi, sqrt def __a ( _UpperCamelCase: Union[str, Any] , _UpperCamelCase: float = 0.0 , _UpperCamelCase: float = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) **...
357
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _a ( __lowerCAmelCase ...
142
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Tuple =logging.get_logger(__name__) __lowerCAmelCase : Any ={ "microsoft/unispeech-sat-base-100h-libri-ft": ( "https://huggin...
237
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : int | float | str ): try: A__ = float(_lowerCamelCase ) except ValueError: raise ValueError("Please enter a valid number" ) A__ = decimal - int(_lowerCamelCase ) ...
237
1
"""simple docstring""" from scipy.stats import pearsonr import datasets __UpperCamelCase : Any = ''' Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-valu...
363
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ ): if not isinstance(A_ , A_ ): lowerCAmelCase__ : int = f'Input value of [number={number}] must be an integer' raise TypeError(A_ ) if number < 0: return False lowerCAmelCase__ : List[Any] = ...
74
0
"""simple docstring""" import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Token...
241
"""simple docstring""" from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) # TODO Update this lowercase__ = { """facebook/esm-1b""": """https://...
241
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule A__ : Tuple ={'''processing_wav2vec2_with_lm''': ['''Wav2Vec2ProcessorWithLM''']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM...
367
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration A__ : str =5_00_00 A__ : Optional[int] =50_00 A__ , A__ : Optional[int] ...
220
0
"""simple docstring""" def _lowercase ( __snake_case ) -> str: if isinstance(__lowercase ,__lowercase ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(__lowercase ,__lowercase ): raise TypeError("'str' object c...
269
'''simple docstring''' import os from datetime import datetime as dt from github import Github __SCREAMING_SNAKE_CASE :str = [ '''good first issue''', '''feature request''', '''wip''', ] def UpperCAmelCase_ ( ) -> Optional[Any]: '''simple docstring''' ...
22
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, ) UpperCamelCase : Dict = { "configuration_distilbert": [ ...
351
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( snake_case : list[int | float] , snake_case : int , snake_case : int ) -> int | float: """simple docstring""" if len(snake_case ) =...
345
0
"""simple docstring""" def _A ( lowercase ): """simple docstring""" return "".join([hex(lowercase )[2:].zfill(2 ).upper() for byte in list(lowercase )] ) def _A ( lowercase ): """simple docstring""" # Check data validity, fo...
81
import datasets from .evaluate import evaluate _A : Optional[int] = '\\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={EMNLP},\n year={2016...
142
0
"""simple docstring""" def UpperCamelCase ( _A : Optional[int] )-> str: """simple docstring""" if collection == []: return [] # get some information about the collection A__ = len(_lowercase ) A__ = max(_lo...
363
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
0
"""simple docstring""" import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForCondition...
100
"""simple docstring""" class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Dict ,A_ : list[int] ) -> None: A = len(A_ ) A = [0] * len_array if len_array > 0: A = array[0] f...
74
0
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_avail...
370
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/conf...
241
0
import math def _lowerCAmelCase ( __lowerCAmelCase ) -> Optional[Any]: """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 numb...
230
"""simple docstring""" import requests from bsa import BeautifulSoup def _SCREAMING_SNAKE_CASE ( __snake_case : str = "AAPL" ): '''simple docstring''' lowercase = f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}' lowercase = BeautifulSoup(...
220
0
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __snake_case ( __lowerCAmelCase ): a__ = ["""image_processor""", """tokenizer"""] a__ = """AutoImageProcessor""" a__ = """AutoTokenizer""" def __...
358
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE ) ->bool: return credit_card_number.startswith(('34', '35', '37', '4', '5', '6') ) def __a ( _SCREAMING_SNAKE_CASE ) ->bool: a__: Any = credit_card_number a__: Tuple ...
203
0
"""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/lic...
81
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig UpperCamelCase_ = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pytorch''': '''htt...
345
0
"""simple docstring""" from timeit import timeit def a__ ( __lowercase ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) _A = 0 while number: number &= number - 1 result += 1 return res...
163
"""simple docstring""" def a__ ( __lowercase ) -> int: assert ( isinstance(__lowercase , __lowercase ) and number_of_steps > 0 ), f"""number_of_steps needs to be positive integer, your input {number_of_steps}""" if number_of_steps == 1: return 1 ...
163
1
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils im...
75
'''simple docstring''' import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase ( a__ , unittest.TestCase ): '''simple docstring''...
198
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule _UpperCAmelCase : Tuple = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _UpperCAmelCase : ...
9
'''simple docstring''' from __future__ import annotations import math def __magic_name__( lowerCamelCase, lowerCamelCase): if len(lowerCamelCase) != 2 or len(a[0]) != 2 or len(lowerCamelCase) != 2 or len(b[0]) != 2: raise Exception('''Matrices are not 2x2''') __lowerC...
9
1
'''simple docstring''' def _UpperCamelCase ( __A , __A , __A ) -> bool: '''simple docstring''' return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__A ) ) def _UpperCamelCase ( ...
80
"""simple docstring""" import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig lowercase__ = { """facebook/maskformer-swin-base-ade...
241
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase_ = { '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowe...
253
"""simple docstring""" import re import string import numpy as np import datasets lowerCamelCase_ = ''' 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. ''' lowerCamelCase_ = ''' Args...
253
1
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from ...
63
"""simple docstring""" def __lowerCAmelCase ( lowercase : int ) -> bool: """simple docstring""" if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True snake_case : Dict = 4 snake_case : str ...
203
0
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import Pr...
356
# 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 appl...
20
0
'''simple docstring''' from __future__ import annotations from typing import Any class _snake_case : def __init__( self , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase = 0): UpperCAmelCase__ , UpperCAmelCase__ ...
163
'''simple docstring''' import torch from torch import nn class _snake_case ( nn.Module ): def __init__( self , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase=1 , ...
163
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequence...
371
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class snake_case__: """simple docstring""" def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE : Collection[float] | None = None ): ...
121
0