code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import 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 ...
352
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean _lowerCamelCase : List[str] = 0 _lowerCamelCase : Tuple = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0,...
352
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCAmelCase : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxConfig...
364
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] = { "configuration_ber...
364
1
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_t...
453
"""simple docstring""" def SCREAMING_SNAKE_CASE ( lowercase__ , lowercase__ ) -> list: lowerCAmelCase__ : List[str] = len(lowercase__ ) lowerCAmelCase__ : Dict = [] for i in range(len(lowercase__ ) - pat_len + 1 ): lowerCAmelCase__ : Union[str, Any] ...
453
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { """microsoft/cvt-13""": """https://huggingface.co/microsoft/cvt-13/resolve/main/config.json""", # See all Cvt models at https://huggingface...
720
'''simple docstring''' from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class a : """simple docstring""" def __init__( self , snake_case_ = None ): '''simple docstring''' if componen...
466
0
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_uti...
228
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class __a ( A__ ): _lowerCAmelCase : ...
228
1
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_staging_test class lowerC...
707
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __snake_case : Optional[int] =(3, 9, -1_1, 0, 7, 5, 1, -1) __snake_case : str =(4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class lowerCamelCase__ : '''simpl...
90
0
"""simple docstring""" from __future__ import annotations def snake_case_ ( A_ : float, A_ : float, A_ : float, ): '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot su...
83
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC SCREAMING_SNAKE_CASE :Union[str, Any] = parse(importlib.metadata.version('''torch''')) def _lowerCAmelCase ( lowerCAmelCase_ :Union...
283
0
'''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() lowerCa...
709
'''simple docstring''' from ..utils import DummyObject, requires_backends class _lowerCAmelCase ( metaclass=__A ): '''simple docstring''' snake_case_ = ['flax'] def __init__( self : List[Any] , *UpperCamelCase_ : str , **Upper...
411
0
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True lowercase = 4 lowercase = (1 << p) - 1 for _ in range(p - 2 ): lowercase = ((s * s) - 2) % m return s == 0 if __name__ ...
84
def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: A__ : Tuple =1 for i in range(1, num + 1 ): fact *= i return fact def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: A__ : Optional[Any] =0 while number >...
416
0
lowercase_: Optional[Any] = {str(digit): digit**5 for digit in range(10)} def _lowercase ( UpperCAmelCase_): """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_lowerCamelCase)) def _lowercase ( ): """simple docstring""" ...
716
def _lowercase ( UpperCAmelCase_): """simple docstring""" snake_case__ : Any = 1 snake_case__ : Dict = 2 while i * i <= n: snake_case__ : Dict = 0 while n % i == 0: n //= i multiplicity += 1 n_div...
127
0
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 GenerationTes...
35
'''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 ...
309
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
414
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __magic_name__ ( lowercase_ = "isbn/0140328726" ) -> dict: '''simple docstring''' UpperCamelCase = olid.strip().strip("/" ) # Remove le...
414
1
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils impor...
351
from abc import ABC, abstractmethod from argparse import ArgumentParser class snake_case_ ( __UpperCamelCase ): """simple docstring""" @staticmethod @abstractmethod def UpperCAmelCase__ (__UpperCAmelCase: ArgumentParser ) -> Tuple: ...
351
1
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowercase : '''simple docstring''' UpperCAmelCase : int UpperCAmelCase : int class lowercase : ''...
700
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils...
308
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase__ ={ "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig", "...
616
"""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 log...
616
1
'''simple docstring''' def __snake_case ( lowercase : float ): return 10 - x * x def __snake_case ( lowercase : float , lowercase : float ): # Bolzano theory in order to find if there is a root between a and b if equation(lower...
710
'''simple docstring''' from __future__ import annotations def __snake_case ( lowercase : list ): if len(lowercase ) == 0: return [] snake_case_ , snake_case_ = min(lowercase ), max(lowercase ) snake_case_ = int(max_value - min_value ...
420
0
def __A(lowerCAmelCase ) -> list[int]: """simple docstring""" _UpperCamelCase = len(lowerCAmelCase ) for i in range(lowerCAmelCase ): for j in range(i + 1 , lowerCAmelCase ): if numbers[j] < numbers[i]: _UpperCamelCase , _UpperCamelCase =...
612
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
612
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''facebook/xmod-ba...
624
'''simple docstring''' from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, rando...
624
1
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Config...
103
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase ( __UpperCamelCase : list[float] , __UpperCamelCase : Any ): '''simple docstring''' print(F'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(__UpperCamelCa...
719
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_ava...
21
0
'''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...
5
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_trans...
315
0
import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py a ="""src/transformers""" # This is to make sure the transformers module imported is the one in the r...
702
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a ={ """configuration_canine""": ["""CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CanineConfig"""], """tokenization_canine""": ["""CanineTokenizer"""], } ...
337
0
"""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 lowerCAmelCase ...
543
"""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__ ( snake_case__ ) -> Dict[str, torch.Tensor]: lowerCamelCase = [] lowerCamelCase = [...
543
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Dict = {'''configuration...
39
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase__ ( UpperCamelCase__ ): def __init__( self ) -> List[str]: # test for the above condition self.test() def UpperCAmelCase_ ( self ) ...
39
1
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __lowerCAmelCase ( nn.Module): '''simple docstring''' __magic_name__ : in...
656
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A : Any = { "configuration_efficientformer": [ "EFFICIENTFORMER_PRETRAINED_CONF...
656
1
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testin...
274
"""simple docstring""" def UpperCAmelCase__ ( ) -> int: """simple docstring""" return 1 def UpperCAmelCase__ ( A__ ) -> int: """simple docstring""" return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def UpperCAmelCase__ ( A__ ) -> ...
274
1
'''simple docstring''' import pytest lowerCAmelCase_ : Optional[Any] = """__dummy_dataset1__""" lowerCAmelCase_ : List[str] = """\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nU...
435
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-b...
695
0
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""" )
711
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDep...
87
0
'''simple docstring''' import numpy as np import qiskit def _a ( _lowerCamelCase = 8 , _lowerCamelCase = None ) -> str: """simple docstring""" __snake_case : Any = np.random.default_rng(seed=_lowerCamelCase ) ...
26
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingface...
514
0
"""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 ...
295
"""simple docstring""" from __future__ import annotations lowercase_ : List[str] = '''#''' class UpperCamelCase : def __init__( self ): """simple docstring""" _SCREAMING_SNAKE_CASE : dict = {} def __SCREAMING_SNAKE_CASE...
295
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase_ = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], } try: if not is_tor...
209
# 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 req...
279
0
from math import factorial def UpperCamelCase ( _a = 1_0_0 ) -> int: '''simple docstring''' return sum(map(_a , str(factorial(_a ) ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: ").strip())))
714
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor...
441
0
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger a_ = """<<<<<<< This should probably be modified because it mentions: """ a_ = """======= >>>>>>> """ a_ = ...
221
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCAmelCase__ : """simple docstring""" lowerCAmelCase__ : int lowerCAmelCase__ : TreeNode | None = None lowerCAmelCase__ : TreeNode | None ...
221
1
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowercase__( __UpperCamelCase: Optional[Any] ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = Fil...
714
'''simple docstring''' from __future__ import annotations import math def lowercase__( __UpperCamelCase: int ,__UpperCamelCase: int ,__UpperCamelCase: bool ,__UpperCamelCase: list[int] ,__UpperCamelCase: float ): """simple docstring""" ...
508
0
from collections.abc import Callable import numpy as np def lowerCamelCase_ ( lowerCAmelCase__ : Callable , lowerCAmelCase__ : float , lowerCAmelCase__ : float , lowerCAmelCase__ : float , lowerCAmelCase__ : float ) -> np.array: '''simple docstring''' A ...
106
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers ...
145
0
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ = 100 ): '''simple docstring''' __SCREAMING_SNAKE_CASE = n * (n + 1) * (2 * n + 1) / 6 __SCREAMING_SNAKE_CASE = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __...
715
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_visio...
553
0
def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> float: if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 * mass * abs(__snake_case ) * abs(__snake_case ) if __name__ == "__main__": import doctest docte...
108
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 ImageProcessingSavingTestMixin, pre...
108
1
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, Reques...
712
def _A ( __snake_case :int ) -> bool: """simple docstring""" if not isinstance(__snake_case , __snake_case ): raise ValueError("check_bouncy() accepts only integer arguments" ) __SCREAMING_SNAKE_CASE = str(__snake_case ) __SCRE...
214
0
"""simple docstring""" import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') UpperCAmelCase__ = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) UpperCAmelCase__ ...
224
def __lowerCAmelCase( _SCREAMING_SNAKE_CASE ) -> bool: """simple docstring""" if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError('check_bouncy() accepts only integer arguments' ) _A = str(_S...
27
0
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast A : List[str] = datasets.utils.logging.get_logger(__name__) @dataclass class _UpperCamelCase ( ...
717
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices A : Optional[int] = logging.get_logger(__name__) A : List[str] = { "goog...
282
0
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArguments
395
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.append(os.pa...
395
1
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto import TF_MOD...
682
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ = None ) -> None: if components is None: __U...
682
1
'''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 loa...
591
'''simple docstring''' class _a : """simple docstring""" def __init__( self , A__ ) -> List[Any]: # we need a list not a string, so do something to change the type _SCREAMING_SNAKE_CASE = arr.split(""",""" ) def Upp...
591
1
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if...
704
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { """s-JoL/Open-Llama-V1""": """https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json""", } class a ( A_...
173
0
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('3.8'): import importlib_metadata else: import importlib.metadata as importlib_metadata SCREA...
34
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class snake_case_ ( lowerCamelCase_ ): """simple docstring""" def __init__( se...
34
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils...
554
"""simple docstring""" from __future__ import annotations def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ = None ): A__ = word_bank or [] # create a table A__ = len(lowerCAmelCase__ ) + 1 A__ = ...
554
1
'''simple docstring''' from math import sqrt def _UpperCAmelCase ( __A : List[Any] ): a_ : List[str] = 0 for i in range(1 , int(sqrt(lowerCAmelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCAmelCase_ ): total +=...
466
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_ut...
310
0
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from ...
603
'''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_channel_d...
603
1
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _lowercase ( UpperCamelCase_ , Upper...
472
import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __versi...
472
1
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def A(__a: str = "" ): lowerCAmelCase_ = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" lowerCAmelCase_ = BeautifulSoup(requests.get(__a ).text , "html.parser" ) lo...
719
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_staging_test class __magi...
226
0
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from tra...
55
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 @require_tokenizers ...
55
1
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _SCREAMING_SNAKE_CASE = logging.getLogger(__name__) @datac...
557
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "feature_extraction_en...
557
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'fac...
61
'''simple docstring''' import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must...
244
0
'''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()...
711
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": UpperCAmelCase = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHead...
344
0
'''simple docstring''' a : Union[str, Any] = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.g...
640
'''simple docstring''' from __future__ import annotations def _a (lowercase__ : int , lowercase__ : int ) -> list[str]: """simple docstring""" if partitions <= 0: raise ValueError('partitions must be a positive number!' ) if partitions > number...
56
0
"""simple docstring""" from statistics import mean import numpy as np def A__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' _SCREAMING_SNAKE_CASE = 0 # Number of...
706
"""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
0
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class UpperCamelCase__ : '''simple docstring''' lowerCamelCase_ : Optional[Any] = 4_...
311
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _SCREAMING_SNAKE_CASE = """\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic...
537
0
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CASE :int ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) __lowerCAmelCase : List[Any] = str(bin(SCREAMING_SNAKE_CASE ) )[2:] # remove the le...
240
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :str , SCREAMING_SNAKE_CASE :str ) -> str: if not (isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) and isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )): raise ValueError("""longest_common_substrin...
240
1
from __future__ import annotations from random import choice def A__ ( __A : str ) ->int: return choice(__lowerCAmelCase ) def A__ ( __A : Optional[int] , __A : Union[str, Any] ) ->int: __A =random_pivot(__lowerCAmelCase ) ...
184
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : str = logging.get_logger(__name__) __lowerCAmelCase ...
509
0
'''simple docstring''' from __future__ import annotations from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , __lowercase : str = 6 ) -> Union[str, Any]: SCREAMING_SNAKE_CASE__ : Tupl...
707
'''simple docstring''' from __future__ import annotations from collections.abc import Callable a_ = list[list[float | int]] def _a( UpperCamelCase__ : Matrix, UpperCamelCase__ : Matrix ): '''simple docstring''' SCREAMING_SNAKE...
665
0
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : List[str] = logging.get_logger(__name__) __magic_name__ : Tuple = { 'facebook/enco...
281
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class __snake_case (lowerCamel...
281
1
"""simple docstring""" from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _a : Union[str, Any] = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw ...
713
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
663
0
"""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_deter...
82
'''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 from packaging import version fr...
119
0
import pytest lowerCamelCase :List[Any] = '__dummy_dataset1__' lowerCamelCase :List[Any] = '\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/"\nURLS = {"train": REPO_URL + "wikiann-bn-train.jsonl", "vali...
346
from collections.abc import Generator from math import sin def __snake_case ( _UpperCamelCase ) -> bytes: if len(_UpperCamelCase ) != 32: raise ValueError('''Input must be of length 32''' ) _a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * i : 8 * ...
346
1
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoMo...
252
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...uti...
252
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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( B...
720
'''simple docstring''' import sys __snake_case = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''6689...
280
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __snake_case = {'''UserAgent''': UserAgent().random} def _A ( _lowercase ) -> dict: """simple docstring""" __UpperCame...
1
'''simple docstring''' from __future__ import annotations __UpperCAmelCase = list[list[int]] # assigning initial values to the grid __UpperCAmelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0...
90
0
from __future__ import annotations from math import pow, sqrt def a__ ( _UpperCamelCase : float ,_UpperCamelCase : float ,_UpperCamelCase : float ): if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if re...
622
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device a_ = False class __lowerCAmelCase ( unittest.TestCase ): pass @nightly @re...
622
1
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def a__ ( A__, A__=(), A__=None, A__="no", A__="29500" ): SCREAMING_SNAKE_CASE_ ...
101
"""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_funnel import FunnelTokenizer __SCREAMING_SNAKE_CASE = logging.get_logger(__n...
357
0
'''simple docstring''' def __UpperCAmelCase ( UpperCamelCase__ :int , UpperCamelCase__ :int ) -> str: if not isinstance(UpperCamelCase__ , UpperCamelCase__ ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(Up...
574
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE (lowercase__ ): A__ = 'ClapFeatureExtractor' A__ = ('RobertaTokenizer', 'RobertaTokenizerFast') def _...
574
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _lowerCamelCase( ...
230
import os import sys import unittest lowerCAmelCase = 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_model_to_test_mapping, ...
230
1
from collections import defaultdict def __lowerCamelCase ( A__ : str , A__ : str ) -> bool: lowerCamelCase_ : str = first_str.lower().strip() lowerCamelCase_ : Union[str, Any] = second_str.lower().strip() # Remove whitespace lowerCamelCase_ : List[Any] ...
171
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class SCREAMING_SNAKE_CASE_ (a__ ): ...
171
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Any = logging.get_logger(__name__) _A : Any = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class ...
427
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 ena...
121
0
"""simple docstring""" import os _UpperCamelCase : Dict = {'I': 1, 'V': 5, 'X': 1_0, 'L': 5_0, 'C': 1_0_0, 'D': 5_0_0, 'M': 1_0_0_0} def _SCREAMING_SNAKE_CASE ( __snake_case : str ): '''simple docstring''' lowercase = 0 lowercase = 0 while i...
134
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils...
134
1
import warnings from functools import wraps from typing import Callable def __snake_case ( _lowerCAmelCase : List[str] ) -> int: @wraps(_lowercase ) def _inner_fn(*_lowerCAmelCase : List[str] , **_lowerCAmelCase : Dict ): warnings.warn( (f...
454
'''simple docstring''' from __future__ import annotations import numpy as np def _lowerCAmelCase (_lowercase ): """simple docstring""" return np.maximum(0 , _lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, ...
331
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = {'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']} try: if not is_torch_available(): rai...
665
'''simple docstring''' from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from...
665
1
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.testing...
271
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( lowercase: str = "" ) -> dict[str, float]: '''simple docstring''' _UpperCamelCase: Tuple = url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250''' _UpperCame...
271
1
'''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 tr...
384
'''simple docstring''' def _UpperCamelCase ( __UpperCamelCase = 1 ,__UpperCamelCase = 10_00 ) -> int: lowerCamelCase_ = 1 lowerCamelCase_ = 0 for divide_by_number in range(__UpperCamelCase ,digit + 1 ): lowerCamelCase_ = [] ...
384
1
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
439
# 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 applica...
439
1
"""simple docstring""" import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter lowerCamelCase_...
717
"""simple docstring""" class UpperCamelCase_ : def __init__( self : List[str] , lowerCAmelCase_ : int , lowerCAmelCase_ : int=None , lowerCAmelCase_ : List[Any]=None ) -> int: UpperCAmelCase_ : int = data UpperCAmelCase_ : Opt...
463
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependency...
67
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ ( unittest.TestCas...
67
1
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase ) -> str: '''simple docstring''' _lowerCamelCase : str = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def ...
386
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
386
1
'''simple docstring''' from functools import reduce __lowerCAmelCase = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443...
358
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __l...
358
1
"""simple docstring""" from __future__ import annotations def lowercase (_lowerCAmelCase ): __lowerCAmelCase = str(_lowerCAmelCase ) return len(_lowerCAmelCase ) == 9 and set(_lowerCAmelCase ) == set("""123456789""" ) def lowercase (): for base_num in range(9999 ...
720
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_t...
573
0
# Algorithm for the pigeonhole sorting def a_ ( lowerCAmelCase_ : Optional[Any] ): __lowerCAmelCase = min(lowerCAmelCase_ ) # min() finds the minimum value __lowerCAmelCase = max(lowerCAmelCase_ ) # max() finds the maximum value __lowerCA...
53
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : str = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Tim...
244
0
def lowerCamelCase_ ( A : int , A : int ): """simple docstring""" lowerCAmelCase_ = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): lowerCAmelCase_ = n - k # Calculate C(n,k) for i in range(A ): ...
413
from __future__ import annotations from collections.abc import Iterator class UpperCamelCase_ : '''simple docstring''' def __init__( self , _UpperCAmelCase): lowerCAmelCase_ = value lowerCAmelCase_ = None lowerCAme...
413
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int | float | str ) -> tuple[int, int]: """simple docstring""" try: UpperCAmelCase_ : int = float(_SCREAMING_SNAKE_CASE ) except ValueError: raise ValueError("Please enter a valid numbe...
71
'''simple docstring''' from statistics import mean, stdev def a__ ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : int = 3 ) -> list: """simple docstring""" UpperCAmelCase_ : Dict = min(_SCREAMING_SNAKE_CASE ) UpperCAmelCase...
71
1
"""simple docstring""" import os from pathlib import Path def lowerCamelCase ( ) -> Tuple: '''simple docstring''' from torch.utils.cpp_extension import load __UpperCAmelCase : int = Path(_UpperCamelCase ).resolve().parent.parent.parent / """kernels""" / """deform...
703
"""simple docstring""" import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbon...
299
0
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def UpperCAmelCase ( a__ = 1_00_00_00 , a__ = 10 ): '''simple docstring''' lowerCAmelCase :defaultdict = defaultdict(a__ ) for outer_width in range(3 , ...
553
"""simple docstring""" import math def UpperCAmelCase ( a__ , a__ ): '''simple docstring''' if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(a__ ) else: if x == 0: ...
553
1
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __UpperCamelCase : Optional[int] = {'UserAgent': UserAgent().random} def A ( _lowercase ): SCREAMING_SNAKE_CASE : List[str] ...
721
from __future__ import annotations from typing import Any class lowercase__ ( UpperCamelCase_): pass class lowercase__ : def __init__( self : Union[str, Any] , UpperCamelCase__ : Any ): '''simple docstring''' ...
34
0
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __a(SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : Optional[str] = None ): ''...
18
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a : Optional[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else...
479
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCondi...
718
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers ...
353
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : int = { """configuration_jukebox""": [ """JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """JukeboxConfig""", """JukeboxPriorConfig...
295
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase = 200 ) -> int: lowerCamelCase__ : Dict = [1, 2, 5, 10, 20, 50, 100, 200] lowerCamelCase__ : Union[str, Any] = [0] * (pence + 1) lowerCamelCase__ : List[str] = 1 # base case: 1 way to make 0 ...
295
1
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @mayb...
721
def _SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> bool: _UpperCAmelCase = len(snake_case ) + 1 _UpperCAmelCase = len(snake_case ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i o...
175
0
'''simple docstring''' import random class _UpperCAmelCase : """simple docstring""" @staticmethod def _lowerCAmelCase ( lowerCAmelCase_ ): '''simple docstring''' a_ : int = [ord(snake_case__ ) for i in text] a_ : Optional[int]...
577
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def UpperCamelCase ( __lowe...
204
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_...
37
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase_ = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MA...
37
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_squeezebert import SqueezeBertTokenizer lowerCamelCase_ = l...
498
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 : Dict = logging.get_logger(__name__) def UpperCamelCase_ ( __a ) -> Union[str, Any]: a__ : Tuple ...
37
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.utils impo...
709
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask A : Any = logging.getLogger(__name__) class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): """simple docstring""" def ...
356
0
'''simple docstring''' 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_conf...
539
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import Aut...
539
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch ...
716
"""simple docstring""" def __lowercase ( a : str , a : str ) -> str: __snake_case : int =len(a ) __snake_case : int =len(a ) __snake_case : int =( first_str_length if first_str_length > second_str_length else sec...
497
0