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
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_...
120
'''simple docstring''' import mpmath # for roots of unity import numpy as np class a : '''simple docstring''' def __init__( self , lowerCamelCase_=None , lowerCamelCase_=None ) -> Tuple: # Input as list _a : Optional[int] = list(poly_a or [0] ...
120
1
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def _lowerCamelCase ( __A : bool = True , *__A : List[Any] , **__A : Tuple ) -> Optional[int]: if not is_...
186
from __future__ import annotations def _lowerCamelCase ( __A : int ) -> list[int]: _UpperCAmelCase : List[str] = [True] * limit _UpperCAmelCase : Optional[int] = False _UpperCAmelCase : Dict = False _UpperCAmel...
186
1
from collections import Counter from timeit import timeit def __A ( _lowercase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def __A ( _lowercase = "" ): ...
484
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def __A ( _lowercase ): '''simple docstring''' ...
484
1
"""simple docstring""" import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules ...
635
"""simple docstring""" from __future__ import annotations def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , )-> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("""You cannot supply more o...
635
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnn...
79
'''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() ...
292
0
"""simple docstring""" from math import sqrt def lowercase__(A = 1_000_000 ) ->int: """simple docstring""" lowercase__ : int= 0 lowercase__ : int= 0 lowercase__ : int while num_cuboids <= limit: ...
85
"""simple docstring""" from ....utils import logging a : List[str] = logging.get_logger(__name__) class __UpperCAmelCase( SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self , snake_case__ , ...
85
1
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ ...
470
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_V...
470
1
"""simple docstring""" import enum import shutil import sys __lowerCamelCase , __lowerCamelCase = shutil.get_terminal_size() __lowerCamelCase = {"UP": "A", "DOWN": "B", "RIGHT": "C", "LEFT": "D"} class _lowercase ( enum.Enum ): _lowerCamelCase = ...
712
"""simple docstring""" import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _lowercase ( __UpperCAmelCase ): _lowerCamelCase = (EulerDiscreteScheduler,) _lowerCamelCase ...
190
0
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping lowerCAmelCase__ : int = tuple[int, int] class a : """simple docstring""" def __init__( self : Any , snake_case_ : set[int] ...
347
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class a : """simple docstring""" def __init__( self : Optional[Any] , snake_case_ : List[str]=2 ...
347
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_log...
710
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SqueezeBertConfig""", """Squ...
582
0
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 = 'scheduler_config.json' class _A ( UpperCAmelCas...
269
def __lowerCamelCase ( __lowerCAmelCase : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __UpperCamelCase : List[str] = sorted(string.lower() ) return ...
269
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCamelCase : Union[str, A...
720
'''simple docstring''' def __lowerCamelCase ( A__ , A__ ) -> int: """simple docstring""" while a != 0: UpperCamelCase , UpperCamelCase = b % a, a return b def __lowerCamelCase ( A__ , A__ ...
324
0
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention...
263
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transforme...
633
0
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version SCREAMING_SNAKE_CASE_:Tuple = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, """>""": operator....
520
from __future__ import annotations import math def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> float: """simple docstring""" A : str = u for i in range(1 , _lowerCAmelCase ): A : str = temp * (u - i) return temp def ...
520
1
import os from pathlib import Path def UpperCamelCase__ ( ): from torch.utils.cpp_extension import load lowercase = Path(a__ ).resolve().parent.parent.parent / """kernels""" / """deformable_detr""" lowercase = [ root / filename for filename in [ ...
428
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) class UpperCAmelCase_ ( _lowercase): snake_case__ = '''encoder-decoder''' snake_case__ = True d...
420
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _lowerCamelCase ( unittest.TestCase ): ...
507
"""simple docstring""" import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class _lowerCame...
507
1
'''simple docstring''' from __future__ import annotations def a__ ( lowerCAmelCase__ ) -> list[int]: # This function is recursive UpperCAmelCase__ : Union[str, Any] = len(UpperCamelCase_ ) # If the array contains only one element, we return it (it's t...
75
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 class...
339
0
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
337
from ...configuration_utils import PretrainedConfig from ...utils import logging a =logging.get_logger(__name__) a ={ """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""", # See all BioGPT models at https://huggingface.co/models?filter=biogpt } ...
337
1
import os import numpy import onnx def __lowerCAmelCase( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Optional[int]: """simple docstring""" _A = a.name _A = b.name _A = '' _A = ...
27
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor...
27
1
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelCase ( A__ ): UpperCamelCase__ ...
526
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 # # Unl...
526
1
import os import string import sys __A : Optional[Any] = 1 << 8 __A : List[str] = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, "left"...
27
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be c...
27
1
def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): return [sentence[i : i + ngram_size] for i in range(len(lowerCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
367
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask fro...
367
1
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvisio...
88
# 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...
60
0
"""simple docstring""" from collections import defaultdict class SCREAMING_SNAKE_CASE_ : """simple docstring""" def __init__( self :Optional[int] , __lowercase :str , __lowercase :Dict ): __lowerCamelCase : Dict =to...
363
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, requir...
363
1
"""simple docstring""" import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_fla...
76
'''simple docstring''' import numpy as np def lowercase__ ( __UpperCamelCase : np.array ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
566
0
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_lis...
705
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils imp...
474
0
"""simple docstring""" import os from math import logaa def _lowercase ( __lowerCAmelCase = "base_exp.txt" ) -> int: SCREAMING_SNAKE_CASE__ : float = 0 SCREAMING_SNAKE_CASE__ : Tuple = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(...
680
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available a :str = { "configuration_ernie": ["ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ErnieConfig", "ErnieOnnxConfig"], } try: if not ...
680
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class __SCREAMING_SNAKE_CASE ( metaclass=lowercase__ ): UpperCAmelCase : Union[str, Any] = ["""transformers""", """torch""", """note_seq"""] def __init__( self :List[str] ,*__UpperCAmelC...
715
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequence...
121
0
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate depre...
488
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models.b...
488
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 lowerCAmelCa...
54
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { "configuration_efficientformer": [ "EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
54
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A = logging.get_logger(__name__) _A = {...
159
"""simple docstring""" import math def SCREAMING_SNAKE_CASE ( __UpperCAmelCase ) -> bool: SCREAMING_SNAKE_CASE__ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(__UpperCAmelCase ) def SCREAMIN...
159
1
def lowerCAmelCase_ ( A_): UpperCamelCase__: Dict = len(_snake_case) UpperCamelCase__: Optional[int] = len(matrix[0]) UpperCamelCase__: Optional[int] = min(_snake_case ,_snake_case) for row in range(_snake_case): # Check ...
708
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig A__: Union[str, Any] = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''', '''albert-lar...
221
0
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def lowerCAmelCas...
635
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, req...
635
1
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, ...
680
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = False __SCREAMING_SNAKE_CASE = ...
680
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available UpperCAmelCase = { '''configuration_ernie''': ['''ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieConfig''', '''ErnieOnnxConfig'''], } try: if not is_to...
84
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _snake_case ( lowerCAmelCase : Lis...
216
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokeniza...
78
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _a = { """configuration_perceiver""": ["""PERCEIVER_PRETRAINED_...
78
1
'''simple docstring''' from statistics import mean import numpy as np def UpperCAmelCase_ ( __lowerCamelCase : list ,__lowerCamelCase : list ,__lowerCamelCase : list ,__lowerCamelCase : int ): lowercase_ :Optional[Any] = 0 # Numb...
172
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class a_ ( _lowerCAmelCase ): def lowercase__ ( self : Tuple , lowercase : float )...
172
1
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureEx...
714
"""simple docstring""" from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) ...
137
0
'''simple docstring''' from math import sqrt def A__ ( __lowerCAmelCase : int = 100_0000 ): lowerCamelCase__ = 0 lowerCamelCase__ = 0 lowerCamelCase__ = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_s...
50
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @r...
279
0
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch lowerCAmelCase = """sshleifer/bart-tiny-random""" lowerCAme...
706
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase = """https://www.indeed.co.in/jobs?q=mobile+app+development&l=""" def __SCREAMING_SNAKE_CASE ( lowercase_ = "mumbai" ) -> Generator[tuple[str, ...
675
0
def a (lowerCAmelCase__ ): __a = [] if len(lowerCAmelCase__ ) == 1: return [nums.copy()] for _ in range(len(lowerCAmelCase__ ) ): __a = nums.pop(0 ) __a = permute(lowerCAmelCase__ ) for perm in permutations: perm.append(lowerCAmelCase...
99
"""simple docstring""" import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.p...
602
0
import os import pytest from attr import dataclass _A : Any = 'us-east-1' # defaults region @dataclass class __SCREAMING_SNAKE_CASE : _UpperCAmelCase : str _UpperCAmelCase : Any = "arn:aws:iam::558105141721:role/sagemaker_execution_role"...
130
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer ...
130
1
'''simple docstring''' from __future__ import annotations def __snake_case ( SCREAMING_SNAKE_CASE_ : list[float] ) -> float: """simple docstring""" UpperCAmelCase = 0.00 UpperCAmelCase = 0 for resistor in resistors: if resistor <= 0: ...
51
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : Li...
49
0
'''simple docstring''' import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from tran...
461
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class lowercase ( __lowerCamelCase ): def __init__( self : str , __lowerCAmelCase : Callab...
461
1
"""simple docstring""" from collections.abc import Sequence def lowerCamelCase (a_ :Sequence[float] , a_ :float) -> float: return sum(c * (x**i) for i, c in enumerate(a_)) def lowerCamelCase (a_ :Sequence[float] , a_ :float) -> float: ...
677
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def lowerCamelCase (a_ :int)...
677
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import...
252
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pip...
252
1
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __a = (7_2_0, 1_2_8_0) # Height, Width __a = (0.4, 0.6) # if height or width lower than this scale, drop it. __a = 1 / 1_0_0 __a = '' __a ...
97
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json', # See al...
97
1
lowerCamelCase_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def UpperCAmelCase_ ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ ...
588
import math def UpperCAmelCase_ ( __UpperCamelCase ): SCREAMING_SNAKE_CASE__ =[] SCREAMING_SNAKE_CASE__ =2 SCREAMING_SNAKE_CASE__ =int(math.sqrt(__UpperCamelCase ) ) # Size of every segment SCREAMING_SNAKE_CASE__ =[True] * (end + 1) SCREAMI...
588
1
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, l...
20
'''simple docstring''' def snake_case__ ( UpperCamelCase ) -> list: _UpperCamelCase : Any = False while is_sorted is False: # Until all the indices are traversed keep looping _UpperCamelCase : List[str] = True for i in range(0 ,len(UpperCamelCase ...
683
0
def SCREAMING_SNAKE_CASE_ ( __A : list , __A : int = 0 ) -> list: """simple docstring""" a_ : Tuple = length or len(__A ) a_ : Union[str, Any] = False for i in range(length - 1 ): if li...
443
UpperCAmelCase_ : Optional[int] = '\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.git\n' UpperCA...
443
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowerCAmelCase_ = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noq...
60
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all file...
123
0
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __lowercase (__lowerCamelCase ): _lowerCamelCase = '''''' _lowerCam...
6
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowerCAmelCase__ = 3 def __UpperCAmelCase ( lowerCamelCase_) -> int: print('Generating primitive root o...
6
1
"""simple docstring""" import baseaa def snake_case ( lowerCAmelCase_ ) -> bytes: return baseaa.baaencode(string.encode('''utf-8''' ) ) def snake_case ( lowerCAmelCase_ ) -> str: return baseaa.baadecode(lowerCAmelCase_ ).decode('''utf-8''' ) if...
103
'''simple docstring''' def A__ ( UpperCAmelCase_ = 1_0_0_0 ): _UpperCamelCase : List[str] = 3 _UpperCamelCase : Any = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: ...
195
0
"""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 Tokenize...
255
"""simple docstring""" UpperCAmelCase =256 # Modulus to hash a string UpperCAmelCase =1_000_003 def _A ( _a : str , _a : str ): """simple docstring""" A = len(_a ) A = len(_a ) if p...
255
1
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ )-> Union[str, Any]: """simple docstring""" if len(SCREAMING_SNAKE_CASE_ ) != len(SCREAMING_SNAKE_CASE_ ): raise ValueError("The length of profit and weight...
628
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertS...
574
0
'''simple docstring''' import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py A : Tuple = """src/transformer...
163
'''simple docstring''' def snake_case_ ( a__ : int ): """simple docstring""" if bit_count < 0: raise ValueError("""The given input must be positive""" ) # get the generated string sequence __lowercase = gray_code_sequence_string(...
163
1
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRobertaT...
216
from __future__ import annotations def _snake_case ( lowerCAmelCase : int | float | str , lowerCAmelCase : int | float | str ): """simple docstring""" if nth_term == "": return [""] SCREAMING_SNAKE_CASE_ : Tuple = int(lowerCAmelCase ) SCREAMING_S...
216
1
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def A_ ( _lowerCAmelCase : Optional[Any] , _lowerCAmelCase : List[str] , _...
708
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A_ ( _lowerCAmelCase : Union[str, Any] ): """simple docstring""" if "img_encoder.pos_embed" in name: ...
11
0
from sklearn.metrics import fa_score import datasets __a = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' __a = '\nArgs:\n predictions (`list` of `int`): Predicted labe...
97
from __future__ import annotations def a ( snake_case__: Optional[int] , snake_case__: Optional[int] , snake_case__: Any , snake_case__: Optional[int] ): # noqa: E741 '''simple docstring''' while r - l > 1: lowercase_ = (l + r) // 2 if v[m] >=...
97
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A ={ '''configuration_clap''': [ '''CLAP_PRETRAINED_MODEL_ARCHIVE_LIST''', '''ClapAudioConfig''', '''ClapConfi...
706
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 AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import ...
241
0
"""simple docstring""" # DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.confi...
299
"""simple docstring""" from __future__ import annotations import queue class _lowerCamelCase : def __init__( self : Optional[int] , UpperCamelCase : List[Any] ) -> List[str]: """simple docstring""" lowerCAmelCase__ : Union[str, A...
299
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _SCREAMING_SNAKE_CASE = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa ...
703
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( __a , __a ): # Load...
534
0
from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=A_ ): '''simple docstring''' UpperCAmelCase_ = ['''torch'''] def __init__( self : Union[str, Any] , *UpperCamelCase : List[Any] , **UpperCamelCase : ...
322
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from data...
322
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( snake_case): if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''') for cell_n in range(1, len(grid[0])): grid[0][cell_n] += grid[0][cell_n - 1] __snak...
93
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowercase : Dict = { "configuration_vision_text_dual_encoder": ["Visi...
93
1
'''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_configuration_com...
270
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy A_ = logging.get_logger(__name__) ...
270
1
from __future__ import annotations def lowerCAmelCase_ ( lowercase: Union[str, Any] ) -> list[int]: # This function is recursive '''simple docstring''' _UpperCamelCase: int = len(lowercase ) # If the array contains only one element, we return it (it's the stop condition...
719
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def lowerCAmelCase_ ( lowercase: Optional[Any] ...
264
0
'''simple docstring''' from typing import Dict, Iterable, 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, re...
536
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __SCREAMING_SNAKE_CASE (__A ): """simple docstring""" _a : List[Any] = ['''image_processor''', '''tokenizer'''] _a : L...
536
1
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_p...
701
'''simple docstring''' import argparse _lowercase : Optional[int] = "docs/source/_static/js/custom.js" def lowerCamelCase ( UpperCAmelCase__ : Tuple ) -> Dict: with open(UpperCAmelCase__ , encoding="""utf-8""" , newline="""\n""" ) as f: lower...
30
0
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_torch_available(): im...
64
'''simple docstring''' import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowercase__ =argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type...
263
0
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ ): ...
693
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase : int ={ 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', ...
693
1
"""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 Session, Trai...
65
'''simple docstring''' import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase_ ( A ): '''simple docstring''' _a : Dict = args.pruning_method _a : Optional[Any] ...
120
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_ ( UpperCAmelCase__ ): def __lt__( self : Optional[Any] , __lowerCAmelCase : List[Any] ): retu...
427
'''simple docstring''' import argparse import copy def lowerCamelCase__ ( a ): __snake_case = {} with open(a ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __snake_case = [] ...
427
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCamelCase ( lowercase__ : int = 3 ) -> qiskit.result.counts.Counts: '''simple docstring''' if isinstance(lowercase__ , lo...
600
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def __UpperCamelCase ( lowercase...
600
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase = { '''configuration_graphormer''': ['''GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GraphormerConfig'''], } try: if not is_torch_avai...
709
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_common ...
102
0
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __lowerCAmelCase = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ "text-classif...
684
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.uti...
684
1
"""simple docstring""" import numpy as np def lowerCAmelCase_( lowercase_ : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) def lowerCAmelCase_( lowercase_ : np.array ) -> np.array: return vector * sigmoid(1.7_0_2 * vector ...
711
"""simple docstring""" import numpy as np def lowerCAmelCase_( lowercase_ : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) def lowerCAmelCase_( lowercase_ : np.array ) -> np.array: return vector * sigmoid(1.7_0_2 * vector ...
623
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_tf clas...
464
import numpy as np def a_ ( SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : float ): '''simple docstring''' return np.where(vector > 0 , SCREAMING_SNAKE_CASE__ , (alpha * (np.exp(SCREAMING_SNAKE_CASE__ ) - 1)) ) if __name__ == "__main...
464
1
import torch from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer from .base import PipelineTool class __a ( __a ): """simple docstring""" _A : int = "facebook/bart-large-mnli" _A : Optional[Any] = ( ...
719
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import Huggin...
588
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Tuple = { "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/...
89
def UpperCamelCase_( lowerCamelCase_ ) -> int: if n == 1 or not isinstance(lowerCamelCase_ , lowerCamelCase_ ): return 0 elif n == 2: return 1 else: _lowercase : List[str] = [0, 1] for i in range(2 , n + 1 ): ...
89
1
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.num...
710
"""simple docstring""" import colorsys from PIL import Image # type: ignore def _lowerCAmelCase ( __lowerCamelCase:float , __lowerCamelCase:float , __lowerCamelCase:int ): '''simple docstring''' __magic_name__ = x __magic_n...
468
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer UpperCamelCase__ : List[Any] = logging.get_logger(__name__) ...
105
"""simple docstring""" import argparse import struct import unittest class a : def __init__( self : List[str] , lowerCAmelCase : bytes ) -> None: '''simple docstring''' SCREAMING_SNAKE_CASE_: Tuple =data # Initia...
409
0
"""simple docstring""" from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'nielsr/canine-s': 2048, } # Unicode defines 1,114,112 total “code...
112
"""simple docstring""" from math import sqrt def __lowercase ( lowerCamelCase_ : int ): SCREAMING_SNAKE_CASE__ = 0 for i in range(1 , int(sqrt(lowerCamelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCamelCase_ ): total += i + n // i ...
112
1
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging A : Dict = { 'cola': 2, ...
140
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizer...
15
0
'''simple docstring''' import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from .....
714
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @...
517
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler...
65
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor UpperCamelCase__ =logging.get_logger(__name__) class lowerCAmelCase__( __lowercase ): '''simple docstring''' def __init__( self , *__lowerCamelCase , ...
249
0
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerat...
12
"""simple docstring""" class __a : '''simple docstring''' def __init__( self , _a , _a , _a ) -> str: """simple docstring""" SCREAMING_SNAKE_CASE__ : Any = name SCREAMING_SNAKE_CASE__ : Optional[Any] = ...
12
1
'''simple docstring''' __lowercase : Dict = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def lowercase_ ( ) -> None: '''simple docstring''' lowerCamelCase_ : int = input('''Enter message: ''' ) lowerCamelCase_ : Optional[int] = input('''Enter key [alphanumeric]:...
422
from heapq import heappop, heappush import numpy as np def __lowercase ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , ) -> tuple[float | int, list[tuple[int, int]]]: '''simple docstring''' __lowercase , __lowercase = grid.shape __low...
321
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable __snake_case :Optional[Any] ={ 'configuration_gpt_neox_japanese': ['GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoXJapaneseConfig'], 'tokeni...
705
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def lowerCamelCase_ ( lowerCAmelCase__ : Optional[A...
224
0
'''simple docstring''' from __future__ import annotations lowerCamelCase_ = [] def __lowercase ( __lowercase , __lowercase , __lowercase ) -> bool: '''simple docstring''' for i in range(len(__lowercase ) ): if board[row][i] == 1: ...
330
import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib A_ = { "debug": logging.DEBUG, ...
393
0
"""simple docstring""" class lowerCAmelCase_ : # Public class to implement a graph '''simple docstring''' def __init__( self , snake_case_ , snake_case_ , snake_case_ ) -> None: __lowerCAmelCase = row ...
705
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class lowerCAmelCase_ ( A__ ): '''simple docstring''' def __init__( self ...
573
0
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 OptionalDependencyNotAv...
659
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class lowerCa...
201
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class a ( _a ...
714
'''simple docstring''' import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): """simple docstring""" __lowerCAmelCase = JukeboxTokenizer __lowerCAmelCase = { """artist""...
466
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: int ): """simple docstring""" if length <= 0 or not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise ValueError('Length must be a positive integer.' ) ...
580
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copie...
580
1
__UpperCamelCase : Tuple = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def _a ( SCREAMING_SNAKE_CASE : dict , SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CAS...
709
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase : Optional[int] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base...
106
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch...
91
"""simple docstring""" import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterToke...
155
0
# This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests from os.path import j...
15
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase : Dict =logging.get_logger(__name__) lowerCAmelCase : Dict ={"vocab_file": "vocab.json"} lowerCAmelCase : List[str] ...
15
1
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that...
431
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 from transformers.utils import...
431
1
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Tuple = logging.get_logger(__name__) _UpperCAmelCase : Union[...
720
import os _UpperCAmelCase : int = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000} def A ( lowercase ) -> int: '''simple docstring''' UpperCamelCase = 0 UpperCamelCase = 0 while index < len(lowercase ) - 1: UpperCamelCase = SY...
3
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCamelCase = logging.get_logger(__name__) U...
45
def A ( lowercase__ : int ) -> Optional[Any]: stooge(lowercase__ , 0 , len(lowercase__ ) - 1 ) return arr def A ( lowercase__ : Union[str, Any] , lowercase__ : Dict , lowercase__ : str ) -> List[str]: if i >= h: return # If first element is smaller than the last the...
45
1
'''simple docstring''' from math import sqrt def A_ ( SCREAMING_SNAKE_CASE_ = 1_00_00_00 ) ->int: lowercase_ = 0 lowercase_ = 0 lowercase_ = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , 2 * max_cuboid_size + 1 ): if ...
603
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports __snake_case = """ import os """ __snake_case = """ def foo(): import os return False """ __snake_case = """ def foo(): def bar(): if True: import os ...
603
1