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
def __UpperCAmelCase ( __A = 5_0_0_0_0_0_0_0 ) -> int: '''simple docstring''' UpperCAmelCase__ = set() UpperCAmelCase__ = int((limit - 2_4) ** (1 / 2) ) UpperCAmelCase__ = set(range(3 , prime_square_limit +...
475
'''simple docstring''' import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __UpperCAmelCase ( unittest.TestCase ): '''...
366
0
'''simple docstring''' from __future__ import annotations class lowercase : def __init__( self : List[Any] , _lowercase : list[list[int]] ): SCREAMING_SNAKE_CASE__ : List[str] = TypeError( '''Matrices must be formed from a list of ze...
701
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_avail...
250
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : str ): """simple docstring""" __a = [int(SCREAMING_SNAKE_CASE__ ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(SCREAMING_SNAKE_CASE__ ) == 4 and all(0 <= int(SCREAMING_SNAKE_CASE__ ) <= 25...
225
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() ...
289
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_f...
704
"""simple docstring""" import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED...
397
0
from math import sqrt def UpperCamelCase_ ( __a = 1_000_000 ) -> int: a__ : int = 0 a__ : int = 0 a__ : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , 2 * max_cuboid_size + 1 ): ...
37
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Option...
666
0
"""simple docstring""" import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class __lowerCAmelCase ( _lowercase , unittest.TestCase ): """simple docstring""" ...
482
"""simple docstring""" def A_ (__a , __a , __a ): '''simple docstring''' A_ = len(__a ) A_ = [[0] * n for i in range(__a )] for i in range(__a ): A_ = y_points[i] for i in range(2 , __a ): for j...
482
1
'''simple docstring''' import collections import inspect import unittest from transformers import FocalNetConfig 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_back...
274
'''simple docstring''' from __future__ import annotations from typing import Any def snake_case_ ( __snake_case : list[Any]) -> None: create_state_space_tree(__snake_case , [] , 0) def snake_case_ ( __snake_case : list[Any] , __snake_case : list...
274
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise Optional...
704
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake SCREAMING_SNAKE_CASE_ = numpy.array([0, 0]) SCREAMING_SNAKE_CASE_ = numpy.array([0.5, 0.866_0254]) SCREAMING_SNAKE_CASE_ = numpy.array([1, 0]...
466
0
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Flax...
17
"""simple docstring""" import argparse import json import subprocess def UpperCamelCase ( _lowerCAmelCase : Optional[Any], _lowerCAmelCase : Optional[int] ) -> Union[str, Any]: _UpperCAmelCase : Tuple = [] _UpperCAmelCase : Dict ...
238
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, ...
704
import warnings 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_ ( SCREAMING_SNAKE_CASE_...
114
0
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : List[str] , UpperCAmelCase_ : Optional[Any] ) -> str: if not (isinstance(__UpperCAmelCase , __UpperCAmelCase ) and isinstance(__UpperCAmelCase , __UpperCAmelCase )): ...
13
"""simple docstring""" def lowercase_ ( __UpperCAmelCase ) -> str: return " ".join( """""".join(word[::-1] ) if len(__UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wo...
299
0
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
90
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, to_channel_di...
90
1
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ ) -> ...
193
from typing import Dict from .base import GenericTensor, Pipeline class __snake_case ( SCREAMING_SNAKE_CASE ): def SCREAMING_SNAKE_CASE_ ( self ,a_=None ,a_=None ,a_=None ,**a_ ): """simple docstring""" if tokenize_kwargs is None: lowerCAmelCase_...
193
1
'''simple docstring''' import argparse from collections import defaultdict import yaml snake_case_ : int = "docs/source/en/_toctree.yml" def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : Union[str, Any] ) -> str: UpperCAmelCase_ : List[Any] = ...
705
'''simple docstring''' class __a : def __init__( self : List[Any] , __magic_name__ : int ) -> None: """simple docstring""" UpperCAmelCase_ : Optional[Any] = size UpperCAmelCase_...
644
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging __SCREAMING_SNAKE_CASE : List[str] =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : List[str] ={ 'CarlCochet/trajectory-transformer-halfcheetah-medium-v2': ( ...
135
'''simple docstring''' # 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 ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipel...
135
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a__ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """GroupViTOnnxConfig""", ...
706
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__ = logging.getLogger() def _UpperCAmelCase ( ): ...
99
0
from __future__ import annotations from PIL import Image # Define glider example _lowerCAmelCase : int = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],...
246
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_byt...
246
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass A =(3, 9, -11, 0, 7, 5, 1, -1) A =(4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _a : __a : int _...
711
'''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...
358
0
from ..utils import DummyObject, requires_backends class snake_case_ ( metaclass=lowerCAmelCase ): __lowerCamelCase : List[Any] = ['torch', 'transformers', 'onnx'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): requires...
345
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class snake_case_ ( lowerCAmelCase , unittest.TestCase ): __lowerCamelCase : Any ...
345
1
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __snake_case ( lower...
620
import pickle import numpy as np from matplotlib import pyplot as plt class __snake_case : def __init__( self , _A , _A , _A , _A , _A , _A=0.2 , _A=0.2): SCREAMING_SNAKE_CASE_ = bp_numa SCREAMING_SNAKE_CASE_ = bp_numa ...
620
1
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class snake_case ( UpperCamelCase_ ): def __init__( self : Optional[Any] , a_ : List[str] , a_ : List[str] )-> List[Any]: """simple docstring""" SCREA...
85
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def __lowercase ( __lowerCAmelCase : List[Any] , __lowerCAmelCase : str , __lowerCAmelCase : str , ...
335
0
'''simple docstring''' from __future__ import annotations class lowerCAmelCase_: '''simple docstring''' def __init__( self ,__UpperCAmelCase ) -> Dict: lowerCAmelCase__ : Any = TypeError( """Matrices must be formed from a list of zero or mo...
718
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _lowerCAmelCase = datasets.logging.get_logger(__name__) _lowerCAmelCase = '''\ @InProceedings{moosavi2019m...
160
0
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention,...
213
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def SCREAMING_SNAKE_CASE ( __UpperCAmelCase ) -> str: return "".join(sorted(__UpperCAmelCase ) ) def SCREAMING_SNAKE_CASE ...
159
0
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import ...
192
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : list[int] , UpperCAmelCase_ : str ) -> list[int]: '''simple docstring''' __snake_case : Union[str, Any] = int(UpperCAmelCase_ ) # Initialize R...
192
1
"""simple docstring""" import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common imp...
7
'''simple docstring''' import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _a : '''simple docstring''' def __init__( self ,__a ,__a ,__a ) -> Tuple: if dst_width < 0 or...
116
0
import tensorflow as tf from ...tf_utils import shape_list class a_ ( tf.keras.layers.Layer ): """simple docstring""" def __init__( self : Optional[int] ,snake_case : Union[str, Any] ,snake_case : Any ,snake_case : Any ,snake_case : Li...
252
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) class a_ ( lowerCamelCase_ ): """simple docstring""" __UpperCAmelCase = 'encoder-decoder' __UpperCAmelCase = True ...
252
1
'''simple docstring''' _lowercase = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _lowercase ...
5
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class SCREAMING_SNAKE_CASE : '''simple docstring''' ...
329
0
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_config...
682
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex _A = logging.getLogger(__name__) class UpperCAmelCase__ : """simple docstring""" def __init__( self ) ->...
682
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_nump...
371
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging A : List[str] = logging.get_logger...
371
1
"""simple docstring""" import pickle import numpy as np from matplotlib import pyplot as plt class _UpperCAmelCase : def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_ , snake_case_ , snake_case_=0.2 , snake_case_=0.2...
87
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils impor...
87
1
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowercase : Any = logging.get_logger("""transformers.models.speecht5""") def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE...
336
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
195
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCAmelCase : List[Any] = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else:...
715
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function lowerCAmelCase : Any = 1.054571817E-34 # unit of ℏ : J * s lowerCAmelCase : List[str] = 3E8 # uni...
425
0
def __lowercase ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ) -> list: '''simple docstring''' __lowercase = len(_UpperCAmelCase ) __lowercase = [[0] * n for i in range(_UpperCAmelCase )] for i in range(_UpperCAmelCase ): __lowercase = y_point...
321
import warnings 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 snake_case ( __snake_case ): """simple doc...
321
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_available(): raise OptionalDe...
109
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational ...
109
1
import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load_...
121
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMi...
502
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> int: if not numbers: return 0 if not isinstance(SCREAMING_SNAKE_CASE , (list, tuple) ) or not all( isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) for number in numbers ): raise ValueError('number...
700
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCAmelCase__: Dict = { "configuration_gpt_neo": ["GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoConfig", "GPTNeoOnnxConfig"], } try: if no...
311
0
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/licen...
90
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = False ) -> list[float]: '''simple doc...
530
0
"""simple docstring""" from torch import nn def __magic_name__ ( _lowerCamelCase : Union[str, Any] ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": ...
63
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def __magic_name__ ( ): __a : Dict = { """repo_name""": ["""test_repo1""", """test_rep...
63
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Optional[Any] = { '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig''...
4
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : Tuple = { '''vinvino02/glpn-kitti''': '''https://huggingface.co/vinvino02/glpn-k...
4
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProcessor, B...
334
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMod...
334
1
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# A__ : Union[str, Any] = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.weight""", """time_embedding.linear_1.w...
233
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('''repo_id''' ,['''canonical_dataset_name''', '''org-name/dataset-name'''] ) @pytest.mark.parametrize('''path''' ,['''filename.csv''', '''filename with blanks.csv'''] ) @pytest.mark.pa...
233
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class __snake_case ( lowerCamelCase__ ): '''simple docstring''' def UpperCAmelCase__ ( self : List[str] , A : Dict ): ...
702
def A__ ( SCREAMING_SNAKE_CASE__ = 1000) -> int: __snake_case , __snake_case: Dict = 1, 1 __snake_case: int = 2 while True: __snake_case: str = 0 __snake_case: Any = fa + fa __snake_case , __snake_case: Tuple ...
155
0
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_pro...
469
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channe...
469
1
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( _UpperCAmelCase ): """simple docstring""" lowercase__ : Union[str, Any] = (E...
715
UpperCamelCase__ = { "joule": 1.0, "kilojoule": 10_00, "megajoule": 1_00_00_00, "gigajoule": 10_00_00_00_00, "wattsecond": 1.0, "watthour": 36_00, "kilowatthour": 3_60_00_00, "newtonmeter": 1.0, "calorie_nutr": 41_86.8, "kilocalorie_nutr": 4_18_68_00.00, ...
634
0
'''simple docstring''' from typing import Any class lowerCAmelCase_ : def __init__( self , _UpperCamelCase )-> Union[str, Any]: _A = data _A = None def __repr__( self )-> str: ...
292
'''simple docstring''' def lowerCamelCase_ ( __UpperCamelCase : list , __UpperCamelCase : int , __UpperCamelCase : int = 0 , __UpperCamelCase : int = 0 ) -> int: """simple docstring""" _A = right or le...
292
1
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def UpperCamelCase_( __magic_name__ : str ): """simple docstring""" return getitem, k def UpperCamelCase_( __magic_na...
382
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTCo...
382
1
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): _lowercase = { """linear""": PIL.Image.Resampling.BILINEAR, """bilinear""": PIL.Image.Re...
91
from __future__ import annotations import numpy as np def __a ( __lowerCAmelCase ) -> Optional[Any]: return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
352
0
import re import string import numpy as np import datasets A : List[Any] = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" A : int = "\nArgs:\n predictions: List...
718
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A : str = { "configuration_rembert": ["REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP...
356
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channe...
469
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def lowerCamelCase_ ( UpperCamelCase__ : int , UpperCamelCase__ : Optional[int] , UpperCamelCase__ : int , UpperCamelCase__ : str ) -> List[str]: """si...
469
1
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _a = logging.get_logger(__name__) def lowerC...
709
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowerCAmelCase__(__snake_case ) -> Union[str, Any]: '''simple docstring''' def wrapper(*__snake_case ,**__snake_case ): lo...
29
0
import string def SCREAMING_SNAKE_CASE_ ( _snake_case :str ) -> None: for key in range(len(string.ascii_uppercase ) ): _A = '''''' for symbol in message: if symbol in string.ascii_uppercase: _A = string.ascii_uppercase.find(_...
2
import uuid from typing import Any, Dict, List, Optional, Union 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 if is_torch_available(): import torch SCREAMING_SNAKE_CASE ...
579
0
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _lowerCAmelCase ( __magic_name__ :str , __magic_name__ :str , __magic_name__ :Optional[str] = None ): if version.parse(hfh.__version__ ...
407
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def _lowerCAmelCase ( __magic_name__ :list , __magic_name__ :list , __magic_name__ :list , ...
407
1
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp fr...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase : Tuple = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], ...
50
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): ...
716
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase = { """configuration_falcon""": ["""FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FalconConfig"""], } try: if not is_torch_availab...
351
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : int = 4_000_000 ) -> int: '''simple docstring''' _UpperCAmelCase : Optional[int] = [0, 1] _UpperCAmelCase : Union[str, Any] = 0 while fib[i] <= ...
289
"""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
1
"""simple docstring""" 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...
439
"""simple docstring""" from ...configuration_utils import PretrainedConfig class a__ ( UpperCamelCase_ ): snake_case__ = '''bert-generation''' def __init__( self : Dict ,a__ : str=5_0358 ,a__ : List[str]=1024 ,a__ : int=24 ...
439
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : Tuple = { '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '...
493
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( A__ , unittest.TestCase ): """simple docstring""" a = TransfoXLTo...
493
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiua...
328
from __future__ import annotations def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> set[str]: """simple docstring""" _UpperCAmelCase ,_UpperCAmelCase : Optional[Any] = set(_SCREAMING_SNAKE_CASE ), [start] ...
328
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _snake_case : Optional[Any] = logging.get_logger(__name__) _snake_case : str = { 'xlm-mlm-e...
53
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def a_ ( lowerCAmelCase_ : Optional[Any], lowerCAmelCase_ : Optio...
53
1
def _SCREAMING_SNAKE_CASE ( lowercase : int , lowercase : int ): '''simple docstring''' while second != 0: lowerCamelCase_ = first & second first ^= second lowerCamelCase_ = c << 1 return first if ...
720
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 _SCREAMING_SNAKE_CASE ...
651
0
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import To...
114
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, ...
114
1
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .atte...
389
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_senten...
389
1
"""simple docstring""" from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets A_ : str = '\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wa...
265
"""simple docstring""" from __future__ import annotations def __snake_case ( __A : list[int] ) -> list[int]: '''simple docstring''' if len(__A ) == 0: return array SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = ...
265
1
from __future__ import annotations def lowerCAmelCase ( UpperCamelCase__ : tuple[int, int] , UpperCamelCase__ : int ) -> list[tuple[int, int]]: """simple docstring""" __SCREAMING_SNAKE_CASE ,__SCREAMING_SNAKE_CASE: int = pos...
146
import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch fro...
146
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ : List[str] = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'...
24
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py __SCREAMING_SNAKE_CASE = """...
388
0
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester fro...
662
from __future__ import annotations import time import numpy as np __lowerCAmelCase : List[str] = [8, 5, 9, 7] __lowerCAmelCase : str = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] __lowerCAmelCase : Optional[Any] = [ [3, 2, 1, 4]...
662
1
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_ ( lowerCamelCase ): return (dat...
21
import heapq def lowerCAmelCase_ ( lowerCamelCase ): __magic_name__ : list[list] =[] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with...
21
1
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 SCREAMING_SNAKE_CASE__ ...
713
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": _SCREAMING_SNAKE_CASE = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Sear...
534
0
def a ( A__ : int = 10 , A__ : int = 1000 , A__ : bool = True ) -> int: """simple docstring""" assert ( isinstance(A__ , A__ ) and isinstance(A__ , A__ ) and isinstance(A__ , A__ ) ), "Invalid type of value(s) sp...
291
import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProcessor fro...
291
1
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute_m...
297
def _lowerCamelCase ( _a ): """simple docstring""" if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence _lowerCamelCase = gray_code_sequence_string(_a ) # # convert them to integers for i in range(len(_a ...
297
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer __snake_case = logging.get_logger(__name__) ...
1
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transforme...
359
0
from __future__ import annotations import time a_ : Tuple = list[tuple[int, int]] a_ : Optional[int] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0,...
444
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path a_ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) a_ : list[int] = [ord(letter) for letter in string.ascii_lowe...
444
1
'''simple docstring''' import os def _UpperCamelCase ()-> Union[str, Any]: '''simple docstring''' __snake_case = os.path.dirname(os.path.realpath(_lowerCamelCase ) ) __snake_case = os.path.join(_lowerCamelCase , '''triangle.txt''' ...
24
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : int , lowerCAmelCase__ : int) -> int: '''simple docstring''' return int((input_a, input_a).count(0) != 0) def SCREAMING_SNAKE_CASE ( ) -> None: '''simple docstrin...
125
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Optional[int] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''...
32
from __future__ import annotations def UpperCAmelCase__ ( UpperCAmelCase__ :int ): '''simple docstring''' a = str(UpperCAmelCase__ ) return len(UpperCAmelCase__ ) == 9 and set(UpperCAmelCase__ ) == set("123456789" ) def UpperCAmelCase__ ( ...
32
1
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers cla...
96
"""simple docstring""" import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: war...
96
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageRes...
584
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 accelerate import Accelera...
584
1
def __lowercase ( _UpperCamelCase, _UpperCamelCase = " " ) ->list: """simple docstring""" lowercase : List[str] = [] lowercase : Union[str, Any] = 0 for index, char in enumerate(_UpperCamelCase ): if char == separator: ...
319
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __a = logging.get_logger(__name__) __a = {'''vocab_file''': '''vocab.txt'''} __a = { '''vocab_file''': ...
319
1
"""simple docstring""" import sys a :Dict = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856...
12
"""simple docstring""" a :List[str] = [ (1_000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def _lowercase ( __lowerCAmelCase ) -> ...
12
1
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def A_ ( _lowerCAmelCase : List[str] ): """simple docstring""" _lowerCamelCase : List[Any] = [ "encoder...
44
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ : List[Any] = logging.get_logger(__name__) lowerCamelCase__ : Union[str, Any] = { "...
12
0
"""simple docstring""" import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase_ ( __UpperCAmelCase ) -> List[str]: return x + 2 class _lowerCamelCase ( unittest.TestCase ): def _lowe...
715
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
507
0
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 diffusers.pipelines.stable_diffusion import Stabl...
202
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : ...
202
1
import os UpperCAmelCase_ = {"""I""": 1, """V""": 5, """X""": 10, """L""": 50, """C""": 100, """D""": 500, """M""": 1_000} def __magic_name__ ( lowercase ) -> int: """simple docstring""" lowercase_ : Optional[Any] ...
436
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundf...
436
1
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: float , _lowerCamelCase: int ): if digit_amount > 0: return round(number - int(_lowerCamelCase ) , _lowerCamelCase ) return number - int(_lowerCamelCase ) if __name__ == "__main__": print(decimal_isolate(1.5...
578
'''simple docstring''' import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() UpperCamelCase_...
578
1
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils...
706
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ : Optional[Any] = { "configuration_funnel": ["FUNNEL_PRETRAINED...
18
0
import os from collections.abc import Iterator def UpperCAmelCase_ ( __UpperCAmelCase : str = "." ) -> Iterator[str]: for dir_path, dir_names, filenames in os.walk(__UpperCAmelCase ): SCREAMING_SNAKE_CASE_ = [d for d in dir_names if d != 'scripts' and d[0] not ...
31
from __future__ import annotations from collections.abc import Iterator class lowerCamelCase_ : '''simple docstring''' def __init__( self : Union[str, Any] , _lowerCAmelCase : int ): SCREAMING_SNAKE_CASE_ = value SCREAMING_SNAKE_CASE_ ...
31
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowercase ( lowerCAmel...
497
"""simple docstring""" 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, ren...
497
1
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
394
'''simple docstring''' import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A : Tuple = logging.get_logger(__name__) __A : int = { 'vocab_file': '...
394
1
"""simple docstring""" from collections.abc import Generator from math import sin def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ) ->bytes: if len(SCREAMING_SNAKE_CASE_ ) != 32: raise ValueError('''Input must be of length 32''' ) _lowerCamelCase : Dict = B'''''' ...
707
"""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, ) class _UpperCAmelC...
558
0
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP lowerCAmelCase_ = False try: lowerCAmelCase_ ...
39
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_ut...
310
0
from statistics import mean import numpy as np def __UpperCAmelCase ( a_ , a_ , a_ , a_): snake_case_ = 0 # Number of processes finished snake_case_ = 0 # Displays the finished process. # If it is 0, the performance is co...
607
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import write_b...
607
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.ut...
559
import math import sys def lowerCAmelCase( __lowerCamelCase ): if number != int(__lowerCamelCase ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the value of input must not be a negative number' ) if number == 0:...
559
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( UpperCAmelCase_ , UpperCAmelCase_ ): @register_to_config def __init__( self : str , *, lowerCamelCase__ : int = 4 ...
515
import fire from utils import calculate_rouge, save_json def __lowerCamelCase ( __lowerCAmelCase : Dict , __lowerCAmelCase : Union[str, Any] , __lowerCAmelCase : Optional[Any]=None , **__lowerCAmelCase : Union[str, Any] ) ...
515
1
'''simple docstring''' import random def __A ( lowerCamelCase_ ): """simple docstring""" SCREAMING_SNAKE_CASE : str = num - 1 SCREAMING_SNAKE_CASE : Union[str, Any] = 0 while s % 2 == 0: SCREAMING_SNAKE_CASE : List[str] = s // 2 t += 1 for _ in range(5 ): ...
379
'''simple docstring''' import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class...
379
1
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging _SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) def ...
206
_SCREAMING_SNAKE_CASE : dict[tuple[int, int, int], int] = {} def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: return 0 ...
206
1
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvisio...
7
import requests def _snake_case (__lowercase , __lowercase): UpperCamelCase_ = {'Content-Type': 'application/json'} UpperCamelCase_ = requests.post(__lowercase , json={'text': message_body} , headers=__lowercase) if response.status_code != 20...
23
0
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperC...
552
from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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 ...
552
1
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_...
72
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface...
72
1
import math def A__ ( SCREAMING_SNAKE_CASE__ = 100) -> int: __snake_case: Tuple = sum(i * i for i in range(1 , n + 1)) __snake_case: List[Any] = int(math.pow(sum(range(1 , n + 1)) , 2)) return square_of_sum - sum_of_squares i...
155
def A__ ( SCREAMING_SNAKE_CASE__ = 100) -> int: __snake_case: str = 0 __snake_case: int = 0 for i in range(1 , n + 1): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main__": print(f'{so...
155
1
"""simple docstring""" import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts and running tests. _SCREAMING_SNAKE_CASE = abspath(join(dirnam...
163
"""simple docstring""" import argparse import json import subprocess def __a ( a, a ): """simple docstring""" _a = [] _a = ( F'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"' " https://...
388
0
from __future__ import annotations from random import choice def a_ ( _A ) -> List[Any]: """simple docstring""" return choice(_A ) def a_ ( _A , _A ) -> int: """simple docstring""" snake_case__ = random_...
372
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_d...
372
1