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
def UpperCAmelCase_ ( __lowerCAmelCase ) -> Optional[Any]: stooge(_SCREAMING_SNAKE_CASE , 0 , len(_SCREAMING_SNAKE_CASE ) - 1 ) return arr def UpperCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> str: if i >= h: ...
156
from argparse import ArgumentParser from .env import EnvironmentCommand def __lowercase ( ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args>]""" ) SCREAMING_...
296
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_availabl...
48
'''simple docstring''' from sklearn.metrics import fa_score import datasets lowerCamelCase = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ lowerCamelCase = """ Args: predictions ...
48
1
"""simple docstring""" from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class _UpperCAmelCase : '''simple docstring''' pass
102
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def snake_case_ ( A_ : Any ): '''simple docstring''' _lowerCamelCase : Any = [ '''encoder.ve...
72
0
from typing import Any class lowerCamelCase_ : '''simple docstring''' def __init__( self : Optional[Any] , __lowerCamelCase : Any ) -> Any: A : Union[str, Any] = data A : Any = None ...
356
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_ava...
256
0
import random class A__ : """simple docstring""" @staticmethod def __lowercase ( lowercase) -> tuple[list[int], list[int]]: '''simple docstring''' a__ : Union[str, Any] = [ord(lowercase) for i in text] a__ : int = []...
99
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : List[Any] = { '''configuration_distilbert''': [ ...
264
0
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = None ): if version.parse(hfh.__version__ ).rele...
352
'''simple docstring''' import functools def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): # Validation if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or not all(isinstance(UpperCamelCase__ , UpperCamelCase__ ) for day in days ): raise V...
283
0
'''simple docstring''' def _lowerCamelCase ( lowercase : float , lowercase : int ) -> float: if digit_amount > 0: return round(number - int(lowercase ) , lowercase ) return number - int(lowercase ) if __name__ == "__main__": ...
63
'''simple docstring''' from ....utils import logging lowerCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" def __init__( self : Tuple , __a : int , ...
63
1
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked befor...
370
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json''', } class _snake_case ...
342
0
UpperCAmelCase_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def lowerCamelCase__ ( ): '''simple docstring''' __lowerCamelCase = input("""Enter message: """ ) __lowerCamelCase = input("""Enter key [alphanumeric]: """ ) __lowerCamelCase = input(...
12
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort UpperCAmelC...
12
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer __SCREAMING_SNAKE_CASE : List[Any] = {'''vocab_file''': '''vocab.txt''...
73
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowerCAmelCase_( lowercase_ : float , lowercase_ : float , lowercase_ : bool = False ) -> list[fl...
73
1
from __future__ import annotations from collections.abc import Iterator class SCREAMING_SNAKE_CASE__ : def __init__( self , a): lowercase__ : Dict = value lowercase__ : Node | None = None lowercase__ : Node | None =...
214
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-...
214
1
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging __A = logging.get_logger(__name__) __A = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } cl...
64
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _snake_case ( a__ ): def __init__( self : Option...
64
1
from __future__ import annotations def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' return len(set(UpperCamelCase__ ) ) == len(UpperCamelCase__ ) if __name__ == "__main__": import doctest doctest.testmod()
285
from __future__ import annotations import numpy as np def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ , snake_case_ = np.shape(UpperCamelCase__ ) if rows != columns: snake_case_ = ( ...
285
1
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokenizer, ...
78
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, ...
78
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = "The quick brown fox jumps over the lazy dog" , ): """simple docstring""" lowerCAmelCase__ : str = set() # Replace all the whitespace in our sentence lowerCAmelCase__ : Tuple ...
37
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__na...
37
1
"""simple docstring""" 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 ) -> Optional[int]: '''simple docstring''' _lowerCamelCase : Di...
369
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> str: '''simple docstring''' _lowerCamelCase : int = len(_lowerCamelCase ) _lowerCamelCase : int = len(_lowerCamelCase ) _lowerCamelCase : int = ...
340
0
import datasets from .evaluate import evaluate a_ = "\\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}\n}\n" a_ ...
175
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def a( A : dict ) -> tuple: """simple doc...
227
0
'''simple docstring''' def _lowerCAmelCase ( __snake_case : str , __snake_case : str ) -> str: __A : int = len(__snake_case ) __A : int = len(__snake_case ) __A : int = ( first_str_leng...
190
'''simple docstring''' import itertools import math def _lowerCAmelCase ( __snake_case : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Ne...
190
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __a = logging.get_logger(__name__) __a ...
66
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging logging.set_...
76
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
366
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 disable_progress...
252
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ = { '''configuration_re...
181
'''simple docstring''' import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProc...
181
1
from timeit import timeit snake_case : Tuple = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan a canal panama" } # Ensure our test dat...
353
from ...configuration_utils import PretrainedConfig class _snake_case ( _snake_case ): SCREAMING_SNAKE_CASE__ = 'bert-generation' def __init__( self , _lowerCamelCase=5_0358 , _lowerCamelCase=1024 , _lowerCamelCase=24 , _lowerCamelCase=16 , _lowerCamelCase=4096 , _lowerCamelCase="g...
281
0
"""simple docstring""" import os from math import logaa def _A ( UpperCamelCase_ : str = "base_exp.txt") -> int: '''simple docstring''' __lowercase = 0 __lowercase = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(UpperCamelCase_), Upper...
17
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { 'huggingface/time-series-transformer-tourism-monthly': ( 'https://huggingface.co/huggin...
17
1
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase ): if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise ValueError('iterations must be defined as integers' ) if not isinstance(_UpperCamelCase , _UpperCamelCase ) or not number >= 1: raise ValueError( ...
182
"""simple docstring""" import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, ...
182
1
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full...
205
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging UpperCAmelCase = logging.get_logger(__name__) def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = r'\w+[.]\d+' ...
195
0
import numpy as np def __snake_case ( _UpperCAmelCase ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
131
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __snake_case :Tuple = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try: if not...
131
1
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A_ ( unittest.TestCase ): def lowercase ( self ...
22
'''simple docstring''' class a__ : def __init__( self , _UpperCamelCase ): """simple docstring""" _lowercase : Tuple = n _lowercase : Any = [None] * self.n _lowercase : Tuple = 0 # index of the first element _lower...
250
0
"""simple docstring""" def a__ ( __lowercase , __lowercase ) -> int: return 1 if input_a == input_a else 0 def a__ ( ) -> None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , ...
163
"""simple docstring""" from collections.abc import Generator from math import sin def a__ ( __lowercase ) -> bytes: if len(__lowercase ) != 32: raise ValueError("Input must be of length 32" ) _A = B"" for i in [3, 2, 1, 0]: littl...
163
1
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowerCamelCase_ = '''\ ''' lowerCamelCase_ = ''' Perplexity (PPL) is one of the most common...
268
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) # pylint: disable=invalid-name class Uppe...
268
1
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __A : Optional[Any] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generation and...
363
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Union[str, Any] = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfi...
323
0
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ ) -> List[Any]: if len(_lowerCAmelCase ) <= 1: return lst __lowerCamelCase = 1 while i < len(_lowerCAmelCase ): if lst[i - 1] <= lst[i]: i += 1 else: __lowerCamelCase , _...
67
"""simple docstring""" import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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 ImagePr...
301
0
"""simple docstring""" __snake_case : Any = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66...
58
"""simple docstring""" from ....utils import logging __snake_case : Optional[Any] = logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self: str , _SCREAMING_SNAKE_CA...
58
1
'''simple docstring''' def _lowerCamelCase ( lowercase : int , lowercase : int ) -> str: return base * power(_a , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') ...
63
'''simple docstring''' from ..utils import DummyObject, requires_backends class _a ( metaclass=__a ): __a : int = ["""flax""", """transformers"""] def __init__( self : Optional[Any] , *lowercase : str , **lowercase : List[Any] ): ...
34
0
'''simple docstring''' import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import Mar...
9
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import requ...
9
1
"""simple docstring""" import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowercase = logging.get_logger(__name__) ...
40
"""simple docstring""" import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, ...
183
0
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> list: """simple docstring""" def merge(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) ...
357
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_...
60
0
class __a : def __init__( self : List[str] , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : Optional[int]=None , SCREAMING_SNAKE_CASE : Union[str, Any]=None ): '''simple docstring''' UpperCamelCase...
189
# 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 # # U...
189
1
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_...
360
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowercase : Any = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} ...
36
0
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowerCAmelCase__ = datasets.logging.get_logger(__name__) lowerCAmelCase__ = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for ...
108
import doctest from collections import deque import numpy as np class _a : """simple docstring""" def __init__( self: Union[str, Any] ): '''simple docstring''' UpperCamelCase__: int = [2, 1, 2, -1] UpperCa...
149
0
'''simple docstring''' class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Tuple , UpperCamelCase__ : str = "" , UpperCamelCase__ : bool = False ): """simple docstring""" UpperCamelCase ...
357
'''simple docstring''' def __lowerCamelCase ( A__ , A__ ) -> float: """simple docstring""" if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bu...
249
0
"""simple docstring""" 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_torc...
289
"""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, )
289
1
import argparse import copy def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> List[Any]: __lowerCamelCase : Optional[Any] = {} with open(a__ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __lowerCamelCase : int = [] ...
361
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 ="""src/transformers""" a ="""docs/source/en""" ...
113
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : int = { '''configuration_lilt''': ['''LILT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LiltConfig'''], } try: if not is_torch_available(): raise Optio...
143
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 .tokenization_rembert...
143
1
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class __SCREAMING_SNAKE_CASE ( _Upper...
310
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowerCamelCase__ = {"UserAgent": UserAgent().random} def lowercase__ ( lowercase_ ) -> dict: """simple docstrin...
310
1
'''simple docstring''' 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 ...
47
"""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 A_ : List[Any] = logging.get_logger(__na...
165
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Tuple = logging.get_logger(__name__) A__ : Optional[int] = {} class snake_case__ ( SCREAMING_SNAKE_CASE_ ): A__ = '''llama''' A__ = ['''p...
0
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKIN...
92
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ...t...
348
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSemant...
125
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
1
def _A ( _lowercase , _lowercase ) -> List[str]: """simple docstring""" return number | (1 << position) def _A ( _lowercase , _lowercase ) -> Union[str, Any]: """simple docstring""" return number & ~(1 << ...
310
def a ( snake_case__: list ): '''simple docstring''' if len(snake_case__ ) <= 1: return [tuple(snake_case__ )] lowercase_ = [] def generate(snake_case__: int , snake_case__: list ): if k == 1: res....
30
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''xlm-mlm-en-2048''': '''https://hugg...
361
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, r...
22
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INP...
103
from pathlib import Path import fire def UpperCamelCase( __UpperCamelCase : str ,__UpperCamelCase : str ,__UpperCamelCase : int ): lowerCAmelCase_ : List[str] = Path(__UpperCamelCase ) lowerCAmelCase_ : Union[str, Any] = Path(__UpperCamelCase ) d...
103
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Tuple = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.j...
206
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar _lowerCamelCase : Union[str, Any] = TypeVar('''T''') class lowercase ( Generic[T]...
206
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class lowercase( ...
64
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __A : Any = logging.get_logger(__name__) __A : ...
154
0
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def snake_case__ ( SCREAMING_SNAKE_CASE_ : BertModel , SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' ...
359
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore snake_case_ = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" snake_case_ = [file for file in filepaths if file != ...
216
0
class a__ : def __init__( self : Optional[Any],_A : int,_A : List[str]=None,_A : Tuple=None ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Tuple = data SCREAMING_SNAKE_CASE_ : int = previous ...
18
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCamelCase : List[str] = logging.get_logger(__name__) __lowerCamelCase : Tuple ...
18
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
from timeit import timeit def __snake_case ( _UpperCAmelCase ): if number < 0: raise ValueError('''the value of input must not be negative''' ) __a = 0 while number: number &= number - 1 result += 1 return result def __snake_case ( ...
49
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _A ( __UpperCAmelCase ): UpperCamelCase__ : Tuple = (DDPMParallelScheduler,) def _lowerCamelCase ( self : int , **__SCREAMING_SNAKE_...
49
1
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
209
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ : List[Any] = { 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_available(): raise...
209
1
"""simple docstring""" from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class _SCREAMING_SNAKE_CASE ( _UpperCamelCase ): UpperCAmelCase_ :int = CustomTokenizer pass
84
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_t...
130
0
def __magic_name__ ( __lowerCAmelCase : Dict , __lowerCAmelCase : Any , __lowerCAmelCase : Union[str, Any] , __lowerCAmelCase : Dict , __lowerCAmelCase : Dict , __lowerCAmelCase : Optional[int] ) -> List[Any]: if index == r...
339
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Optional[Any] = {...
339
1
'''simple docstring''' import argparse import os import re import packaging.version UpperCAmelCase_ = 'examples/' UpperCAmelCase_ = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version__\s+=...
346
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class lowerCAm...
346
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Union[str, Any] = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise OptionalD...
41
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) snake_case : List[str] = {"configuration_beit": ["BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BeitConfig", "BeitOnnxConfig"]}...
41
1
from typing import Any def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ , ): _validation( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ ...
9
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _lowerCAmelCase = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems...
37
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/check_copies.py __snake_c...
371
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VAR...
112
0
"""simple docstring""" import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class __snake_case ( unittest.TestCase ): def lowerCamelCase_ ( self) -> Any: '''simple docstring''' ...
290
"""simple docstring""" from math import pow, sqrt def __a ( *_SCREAMING_SNAKE_CASE ) ->bool: a__: Union[str, Any] = len(_SCREAMING_SNAKE_CASE ) > 0 and all(value > 0.0 for value in values ) return result def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
290
1
'''simple docstring''' import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __SCREAMING_SNAKE_CASE :Tuple = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any m...
371
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging __SCREAMING_SNAKE_CASE :Tuple = '''\ ''' __SCREAMING_SNAKE_CASE :Union[str, Any] = ...
156
0
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 4_0_0 * 2**2_0, 6_0_0 * 2**2_0] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 1_0_0 * 2**2_0, 9_0_0 ...
265
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__ : List[str] = { """huggingface/infor...
224
0
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class __A ( unittest.TestCa...
262
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __A ( a , unittest.TestCase ): __A = ...
262
1
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 lowercase : str = logging.get_logger(__name__) low...
232
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging im...
88
0
def lowerCAmelCase_ ( snake_case_ ): if not isinstance(snake_case_,snake_case_ ): _A : Any = f'''Input value of [number={number}] must be an integer''' raise TypeError(snake_case_ ) if number < 0: return False _A ...
343
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) _snake_case = logging.getLogger() def lowerCAmelCase_ ...
343
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_devic...
95
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decoder, DecoderOutput, Encoder, ...
122
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline,...
52
'''simple docstring''' import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_toke...
52
1
'''simple docstring''' import math def __snake_case ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): return math.pow(UpperCAmelCase_ , 2 ) - a def __snake_case ( UpperCAmelCase_ : float ): return 2 * x d...
55
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" snake_case_ = '''EncodecFeatureExtractor''' ...
90
0
"""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_ma...
361
import torch from diffusers import StableDiffusionPipeline __lowerCAmelCase = '''path-to-your-trained-model''' __lowerCAmelCase = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('''cuda''') __lowerCAmelCase = '''A photo of sks dog in a bucket''' ...
288
0
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : Any = 0 if start ...
37
'''simple docstring''' from pathlib import Path import fire def lowercase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str , lowerCAmelCase__ : int ): """simple docstring""" __UpperCAmelCase : List[str] = Path(lowerCAmelCase...
254
0
import argparse import os import re _UpperCamelCase = '''src/diffusers''' # Pattern that looks at the indentation in a line. _UpperCamelCase = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. _UpperCamelCase = re.compile(R'''^\s*"([...
335
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
1
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokenize...
97
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_...
102
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version UpperCAmelCase__ = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize UpperCAmelCase__ ...
356
def A ( _UpperCAmelCase : int ) -> "list[int]": '''simple docstring''' if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) _UpperCAmelCase = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 _UpperCAmelCase =...
290
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json""", # See all CANINE models at http...
59
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transfor...
59
1
"""simple docstring""" from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a__ ( SCREAMING_SNAKE_CASE : Dict[str, torch.Tensor] ): '''simple docstring''' lowerCAmelCase : st...
365
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class SCREAMING_SNAKE_CASE__ ( lowercase ...
133
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Any =logging.get_logger(__name__) __lowerCAmelCase : Tuple ={ 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://huggingface.co/microsoft/unispeech-sat-...
9
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __lowerCAmelCase : List[Any] =datasets.load_iris() __lowerCAmelCase : Tuple =np.array(data['data']) __lowerCAmelCase : Dict =np.array(data['target']) __lowerCAmelCase...
9
1
def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) -> Optional[int]: if height >= 1: move_tower(height - 1 , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) move_disk(SCREAMING_SNAKE_CASE__ , SCREAM...
293
import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...t...
293
1
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": SCREAMING_SNAKE_CASE : Dict = pd.read_csv("sample_data.csv", header=None) SCREAMING_...
21
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> bool: if len(lowerCamelCase_ ) < 2: raise ValueError('Monogons and Digons are not polygons in the Euclidean space' ) if any(i <= 0 for i in nums ): raise ValueError('All values must be greater tha...
21
1
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' def _lowercase ( self ): """simple docstring""" ...
229
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusion...
229
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowercase__ ( __snake_case : Tuple , __snake_case : Tuple=None ): '''simple docstring'''...
29
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : Any = { """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONFIG_ARCHIV...
95
0
import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants _UpperCamelCase = Mapping[str, np.ndarray] _UpperCamelCase = Mapping[str, Any] # Is a nested dict. _Up...
335
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
1
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 if is_speech_available(): from tra...
11
'''simple docstring''' from __future__ import annotations import queue class lowercase : """simple docstring""" def __init__( self ,a_ ) -> str: _UpperCAmelCase : Optional[Any] = data _UpperCAmelCase : Optional[int] = None ...
215
0
from collections import deque from .hash_table import HashTable class lowercase ( UpperCamelCase__ ): def __init__( self , *_a , **_a ) -> Optional[int]: super().__init__(*_a , **_a ) def a__ ( self , _a , _a ) ...
343
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
343
1
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 _A = logging.get_logger(__name__) _A = '▁' _A = {'vocab_fil...
62
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tra...
98
0
"""simple docstring""" import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_...
354
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ = { '''configuration_maskformer''': ['''MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MaskFormerConfig'''], '''c...
132
0
import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose, ) if is_flax_available(...
76
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES A_ : str = logging.get_logger(__name__) A_ : str = OrderedDict( [ ...
333
0
"""simple docstring""" def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase ) -> int: '''simple docstring''' while second != 0: lowercase : Any = first & second first ^= second lowercase : Any...
53
"""simple docstring""" from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils impo...
53
1
"""simple docstring""" def A ( snake_case :list , snake_case :list , snake_case :int ) -> int: if len(snake_case ) != len(snake_case ): raise ValueError('The length of profit and weight must be same.' ) if max_weight <= 0: raise ValueError('max_weight must gr...
316
"""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 git won't b...
316
1
snake_case_ : int = {str(digit): digit**5 for digit in range(10)} def A (__A : int ) -> int: """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(__A ) ) def A () -> int: ...
7
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __snake_case ( unittest.TestCase ): def lowerCamelCase ( self : Dict): """simple...
7
1
import os import jsonlines import numpy as np from tqdm import tqdm _UpperCamelCase = 2048 _UpperCamelCase = 4096 _UpperCamelCase = 42 _UpperCamelCase = os.environ.pop("PROCESS_TRAIN", "false") _UpperCamelCase = {"null": 0, "short": 1, "long": 2, "yes": 3, "no": 4} def _lowercase ( ...
275
def _lowercase ( lowercase__ = 2_0_0 ): __lowerCAmelCase : Union[str, Any] = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] __lowerCAmelCase : Dict = [0] * (pence + 1) __lowerCAmelCase : Optional[int] = 1 # base case: 1 way to make 0 pence ...
275
1
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _lowerCAmelCase ( lowerCamelCase_ : int ): __lowercase = int(number**0.5 ) return number == sq * sq def _lowerCAmelCas...
217
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { '''Intel/dpt-large''': '''https://huggingface....
217
1
import mpmath # for roots of unity import numpy as np class UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[int] , lowerCAmelCase_ : Any=None , lowerCAmelCase_ : str=None ): """simple docstring""" _A: Optional[int] ...
121
"""simple docstring""" import datasets from .evaluate import evaluate _UpperCAmelCase = """\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMN...
173
0
'''simple docstring''' import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def a_ ( __snake_case : List[str] ) -> Dict: """simple docstring""" monkeypatch.setattr('''datasets.utils.deprecation_utils._emitt...
6
'''simple docstring''' 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 a_ ( __snake_case ...
6
1
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor,...
162
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class A__ : lowercase = 42 lowercase = None lowercase = None def...
162
1
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers __UpperCAmelCase =[int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def __lowerCAmelCase ( ) -> Optional[Any]: __lowerCamelCase = os.path.dirname(os.path.realpath(UpperCamelCase__ ...
237
'''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 ={ "configuration_whisper": ["WHISPER_PRETRAINED_C...
237
1