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 math def a__ ( A__, A__ = 0, A__ = 0 ): SCREAMING_SNAKE_CASE_ : Any = end or len(lowerCAmelCase_ ) for i in range(lowerCAmelCase_, lowerCAmelCase_ ): SCREAMING_SNAKE_CASE_ : Union[str, Any] = i SCREAMING_SNAKE_C...
101
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def SCREAMING_SNAKE_CASE_ ( lowerCAmelCase_: int ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , set() ) @pytest.fixture de...
666
0
'''simple docstring''' def __UpperCamelCase ( _A : int ) -> int: """simple docstring""" if not isinstance(_A , _A ): raise ValueError('multiplicative_persistence() only accepts integral values' ) if num < 0: raise ValueError('multiplicative_persistence() does...
646
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase : Any = logging.get_logger(__name__) _lowerCAmelCase : List[str] = { 'xlm-r...
646
1
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency _SCREAMING_SNAKE_CASE = { 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, 'C': 2.78, ...
401
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_avail...
315
0
from dataclasses import dataclass, field from typing import Optional @dataclass class snake_case_ : '''simple docstring''' lowerCamelCase = field( default="codeparrot/codeparrot" , metadata={"help": "Model name or path of model to be trained."} ) lowerCamelCase ...
253
def __a ( __UpperCAmelCase : str ) -> bool: """simple docstring""" return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def __a ( __UpperCAmelCase : str ) -> bool: """simple docstring""" lowerCamelCase_ : ...
253
1
import numpy as np def __lowercase ( snake_case ): """simple docstring""" return 1 / (1 + np.exp(-vector )) def __lowercase ( snake_case ): """simple docstring""" return vector * sigmoid(1.702 * vector ) if __name__ == "__main__": imp...
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration _lowercase : List[str] =5_0000 _lowercase : str =5000 _lowercase , _lowercase : List[str] =os.path.split(__file__) _lowercase : Union[str, A...
364
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction...
63
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": lowercase__ = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=None, type=str, requi...
63
1
from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from...
59
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __lowercase : Dict ={ """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
54
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _A : Optional[Any] = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTN...
330
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging imp...
330
1
'''simple docstring''' def A_ ( _lowerCAmelCase : str , _lowerCAmelCase : str ): """simple docstring""" assert x is not None assert y is not None _lowerCamelCase : Optional[int] = len(UpperCamelCase__ ) _lowerCamelCase : int ...
44
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_f...
442
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 fro...
706
import doctest from collections import deque import numpy as np class UpperCAmelCase__ : """simple docstring""" def __init__( self : Optional[Any] ) -> None: SCREAMING_SNAKE_CASE__ = [2, 1, 2, -1] SCREAMING_SNAKE_CASE__ = [1, 2, 3, 4] def ...
472
0
UpperCAmelCase_ = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "a", 11: "b", 12: "c", 13: "d", 14: "e", 15: "f", } def A__ ( SCREAMING_SNAKE_CASE_ : float ) -> str: ...
32
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "microsoft/biogpt": "https://huggingface.co/microsoft/biogpt/resolve/main/config.json", # See all BioGPT models at https://huggingface....
32
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase_( SCREAMING_SNAKE_CASE ) -> float: """simple docstring""" return np.dot(SCREAMING_SNAKE_CASE , SCREAMING_SN...
710
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensio...
20
0
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softm...
101
"""simple docstring""" from sklearn.metrics import fa_score import datasets lowerCAmelCase__ = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' lowerCAmelCase__ = ''' Args: ...
645
0
"""simple docstring""" from __future__ import annotations def A__ ( __lowerCamelCase ): # This function is recursive """simple docstring""" _lowerCAmelCase = len(__lowerCamelCase ) # If the array contains only one element, we return it (it's the stop condition of ...
309
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils imp...
309
1
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, ...
510
"""simple docstring""" def snake_case ( _a: int , _a: int )-> 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 # Calc...
510
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase : Tuple = logging.get_logger(__name__) UpperCamelCase : Tuple = { """roberta-base""": "...
151
from queue import PriorityQueue from typing import Any import numpy as np def UpperCamelCase_ ( __a , __a , __a , __a , __a , __a , __a , __a , __a , ) -> float | int: for nxt, d in graph[v]: if nxt in visited_forward: ...
151
1
'''simple docstring''' import argparse import os # New Code # 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_schedul...
8
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transf...
44
0
'''simple docstring''' class UpperCamelCase__ : # Public class to implement a graph """simple docstring""" def __init__( self : Tuple , __A : int , __A : int , __A : list[list[bool]] ): """simple docstring""" _lowercase = row ...
602
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ : Any = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
602
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor __SCREAMING_...
236
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :Tuple = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :List[str] = { '''google/realm-cc-news-pretrained-embedder''': ( '''https://huggingface...
236
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE : List[str] = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenizati...
714
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
238
0
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # no...
152
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorS...
152
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) __lowerCAmelCase : Optional[Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/...
76
from typing import Dict from .base import GenericTensor, Pipeline class UpperCAmelCase_ ( _A ): '''simple docstring''' def _lowercase ( self : List[Any] , UpperCamelCase__ : List[Any]=None , UpperCamelCase__ : Union[str, A...
76
1
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational im...
121
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
1
"""simple docstring""" import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark impor...
498
"""simple docstring""" 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 A_ = logging.get_logger(__name__) A_ = {'''vocab_file'...
498
1
'''simple docstring''' import argparse import os import re import packaging.version lowercase : int = 'examples/' lowercase : int = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re....
649
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class _lowerCAmelCase ( unittest.TestCase ): """...
649
1
"""simple docstring""" import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", e...
562
"""simple docstring""" import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = ...
562
1
"""simple docstring""" 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...
580
"""simple docstring""" 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, rand...
580
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json""", } class lowerCAmelCase__ ( __snake_...
716
from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json', # See all Cvt models at https://huggingface.co/models?filter=cvt } clas...
234
0
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "google/umt5-small": "https://huggingface.co/google/umt5-small/re...
270
'''simple docstring''' import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py A_ = "." # Internal TensorFlow ops...
270
1
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, r...
712
from __future__ import annotations import requests def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE : Dict = f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return requests.get(__lowerCamelCase ).json() def lowerCa...
381
0
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def lowercase_ ( _UpperCamelCase ...
639
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
1
from math import factorial, pi def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ = 30): '''simple docstring''' if not isinstance(lowerCAmelCase_ , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstanc...
73
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax....
73
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabl...
21
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { ...
21
1
from __future__ import annotations class UpperCAmelCase__ : def __init__( self : Any , a_ : int , a_ : Tuple ): '''simple docstring''' __UpperCAmelCase , __UpperCAmelCase : Optional[int] = text, pattern __...
720
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class UpperCAmelCase__ ( __UpperCamelCase ): '''simple docstring''' @require_torch def sn...
241
0
def lowerCamelCase__ ( _lowercase , _lowercase ): '''simple docstring''' UpperCAmelCase_ : Any = len(_lowercase ) print('''The following activities are selected:''' ) # The first activity is always selected UpperCAmelCase_ : int = 0 print(_lowerca...
30
'''simple docstring''' from __future__ import annotations import queue class _a : '''simple docstring''' def __init__( self, A ): '''simple docstring''' SCREAMING_SNAKE_CA...
28
0
"""simple docstring""" from math import factorial def lowerCamelCase_ ( _lowerCamelCase = 100 ): return sum(map(_lowerCamelCase , str(factorial(_lowerCamelCase ) ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: ").strip())))
696
"""simple docstring""" from ..utils import DummyObject, requires_backends class a_ ( metaclass=snake_case_ ): '''simple docstring''' lowerCamelCase__ : str = ['speech'] def __init__(self, *lowerCamelCase_, **lowerCamelCase_ ): '''simple docstring...
696
1
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, O...
62
def lowerCamelCase__ ( lowercase ): """simple docstring""" if not isinstance(lowercase , lowercase ): raise TypeError("only integers accepted as input" ) else: SCREAMING_SNAKE_CASE : Optional[int] = str(abs(lowercase ) ) SCREAMING_SNAKE...
62
1
from typing import Union import fire import torch from tqdm import tqdm def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase = "cpu" , _lowerCamelCase = None ) ->Dict: _UpperCAmelCase =torch.load(a__ , map_location=a__ ) for k, v in tqdm(state_dict.items() ): if not isinstan...
714
import functools from typing import Any def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ) ->bool: # Validation if not isinstance(_lowerCamelCase , _lowerCamelCase ) or len(_lowerCamelCase ) == 0: raise ValueError("the string should be not empty string" ) if not isinstance(_...
592
0
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class __lowerCAmelCase : '''simple docstring''' _A = None def snake_case__( self: Optional[Any] ): lowercase__ : ...
266
def SCREAMING_SNAKE_CASE__ ( _lowercase : int , _lowercase : int ) -> Optional[int]: '''simple docstring''' if b == 0: return 1 if (b % 2) == 0: return actual_power(_lowercase , int(b / 2 ) ) * actual_power(_lowercase , int(b / 2 ...
266
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
167
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature fro...
167
1
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig 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_configurat...
299
"""simple docstring""" from __future__ import annotations def lowercase_ ( __UpperCAmelCase ) -> list[int]: lowerCAmelCase__ : int = 2 lowerCAmelCase__ : int = [] while i * i <= n: if n % i: i += 1 else: ...
299
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_ : Tuple = { "t5-small": "https://hugg...
367
from math import pow, sqrt def lowerCAmelCase_ ( *lowerCamelCase ): __magic_name__ : Tuple =len(lowerCamelCase ) > 0 and all(value > 0.0 for value in values ) return result def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): return ( ro...
367
1
"""simple docstring""" import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --hos...
142
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable _lowerCAmelCase : int = {'configuration_dpt': ['DPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DPTConfig']} ...
246
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_tf, sl...
400
from collections import defaultdict class lowercase__ : def __init__( self : Optional[Any] , UpperCAmelCase_ : int , UpperCAmelCase_ : int ): SCREAMING_SNAKE_CASE__ = total # total no of tasks (N) # DP table will have a dimension of (2...
400
1
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _SCREAMING_SNAKE_CASE = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _SCREAMING_SNAKE_CASE = typing.Union[np.floataa, int, float] # noqa: UP007 def lowercase( Upp...
537
"""simple docstring""" # We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class Upp...
289
0
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 imp...
218
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def snake_case_ (__A : int ) -> str: __lowerCAmelCase : str = int(__A ) ...
218
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configur...
84
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Any = { "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config....
89
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_ge...
247
from ..utils import DummyObject, requires_backends class A (metaclass=SCREAMING_SNAKE_CASE ): '''simple docstring''' __lowerCamelCase : Any = ['''keras_nlp'''] def __init__( self : Any , *__lowerCAmelCase : Any ...
247
1
'''simple docstring''' import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerat...
374
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor im...
374
1
"""simple docstring""" 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 _snake_case ( lowercase__ :...
715
"""simple docstring""" import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from...
256
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Optional[int] ={ """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_available(): ...
650
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ......
625
0
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
62
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, O...
62
1
'''simple docstring''' import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @req...
51
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class A__: def __init__( self : str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE = {} ...
482
0
def lowerCAmelCase__ ( a__ ) ->Tuple: '''simple docstring''' _UpperCamelCase = 0 _UpperCamelCase = len(a__ ) for i in range(n - 1 ): for j in range(i + 1 , a__ ): if arr[i] > arr[j]: num_inversions += 1 return num_inversions def ...
82
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load...
82
1
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _UpperCamelCase : List[Any] =models.Sequential() ...
206
"""simple docstring""" import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from...
656
0
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def lowerCAmelCase__ ( )-> Dict: A__ = ArgumentParser( description=( '''PyTorch TPU distributed training launch help...
713
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 lowerCAmelCase__ ( UpperCamelCase_ : dict )-> tuple: ...
526
0
def __snake_case ( _lowerCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) A_ : List[Any] = len(bin(_lowerCAmelCase )[3:] ) A_ : Optional[int] = bin(abs(_lowerCAmelCase ...
454
from timeit import timeit _lowerCAmelCase : Tuple = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan a canal panama" } # En...
454
1
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffuse...
697
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __SCREAMING_SNAKE_CASE : List[str] = ( '4S 3H 2C 7S 5H', '9D 8H 2C 6S 7H', '2D 6D 9D TH 7D', 'TC 8C 2S JH 6C', ...
697
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowerCAmelCase = {"configuration_unispeech": ["UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP", "UniSpeechConfig"]} try: if not is_...
10
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, DataCo...
10
1
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __a ...
335
from __future__ import annotations from dataclasses import dataclass @dataclass class __a : __lowercase : float __lowercase : TreeNode | None = None __lowercase : TreeNode | None = None def snake_case_ ( snake_case )...
335
1
SCREAMING_SNAKE_CASE__ : int = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def _a ( lowercase__ : bytes ): '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ): SCREAMING_SNAKE_CASE__ : Optio...
85
'''simple docstring''' import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig lowercase__ : int = logging.get_logger(__name__) lowercase__ : Any = ...
98
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision fr...
320
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : str , UpperCAmelCase__ : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(UpperCAmelCase__ ) - ngram_size + 1 )] if __name__ == "__main_...
320
1
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipel...
93
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Union[str, Any] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatureEx...
336
0
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transforme...
278
def A ( UpperCAmelCase ): if n == 1 or not isinstance(UpperCAmelCase , UpperCAmelCase ): return 0 elif n == 2: return 1 else: _snake_case : List[Any] = [0, 1] for i in range(2 , n + 1 ): ...
278
1
def lowerCamelCase__ ( _A , _A ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) snake_case_ = str(bin(_A ) )[2:] # remove the leading "0b" snake_case_ = str(bi...
376
import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids...
376
1
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class snake_case ( _UpperCamelCase): def __lt__( self : List[Any] , a__ : Any ) ...
621
"""simple docstring""" 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 impor...
621
1
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) def _UpperCamelC...
42
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __snake_case( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> int: snake_case__ : Tuple = OmegaConf.loa...
374
0
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(UpperCAmelCase__) , ...
710
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_opt...
308
0
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_availabl...
67
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchma...
251
0
'''simple docstring''' from typing import Any def UpperCamelCase_ ( A__ : list ): '''simple docstring''' if not input_list: return [] lowerCAmelCase_ : int = [input_list.count(A__ ) for value in input_list] lowerCA...
398
'''simple docstring''' import numpy as np def UpperCamelCase_ ( A__ : np.array ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def UpperCamelCase_ ( A__ : np.array ): '''simple do...
398
1
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedCon...
56
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging loggin...
343
0
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels lowerCAmelCase__ = object() # For specifying empty leaf dict `{}` lowerCAmelCase__ = object() def __lowerCame...
712
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
81
0
"""simple docstring""" from __future__ import annotations def __lowerCamelCase ( a_ : int | str ) -> bool: __SCREAMING_SNAKE_CASE :Optional[int] = str(a_ ) return n == n[::-1] def __lowerCamelCase ( a_ : int = 1_00_00_00 ) -> ...
498
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass lowerCamelCase_ = (3, 9, -1_1, 0, 7, 5, 1, -1) lowerCamelCase_ = (4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class _SCREAMIN...
498
1
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowercase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' lowerCamelCase : str = FileLock(str(tmpdir / "foo.lock" ) ) lowerCamelCase : Optional[i...
231
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def lowercase_( SCREAMING_SNAKE_CASE_ = "isbn/0140328726" ): '''simple docstring''' lowerCamelCase : List[Any] = olid.strip().strip("/" ) # Remove leading...
231
1
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : Tuple = { 'huggingface/time-series-trans...
601
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow ...
601
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case :Any = logging.get_logger(__name__) __snake_case :Dict = '''▁''' __snake_case :Optio...
60
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
1
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging __A =logging.get_logger(__name__) def lowerCamelCase_ ( lowerCamelCase__ , lo...
463
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets __A ='''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "Snover, Matthew and Dorr, Bonnie and Schwartz, Rich and ...
463
1
'''simple docstring''' from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __snake_case = logging.get_logger(__name__) __snake_case = OrderedDict( [...
719
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _a ( __a ): """simple docstring""" def __init__( self : ...
603
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : str = logging.get_logger(__name__) lowercase__ : Union[str, Any] = { '''asapp/sew-d-tiny-1...
8
from __future__ import annotations def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = None , SCREAMING_SNAKE_CASE = None ): '''simple docstring''' if start is None: A_ = 0 if end is None: A_ = le...
203
0
'''simple docstring''' from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch...
700
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( A_ : str = "isbn/0140328726" ) -> dict: '''simple docstring''' UpperCamelCase__ : Optional[Any] =olid.strip().strip("/" ) # Remove leading/trailing whitespa...
582
0
def lowerCamelCase( a__): _SCREAMING_SNAKE_CASE =len(a__) for i in range(length - 1): _SCREAMING_SNAKE_CASE =i for k in range(i + 1 ,a__): if collection[k] < collection[least]: _SCREAMING_SNAKE_CASE =k if least != i: _...
691
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowerCamelCase( a__): def wrapper(*a__ ,**a__): _SCREAMING_SNAKE_CASE =timeit.default_timer() _SCREAMING_SNAKE_CASE =fun...
691
1
"""simple docstring""" def A__ ( _UpperCAmelCase : Dict , _UpperCAmelCase : Optional[int] , _UpperCAmelCase : Optional[Any] , _UpperCAmelCase : str ) -> Dict: '''simple docstring''' global f # a global dp table for knapsack if f[i...
717
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.uti...
150
0
"""simple docstring""" from __future__ import annotations def a ( __UpperCAmelCase : list[float] , __UpperCAmelCase : Any ) -> Optional[Any]: print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(__UpperCAmel...
96
'''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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_ut...
672
0
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __magic_name__ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( UpperCamelCase): """simple docstring""" def __init__( self , *_UpperCAmelCase , **_Upp...
679
from timeit import timeit def UpperCAmelCase__( __UpperCAmelCase : int ): if number < 0: raise ValueError('the value of input must not be negative' ) __snake_case : Dict = 0 while number: number &= number - 1 result += 1 return result def ...
679
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'], 'processing_...
511
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ......
111
0
import operator def _snake_case ( __snake_case , __snake_case = False , __snake_case = None ) -> list: '''simple docstring''' UpperCAmelCase_ : Optional[int] = operator.lt if reverse else operator.gt UpperCAmelCase_ : int = so...
455
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class snake_case_ (TensorFormatte...
455
1
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def lowercase__ ( A_: str ) -> Optional[int]: """simple docstr...
68
'''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 import floats_tenso...
292
0
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__ ( lowercase__ ): ...
319
'''simple docstring''' from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline __lowerCAmelCase = logging....
319
1
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __snake_case : Optional[int] ...
131
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
0
import os import time import numpy as np import onnxruntime as ort __UpperCamelCase : List[str] = """1""" __UpperCamelCase : Any = """0""" __UpperCamelCase : Dict = """1""" __UpperCamelCase : int = ort.Session...
53
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( _lowerCAmelCase ): __snake_case :str = (UnCLIPScheduler,) def _a ( self : Optional[int] , **_lowerCAmelCase : Any ...
53
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : int = 1 , lowerCamelCase__ : int = 1000 ): '''simple docstring''' A: Dict = 1 A: str = 0 for divide_by_number in range(lowerCamelCase__ , digit + 1 ): ...
135
'''simple docstring''' import numpy as np def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : List[Any] , lowerCamelCase__ : List[str] , lowerCamelCase__ : Optional[Any] , lowerCamelCase__ : Dict , lowerCamelCase__ : Optional[int] ): '''simple docstring'...
135
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "uclanlp/visualbert-vqa": "https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json", "uclanlp/visualbert-vqa-pre": "https...
228
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def lowercase (_snake_case ,_snake_case ,_snake_case=1024 ,_snake_case=1024 ,_snake_case=False ,**_snake_case ) ->...
228
1
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common...
41
def A__( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__lowerCAmelCase ) ) def A__( __lowerCAmelCase , __lowerCAmelCase , ...
304
0
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 from ...tokenization_u...
29
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging _a = logging.get_logger(__name__) class __A : '''simple docstring''' lowerCAmelCase_ = None @experimental def lowerCAmelCase__(__sna...
29
1
import datasets a : List[Any] = '\\n@InProceedings{conneau2018xnli,\n author = "Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n ...
556
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
556
1
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( _lowerCAmelCase ): __snake_case :str = (UnCLIPScheduler,) def _a ( self : Optional[int] , **_lowerCAmelCase : Any ...
53
from __future__ import annotations from scipy.special import comb # type: ignore class __UpperCamelCase : def __init__( self : int , _lowerCAmelCase : list[tuple[float, float]] ) -> Any: """simple docstring""" __lowercase = list_of_...
53
1
from __future__ import annotations import math def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' if depth < 0: raise ValueError("Depth cannot be less than 0") if len(l...
250
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) __magic_name__ =...
250
1
from maths.prime_factors import prime_factors def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int ) -> int: if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): __lowercase = F"""Input value of [number={number}] must be an integer""" raise T...
688
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
688
1
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_availa...
70
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : int , lowerCAmelCase : int ): """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def lowerCamelCase ( ): """simple docstring""" assert and_g...
561
0
def __lowercase ( UpperCAmelCase__ , UpperCAmelCase__ ): """simple docstring""" _enforce_args(snake_case__ , snake_case__ ) if n == 0: return 0 __lowerCAmelCase = float('-inf' ) for i in range(1 , n + 1 ): ...
717
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHeadsMo...
102
0