code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCamelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class A ( UpperCamelCase_ ): def __in...
464
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = '▁' lowerCamelCase = {'vocab_file': 'pr...
464
1
'''simple docstring''' def _lowerCAmelCase ( lowercase : Optional[int] , lowercase : Optional[Any] ) ->Optional[Any]: """simple docstring""" if not (isinstance(lowercase , lowercase ) and isinstance(lowercase , lowercase )):...
717
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __A ( a ): """simple docstring""" A_ = '' A_ ...
318
0
"""simple docstring""" def _A( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): A__ : Union[str, Any] = len(lowerCAmelCase ) A__ : Tuple = [[0] * n for i in range(lowerCAmelCase )] for i in range(lowerCAmelCase ): ...
363
"""simple docstring""" import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __UpperCAmelCase (unittest.TestCase ): '''simple docstring''' def lowerCamelCase ( self ): ...
363
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Union[str, Any] = { '''configuratio...
711
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Optional[int] = logging.get_logger(__name__) __lowerCamelCase : Dict = {} class lowerCamelCase ( _lowerCamelCase ): '''simple docstring''' UpperCamelCase__ ...
501
0
"""simple docstring""" def lowercase ( lowerCAmelCase__ = 1_000_000 ): lowerCamelCase_ = set(range(3 ,lowerCAmelCase__ ,2 ) ) primes.add(2 ) for p in range(3 ,lowerCAmelCase__ ,2 ): if p not in primes: continue primes.difference_update(set(range(p * p...
29
'''simple docstring''' from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf ...
366
0
UpperCAmelCase_ = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : dict , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMIN...
664
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
664
1
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class SCREAMING_SNAKE_CASE__ : def __init__( self : List[Any] , lowerCAmelCase ...
169
'''simple docstring''' import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore lowerCAmelCase: Optional[int] = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" lowerCAmelCase: O...
526
0
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = log...
476
from ..utils import DummyObject, requires_backends class lowerCAmelCase ( metaclass=_a ): _SCREAMING_SNAKE_CASE : Optional[int] =["""transformers""", """torch""", """note_seq"""] def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ )...
476
1
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCas...
561
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING f...
561
1
'''simple docstring''' 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...
575
'''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 _SCREAMING_SNAKE_CASE : """simple docstring""" ...
575
1
"""simple docstring""" def A ( snake_case__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = [int(snake_case__ ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(snake_case__ ) == 4 and all(0 <= int(snake_case__ ) <= 2_5...
196
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig A_ : Union[str, Any] = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", ...
196
1
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequen...
705
'''simple docstring''' import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig fro...
305
0
'''simple docstring''' import re from filelock import FileLock try: import nltk lowerCamelCase_ = True except (ImportError, ModuleNotFoundError): lowerCamelCase_ = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def SCREAMING_SNAKE_CA...
418
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a__ ( __snake_case ): def __init__( self , UpperCAmelCase , UpperCAmelCase ) -> Tuple: super().__ini...
559
0
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils ...
713
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple reposi...
444
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: list ): """simple docstring""" _lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping _lowerCAmelCase = ...
580
"""simple docstring""" import math def __snake_case ( SCREAMING_SNAKE_CASE: float , SCREAMING_SNAKE_CASE: float ): """simple docstring""" if ( not isinstance(SCREAMING_SNAKE_CASE , (int, float) ) or power_facto...
580
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(DDIMParallelScheduler,) SCREAMING_SNAKE_CASE__ =(("""eta""", 0.0), ("""num_inference...
214
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _snake_case : Optional[int] = {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE...
214
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Any = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwri...
44
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Tuple = {"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""...
233
'''simple docstring''' import argparse import struct import unittest class __lowerCAmelCase: def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE : bytes ): """simple docstring""" SCREAMING_SNAKE_CASE_ :str = data # ...
233
1
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def lowercase__ ( ) -> Optional[Any]: """simple docstring""" UpperCAmelCa...
373
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split SCREAMING_SNAKE_CASE_ = datasets.load_iris() SCREAMING_SNAKE_CASE_ = np.array(data['''data''']) SCREAMING_SNAKE_CASE_ ...
373
1
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import P...
706
def _lowerCAmelCase ( __magic_name__ :int = 1_0_0 ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main__": ...
407
0
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Sessio...
104
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class _lowerCAmelCase ( __snake_case ): '''si...
585
0
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _SCREAMING_SNAKE_CASE (unittest.TestCase ): def lowerCAmelCase ( self : Any ) -> Any: """simple docstring""" s...
718
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def __UpperCAmelCase ( UpperCamelCase__ :Iterable[str] , UpperCamelCase__ :int ) -> Generator[tuple[str, ...], None, None]: snake_case__ : Union[str, Any] ...
574
0
import qiskit def _SCREAMING_SNAKE_CASE ( __snake_case = 2 ) -> qiskit.result.counts.Counts: _UpperCAmelCase = qubits # Using Aer's simulator _UpperCAmelCase = qiskit.Aer.get_backend("""aer_simulator""" ) # Creating a Quantum Circuit acting ...
108
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_col...
249
0
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optio...
527
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets a : Optional[int] = datasets.logging.get_logger(__name__) a : Tuple = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Text Generation}, author={Thibault Sellam and Di...
527
1
'''simple docstring''' def _UpperCamelCase (_lowerCamelCase : int )-> list: '''simple docstring''' if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence __snake_case = gray_code_seq...
24
import unittest import numpy as np import requests 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(): ...
298
0
from math import factorial, pi def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 30 ) -> float: if not isinstance(__SCREAMING_SNAKE_CASE , (int, float) ): raise ValueError("maclaurin_sin() requires either an int or float for theta" ) if not isinstance(__SCRE...
23
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 SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
1
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __lowerCAmelCase ( UpperCamelCase__): _lowe...
563
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput UpperCAmelCase : Tuple = """scheduler_config.json""" ...
563
1
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _lowerCamelCase ( lowercase : str , lowercase : complex , lowercase : str = "x" , lowercase : float = 10**-10 , lowercase ...
521
'''simple docstring''' def _lowerCamelCase ( lowercase : int , lowercase : int ) -> int: return 1 if input_a == input_a else 0 def _lowerCamelCase ( ) -> None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) =...
521
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 lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) lowerCAmelCase ...
214
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import ...
214
1
from ...configuration_utils import PretrainedConfig __lowerCAmelCase : Dict = { 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co/google/tapas...
662
def __magic_name__ ( A : int, A : int, A : int ): '''simple docstring''' if exponent == 1: return base if exponent % 2 == 0: a = _modexpt(A, exponent // 2, A ) % modulo_value return (x * x) % modulo_value else...
662
1
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC __lowercase = parse(importlib.metadata.version('''torch''')) def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_...
167
from string import ascii_uppercase __lowercase = {str(ord(c) - 55): c for c in ascii_uppercase} def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise T...
167
1
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase ) -> int: '''simple docstring''' if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): __SCREAMING_SNAKE_CASE = f"""Input value of [number={number}] must be an integer"...
13
'''simple docstring''' import requests from bsa import BeautifulSoup def __magic_name__ ( __UpperCAmelCase = "AAPL" ) -> str: '''simple docstring''' __SCREAMING_SNAKE_CASE = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" __SCREAMI...
13
1
from __future__ import annotations def lowerCAmelCase__ ( a__: Any , a__: Optional[int] ) -> List[Any]: '''simple docstring''' print(F'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(UpperCAmelCase__ ): prin...
618
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def SCREAMING_SNAKE_CASE ( ): """simple docstring""" _SCREAMING_SNAKE_CASE = HfArgumentParser(UpperCAmelCase__ ) _SCREAMING_SNAKE_CASE = parser.parse_args_into_dataclas...
605
0
"""simple docstring""" import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers....
482
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class __lowerCAmelCase : """simple docstring""" def __init__( self : int ) -> List[Any]: """simple docstring""" A_ = {} ...
482
1
"""simple docstring""" import math class lowercase : def __init__(self : Any ,SCREAMING_SNAKE_CASE_ : str=0 ) -> Dict: # a graph with Node 0,1,...,N-1 """simple docstring""" lowerCAmelCase = n lowerCAmelCase = [ [math.inf for j...
535
"""simple docstring""" UpperCAmelCase = 8.3_144_598 def __magic_name__ ( _lowerCamelCase: float, _lowerCamelCase: float ) -> float: '''simple docstring''' if temperature < 0: raise Exception('''Temperature cannot be less than 0 K''' ) if molar_mass <= 0: raise Exce...
535
1
"""simple docstring""" def _snake_case ( UpperCamelCase : List[Any] = "The quick brown fox jumps over the lazy dog" , ): UpperCAmelCase : Any = set() # Replace all the whitespace in our sentence UpperCAmelCase : str = input_str.replace(""" """ , """""" ) for alpha i...
707
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_m...
359
0
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase = 400_0000 ): lowercase__ : List[Any] = [0, 1] lowercase__ : Union[str, Any] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 lowercase__ : ...
152
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
152
1
from __future__ import annotations def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> int: # noqa: E741 """simple docstring""" while r - l > 1: _SCREAMING_SNAKE_CASE = (l + r) // 2 ...
704
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a (_lowerCamelCase): """simple docstring""" SCREAMING_SNAKE_CASE = ['image_processor', 'tokenizer'] SCREAMING_SNAKE_CASE ...
0
0
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transforme...
237
class __lowerCAmelCase : def __init__( self , lowerCAmelCase__ , lowerCAmelCase__=None , lowerCAmelCase__=None ) -> Any: '''simple docstring''' a__ : Dict =data a__ : str =previous ...
563
0
"""simple docstring""" import logging from transformers import PretrainedConfig lowercase__ :Any = logging.getLogger(__name__) lowercase__ :Optional[int] = { 'bertabs-finetuned-cnndm': 'https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-...
374
"""simple docstring""" import argparse import os 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_task_guides.py lowercase__ :int = 'sr...
374
1
'''simple docstring''' from __future__ import annotations lowerCAmelCase_ : Tuple = 1.6021E-19 # units = C def __A ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase ,) -> tuple[str, float]: '''simple docstring''' if (conductivity, electron_conc, mo...
435
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node UpperCamelCase__ = 4 UpperCamelCase__ = 3 class A ( UpperCAmelCas...
486
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __a : Tuple = {'configuration_v...
717
"""simple docstring""" import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, r...
200
0
"""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, is_stagin...
680
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weig...
217
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __A =logging.get_logger(__name__) __A ={ '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json''' ), # See all Vivit models at https:...
313
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_available(...
313
1
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from t...
3
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device f...
255
0
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor a_ :int = logging.get_logger(__name__) class snake_case__ ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Any, *_snake_case :...
243
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ :str = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBlipQFormerConfig", "Ins...
243
1
import unittest from knapsack import greedy_knapsack as kp class UpperCAmelCase__ ( unittest.TestCase ): """simple docstring""" def _UpperCAmelCase ( self: int ) -> Union[str, Any]: '''simple docstring''' __UpperCAmelCase = [10, 20, 3...
221
import os def lowerCAmelCase_ ( __A = "matrix.txt" ) -> int: '''simple docstring''' with open(os.path.join(os.path.dirname(__A ), __A ) ) as in_file: UpperCAmelCase__ = in_file.read() UpperCAmelCase__ = [[int(_...
486
0
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _lowerCAmelCase ( *UpperCamelCase__: Optional[int] , UpperCamelCase__: Optional[Union[Dict, Any]] = None , UpperCamelCase__: int=True , UpperCamelCase_...
712
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Any = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise OptionalDependencyNotA...
546
0
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ...
42
'''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 UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' ...
42
1
'''simple docstring''' def _lowerCAmelCase ( lowercase : int ) ->int: """simple docstring""" if not isinstance(lowercase , lowercase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: ...
318
'''simple docstring''' def _lowerCAmelCase ( lowercase : int ) ->int: """simple docstring""" if not isinstance(lowercase , lowercase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: ...
318
1
import operator def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase = False , lowerCamelCase = None ): __magic_name__ : Any =operator.lt if reverse else operator.gt __magic_name__ : Union[str, Any] =solution or [] if not arr:...
21
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _a : Optional[Any] = logging.get_logger(__name__) class UpperCamelCase_ ( __UpperCamelCase ): """simple docstring""" def __init__( self , *UpperCAmelCase...
479
0
import os import re import shutil import sys import tempfile import unittest import black UpperCAmelCase_ : Any = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies # noqa: E402 ...
443
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import Ge...
443
1
from __future__ import annotations def snake_case__ ( lowerCamelCase_ ): if not nums: return 0 A : Any = nums[0] A : Any = 0 for num in nums[1:]: A , A : Optional[int] = ...
542
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEA...
542
1
'''simple docstring''' import heapq def _lowerCAmelCase ( __snake_case : dict ) -> set[int]: __A : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be...
338
'''simple docstring''' import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab fro...
338
1
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__lowerCamelCase ) ) def lowerCAmelCase_ ( __lowerCamelCas...
81
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" if "cls_toke...
207
0
'''simple docstring''' from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class A ( a ): def __lt__( self , snake_case_ ) -> Optional[int]: return self[-1] < other[-1] ...
707
'''simple docstring''' class A : def __init__( self ) -> List[str]: _a = 0 _a = 0 _a = {} def __lowerCAmelCase ( self , snake_case_ ) -> int: if vertex not in self.adjacency: ...
691
0
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 load_image if is_torch_available():...
492
from graphs.minimum_spanning_tree_kruskal import kruskal def _lowercase ( ): __lowerCAmelCase : Optional[int] = 9 __lowerCAmelCase : Dict = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], ...
492
1
"""simple docstring""" import string import numpy def lowercase (snake_case__ : int , snake_case__ : int ) -> int: '''simple docstring''' return b if a == 0 else greatest_common_divisor(b % a , snake_case__ ) class SCREAMING_SNAKE_C...
529
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase (snake_case__ : dict , snake_case__ : str , snake_case__ : set , snake_case__ : set , snake_case__ : dict , snake_c...
529
1
import faiss # 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 requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 ...
67
"""simple docstring""" import argparse import gc import json import os 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 acc...
506
0
'''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 # # ...
287
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a= {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailab...
287
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
57
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 snake_case : Optional[Any] = logging.get_logger(__name__) ...
605
0
import gc import unittest from transformers import CTRLConfig, 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_modeling_common import ModelTes...
341
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _UpperCamelCase : str = { """configuration_bridgetower""": [ """BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BridgeTowerConfig""...
341
1
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 from transfor...
54
from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" if not postfix_notation: return 0 _SCREAMING_SNAKE_CASE = {'+', '-', '*', '/'} _SCREAMING_SNAKE_CASE = [] f...
605
0
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def lowerCAmelCase (__A , __A , __A , __A , __A , __A , __A , __A , __A , ): """simple docstring""" for nxt, d in graph[v]: ...
352
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py lowercase_ = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {BLEU: a...
352
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_ = {'vocab_file': 'sentencepiece.bpe.model'}...
417
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __lowercase ( lowerCamelCase : str ): UpperCamelCase_ : Any ...
417
1
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # 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 UpperCamelCase : Tuple = "." # In...
709
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : Tuple = logging.get_logger(__name__) UpperCamelCase : List[str] = { "snap-research/efficientformer-l1-300": ( "https://...
293
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : List[str] = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'Instruc...
575
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to...
575
1
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase_ = logging.get_logger(__name__) def UpperCamelCase( lowercase_ , lowercase_ ...
161
def UpperCamelCase( lowercase_ = 200 ) -> int: '''simple docstring''' snake_case_ = [1, 2, 5, 10, 20, 50, 100, 200] snake_case_ = [0] * (pence + 1) snake_case_ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(lowercase_ , pe...
161
1
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class UpperCAmelCase__ ( __snake_case , unittest.TestCase ): __snake_case : ...
206
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require...
206
1
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokenization_common...
585
from __future__ import annotations from random import choice def _a ( __SCREAMING_SNAKE_CASE : int ): """simple docstring""" return choice(__SCREAMING_SNAKE_CASE ) def _a ( __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : int ...
585
1
from __future__ import annotations def a ( A__ ) -> None: '''simple docstring''' create_state_space_tree(A__ , [] , 0 , [0 for i in range(len(A__ ) )] ) def a ( A__ , A__ , A__ , A__ , ) -> ...
35
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
288
0
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
668
"""simple docstring""" import argparse import json 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...
668
1
'''simple docstring''' def lowerCamelCase ( _snake_case : str ): '''simple docstring''' lowercase__ = [int(_snake_case ) for i in ip_va_address.split("." ) if i.isdigit()] return len(_snake_case ) == 4 and all(0 <= int(_sna...
267
'''simple docstring''' import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case (unittest.TestCase ): lowerCAmelCase__ :Dict = JukeboxTokenizer lowerCAmelCase__ :List[str] = { ...
267
1
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 from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils impo...
54
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...
54
1
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _lowerCamelCas...
674
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case : def __init__( self :Optional[Any] , _lowerCamelCase :int ): __SCREAMING_SNAKE_CASE : int = num_of_nodes __SCREAMING_SNAKE_CASE : list[lis...
674
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : Optional[Any] = logging.get_logger(__name__) _UpperCamelCase : List[Any] = { 'google/pix2struct-textcaps-base': ( 'https://huggingface....
715
'''simple docstring''' import numpy as np def __UpperCAmelCase ( A : np.ndarray , A : np.ndarray , A : float = 1e-12 , A : int = 1_0_0 , ) -> tuple[float, np.ndarray]: assert np.shape(A )[0] == np.shape(A )[1] # Ensure proper dimensionality. assert np...
216
0
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nes...
158
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _A = """https://www.indeed.co.in/jobs?q=mobile+app+development&l=""" def A_ ( __SCREAMING_SNAKE_CASE : str = "mumbai" ) -> Generator[t...
158
1
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common ...
715
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
293
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : int = { '''configuration_ctrl''': ['''CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CTRLConfig'''], '''tokenization_ctrl''': [...
56
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip ins...
172
0
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transforme...
721
'''simple docstring''' import numpy as np import qiskit def _snake_case ( A = 8 , A = None ) -> str: lowerCAmelCase__ = np.random.default_rng(seed=A ) # Roughly 25% of the qubits will contribute to the key. # So we take more than we need. ...
98
0
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host ...
663
from functools import lru_cache def _a ( SCREAMING_SNAKE_CASE__ : int ) -> set: '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] = 2 SCREAMING_SNAKE_CASE__ : Union[str, Any] = set() while i *...
663
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transforme...
168
"""simple docstring""" import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from...
168
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowercase : str = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xlm''': ['''X...
36
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase : Dict ={ 'configura...
206
0
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, C...
675
def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __UpperCAmelCase : Dict = str(bin(lowercase_ ) )[2:] # ...
675
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType lowerCAmel...
347
# 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 required by app...
454
0
'''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_commo...
385
'''simple docstring''' from __future__ import annotations class _lowerCAmelCase : """simple docstring""" def __init__( self , _lowerCamelCase ) -> Dict: A_ : List[Any] = TypeError( """Matrices must be formed from a list of zero or m...
385
1
from __future__ import annotations def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> list: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = input_list[low:mid], ...
100
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __magic_name__ ( snake_case ): UpperCamelCase_ :Dict = (KDPMaDiscreteScheduler,) UpperCamelCase_ ...
628
0
"""simple docstring""" snake_case = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_ ): SCREAMING_SNAKE_CASE = 0 while number: # Increased Speed Slightly by checking every 5 digits toge...
406
"""simple docstring""" import os import sys import unittest snake_case = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get...
406
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __a = logging.get_logger(__name__) __a = { 'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/...
30
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer __a = logging.get_logger(__name__) __a ...
30
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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_ver...
408
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Confi...
408
1
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any] , *l...
622
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( snake_case : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: """simple docstring""" a : Tuple = set() # Replace all the whitespace in our sentence a : Lis...
610
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase : Tuple = { """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_availab...
610
1
from __future__ import annotations from typing import Any class a ( __lowerCAmelCase ): """simple docstring""" pass class a : """simple docstring""" def __init__( self , lowerCAmelCase_ ) -> None:...
401
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration _SCREAMING_SNAKE_CASE = HfArgumentParser(InitializationArguments) _SCREAMING_SNAKE_CASE = parser.parse_args() # Load codeparrot tokenize...
401
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "facebook/s2t-wav2vec2-large-en-de": ( "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/...
471
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configurati...
471
1
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class __lowerCamelCase : """simple docstring""" def __init__( self : Tuple): _A : List[Any] = '' _A : str = ''...
128
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def lowerCAmelCase__ ( lowerCamelCase : Callable[[int | float], int | float] ,lowerCamelCase : int | float ,lowerCamelCase : int | float ,lowerCamelCase : int = 100 ,): ...
128
1
import math def _lowerCamelCase ( __A : int ) -> int: if not isinstance(__A , __A ): _UpperCAmelCase : List[Any] = f'''Input value of [number={number}] must be an integer''' raise TypeError(__A ) if number < 1: _Upper...
707
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.rou...
186
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase :Optional[Any] = logging.get_logger(__name__) lowerCAmelCase :Dict = { '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/re...
561
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate ...
561
1
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_camembert import Ca...
721
from __future__ import annotations def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" if b == 0: return (1, 0) ((__lowercase) , (__lowercase)) = extended_euclid(lowercase , a % b ) __lowercase = ...
522
0
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_c...
36
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _A ( pl.LightningModule ): '''simple docstring''' def __init__( self ,SCREAMING_SNAKE_CASE_ ): '''simple docstri...
36
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json f...
709
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
661
0