code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return x + 2 class lowercas...
46
"""simple docstring""" from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_...
46
1
'''simple docstring''' from __future__ import annotations def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> Optional[Any]: if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: ...
351
'''simple docstring''' from __future__ import annotations import math def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> int: if depth < 0: raise ValueError('''Depth cannot be less than 0''' ) if no...
299
0
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def A (__A : Union[str, Any] , __A : Dict , __A : Dict , __A : int , ) -> list[float]: """simple docstring""" ...
51
from math import isqrt def UpperCAmelCase_ ( __snake_case ) -> list[int]: """simple docstring""" _lowercase =[True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , __snake_case , ...
5
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE : Any = {"configuration_vit": ["VIT_PRE...
92
'''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 from torch.distr...
92
1
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_tensor, load_image, load_numpy, slo...
65
'''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) ...
163
0
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class SCREAMING_SNAKE_CASE ( unittest.TestCase ): '''simple docstring''' def _A ( self : str ): SCREAMING_SNAKE_CASE : int ...
319
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case = get_logger(__name__) snake_case = r""" Args: input_ids (`jnp.ndarray` of shape `(batch_size, sequence_le...
319
1
"""simple docstring""" from __future__ import annotations def a_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : float , ): '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError(...
77
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
205
0
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase , __lowerCamelCase ): '''simple docstring''' return base * power(__lowerCamelCase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recurs...
358
'''simple docstring''' 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 impo...
242
0
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( __a , __a , __a=None ) -> Any: """s...
10
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class __lowerCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): @register_to_config def...
82
0
import os import sys import transformers lowerCamelCase__ = """3""" print("""Python version:""", sys.version) print("""transformers version:""", transformers.__version__) try: import torch print("""Torch version:""", torch.__version__) print("""Cuda available:""", torch.cuda.is_avail...
367
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers....
182
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = ...
346
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json''', }...
74
0
from __future__ import annotations def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE : List[Any] = 0.00 _SCREAMING_SNAKE_CASE : List[str] = 0 for resistor in resistors: if resistor <= 0: _SCREAMING_SNAKE_CASE...
353
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 logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ...
325
0
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers _lowerCamelCase : Any = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def __lowerCamelCase ( ) -> Union[str, Any]: """simple docstring""" UpperCamelC...
28
'''simple docstring''' import heapq import sys import numpy as np UpperCamelCase = tuple[int, int] class lowerCAmelCase_ : '''simple docstring''' def __init__( self : List[Any] ) -> str: '''simple ...
319
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _a = { """configuration_funnel""": ["""FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FunnelConfig"""],...
359
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """bert-base-uncased"...
100
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging ...
24
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate...
299
0
# Lint as: python3 import itertools import os import re _snake_case = re.compile(R"([A-Z]+)([A-Z][a-z])") _snake_case = re.compile(R"([a-z\d])([A-Z])") _snake_case = re.compile(R"(?<!_)_(?!_)") _snake_case = re.compile(R"(_{2,})") _snake_case = R"^\w+(\.\w+)*$" _snake_case = R"<>:/\|?*" def ...
367
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class UpperCAmelCase_ ( datasets.BuilderConfig): lowerCamelCase__ = None class UpperCAmelCase_ ...
300
0
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar UpperCamelCase__ = TypeVar("""T""") def _a ( SCREAMING_SNAKE_CASE_ : int ): return (position - 1) // 2 def _a ( SCREAMING_SNAKE_CASE_ : int ): ...
92
from queue import PriorityQueue from typing import Any import numpy as np def _a ( SCREAMING_SNAKE_CASE_ : dict , SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : set , SCREAMING_SNAKE_CASE_ : set , SCREAMING_SNAKE_...
92
1
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging SCREAMING_SNAKE_CASE :Tuple = logging.get_logger(__name__) class UpperCAmelCase : '''simple docstring''' snake_case_ = None @experim...
124
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppTokenizer,...
124
1
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class lowerCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def _snake_case ...
319
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase = { '''configuration_vision_encoder_decoder''': ['''VisionEn...
319
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor lowerCamelCase = logging.get_logger(__name__) class lowercase__ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' ...
363
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
241
0
import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class __lowerCamelCase : """simple docstring""" def __init__( self , UpperCAmelCase ...
39
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _A = logging.get_logger(__name__) _A = { """SenseTime/deformable-detr""": """https://huggingface.co/sensetime/deformable-detr/r...
242
0
'''simple docstring''' import datasets _lowercase : Dict = "\\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 ...
361
'''simple docstring''' import qiskit def snake_case_ ( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): """simple docstring""" lowercase_ : List[Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Cre...
264
0
import numpy as np from PIL import Image def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ) -> int: '''simple docstring''' lowerCamelCase__ = np.array(_lowercase ) if arr.shape[0] != arr.shape[1]: raise ValueError('''The input array is n...
209
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import P...
182
0
'''simple docstring''' from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDi...
331
'''simple docstring''' import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_atte...
331
1
"""simple docstring""" class __lowerCAmelCase : # Public class to implement a graph def __init__( self , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): '''simple docstring''' __UpperCamelCase = row __UpperCamelCase = col __Uppe...
316
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't b...
316
1
'''simple docstring''' class UpperCAmelCase : def __init__( self : Union[str, Any], a_ : Dict ): """simple docstring""" UpperCamelCase__ = arr.split("," ) def lowercase_ ( self : List[str] ): """simple docstring""" UpperCamelCase...
31
'''simple docstring''' import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="%(message)s") def SCREAMING_SNAKE_CASE__( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' ...
31
1
from pathlib import Path import fire from tqdm import tqdm def __A ( __lowerCamelCase="ro" , __lowerCamelCase="en" , __lowerCamelCase="wmt16" , __lowerCamelCase=None ) -> Dict: try: import datasets except (ModuleNotFoundError, ImportError): rai...
228
"""simple docstring""" from math import isqrt, loga def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase_ , UpperCamel...
100
0
class __lowercase : """simple docstring""" def __init__( self , A ) -> List[Any]: snake_case : Tuple = n snake_case : Optional[Any] = [None] * self.n snake_case : Tuple = 0 # index of the first ...
176
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 transformers.utils import loggi...
176
1
"""simple docstring""" from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, ...
25
from __future__ import annotations def __snake_case ( _lowerCAmelCase : list[float] ) -> bool: if len(_lowerCAmelCase ) < 2: raise ValueError("Monogons and Digons are not polygons in the Euclidean space" ) if any(i <= 0 for i in nums ): raise ValueError("All values...
300
0
def SCREAMING_SNAKE_CASE__ ( __a , __a , __a ): snake_case_ : List[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def SCREAMING_SNAKE_CASE__ ( ): print(sum_of_series(1 ,...
371
def SCREAMING_SNAKE_CASE__ ( __a = 60_08_51_47_51_43 ): try: snake_case_ : Optional[Any] = int(__a ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater t...
88
0
import math def SCREAMING_SNAKE_CASE__ ( lowercase = 100 ) -> int: snake_case : int = sum(i * i for i in range(1 ,n + 1 ) ) snake_case : Optional[int] = int(math.pow(sum(range(1 ,n + 1 ) ) ,2 ) ) return square...
124
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() lowerCamelCase : Any = logging.get_...
124
1
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __snake_case : def __init__( self : Union[str, Any] , _UpperCAmelCase : Tuple , _UpperCAmelCase : int , _UpperCAmelCase : int ) -> Any: '''simple docstring'...
159
_lowerCamelCase : List[Any] = tuple[float, float, float] _lowerCamelCase : Tuple = tuple[float, float, float] def _UpperCAmelCase (UpperCamelCase_ : Pointad , UpperCamelCase_ : Pointad ): '''simple docstring''' _lowerCAmelCase : Tuple = end_pointa[0] - en...
159
1
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
329
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_avai...
241
0
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, re...
18
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normalize, ...
18
1
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import...
220
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_pro...
264
0
SCREAMING_SNAKE_CASE__ : List[Any] = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, i...
339
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import f...
339
1
'''simple docstring''' from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDim...
331
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common impor...
331
1
"""simple docstring""" import os _UpperCamelCase = {"""I""": 1, """V""": 5, """X""": 10, """L""": 50, """C""": 100, """D""": 500, """M""": 1000} def _a ( _snake_case ): """simple docstring""" UpperCAmelCase = 0 UpperCAmelCase = 0 ...
360
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase = { """configuration_roformer""": ["""ROF...
234
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_o...
31
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else:...
31
1
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils ...
365
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
250
0
# Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
176
def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> str: '''simple docstring''' if not isinstance(UpperCamelCase_ , UpperCamelCase_ ): raise ValueError('iterations must be defined as integers' ) if not isinstance(UpperCamelCase_ , UpperCamelCase_ ) or not number >=...
176
1
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import ...
365
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : List[str] = { """configuration_altclip""": [ """ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AltCLIPConf...
338
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
19
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : List[Any] = logging.get_logger(__name__) __lowerCAmelCase : int = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # See a...
88
0
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py lowerCAmelCase_ = '\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {BLEU: a Method for...
116
import os from collections.abc import Iterator def snake_case( __magic_name__ = "." ) -> Iterator[str]: '''simple docstring''' for dir_path, dir_names, filenames in os.walk(__magic_name__ ): lowercase : Tuple = [d for d in dir_na...
116
1
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": SCREAMING_SNAKE_CASE :List[Any] = input('''Enter image url: ''').strip() print(F'''Downloading image from {url} ...''') SCREAMING_SNAKE_CASE :List[str] = BeautifulSou...
159
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
159
1
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import Tokenizer...
358
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __A = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xlm''': ['...
64
0
def _snake_case ( lowerCAmelCase : list ): """simple docstring""" def merge(lowerCAmelCase : list , lowerCAmelCase : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yiel...
18
def _snake_case ( lowerCAmelCase : int ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Tuple = int(lowerCAmelCase ) if decimal in (0, 1): # Exit cases for the recursion return str(lowerCAmelCase ) SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ : Dict ...
18
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_whisper''': ['''WHISPER_PR...
52
'''simple docstring''' from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, rando...
52
1
UpperCAmelCase__ = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_librosa_available, is...
339
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version UpperCAmelCase__ = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize UpperCAmelCase__ =...
339
1
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"""): lowerCamelCase_ = { """linear""": PIL.Image.Resampling.BILINEAR, """bilinear"""...
362
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, O...
256
0
"""simple docstring""" import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowerCamelCase__ ( _lowerCamelCase : Tuple ) -> str: if "model" in orig_key: lowerCamelCase_ = orig_ke...
183
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from u...
220
0
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) A_ :Any = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block''': 2, ...
352
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def A ( a_ = 3 ) -> qiskit.result.counts.Counts: if isinstance(a_ ,a_ ): raise TypeError('number of qubits must be a...
245
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, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dimensi...
329
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def lowerCAmelCase__ ( a__: Tuple , a__: Optional[Any] , a__: Any ) -> List[Any]: '''simple docstring''' _UpperCAmelCase = AutoConfig.from_pretrained(a__ ...
329
1
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel __snake_case :Tuple = False __snake_case :Optional[int] = True __snake_case :List[Any] = False if __name__ == "__mai...
131
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : UpperCamelCase__ : int UpperCamelCase__ : TreeNode | None = None UpperCamelCase__ : TreeNode | None = None __snake_case :Optio...
131
1
import torch from diffusers import StableDiffusionPipeline __lowerCamelCase = """path-to-your-trained-model""" __lowerCamelCase = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") __lowerCamelCase = """A photo of sks dog in a bu...
59
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 SCREAMING_SNAKE_CASE_ ( snake_case__ , snake_case__ ) -> Union...
338
0
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 lowercase_ = logging.get_logger(__name__) low...
282
def _snake_case( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : list[list[int]] ) -> int: '''simple docstring''' def update_area_of_max_square(SCREAMING_SNAKE_CASE__ : int ...
282
1
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig SCREAMING_SNAKE_CASE_:List[Any] = { """facebook/maskformer-swin-base-ad...
116
from manim import * class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def _lowerCAmelCase ( self ): A : Union[str, Any] = Rectangle(height=0.5, width=0.5 ) A : Optional[int] = Rectangle(he...
116
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : List[str] = {'configuration_mra': ['MRA_PRETRAINED_CONFIG_ARCHIVE_MAP',...
354
"""simple docstring""" import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_availabl...
86
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_devic...
95
"""simple docstring""" import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available()...
64
0
from __future__ import annotations def __UpperCamelCase ( _A , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = len(_A ) - 1 while i < j: if nums[i] + nums[j] == target: return [i, j] elif nums[i] + nums[j] < target: ...
167
def __UpperCamelCase ( _A = 4000000 ): lowerCAmelCase_ = [0, 1] lowerCAmelCase_ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 lowerCAmelCase_ = 0 for j ...
167
1
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def A_ ( _lowerCAmelCase ) -> bool: UpperCamelCase : int = int(number**0.5 ) return number == sq * sq def A_ ( _lowerCAmelCase , _lowerCAmelCase , _lowe...
52
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceF...
52
1
import math import flax.linen as nn import jax.numpy as jnp def UpperCAmelCase_ ( _A , _A , _A = 1 , _A = 1 , _A = 1.0e4 , _A = False , _A = 1.0 , ): '''simple docstring''' assert timesteps.ndim == 1, "Timesteps should be a 1d-array" assert embedding...
218
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _SCREAMING_SNAKE_CASE : str = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block''': 2, ...
218
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer a__ : Optional[Any] = {"vocab_file": "vocab.txt", ...
161
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin UpperCAmelCase = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targe...
256
0
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class UpperCAmelCase ( UpperC...
367
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration A__ : str =5_00_00 A__ : Optional[int] =50_00 A__ , A__ : Optional[int] ...
220
0
'''simple docstring''' from __future__ import annotations import bisect def a__ ( lowercase : List[Any], lowercase : List[str], lowercase : Dict = 0, lowercase : Optional[Any] = -1 ) -> int: """simple docstring""" if hi < 0: ...
324
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall...
245
0
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __snake_case ( __lowerCAmelCase ): a__ = ["""image_processor""", """tokenizer"""] a__ = """AutoImageProcessor""" a__ = """AutoToken...
203
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: lowercase__ = None try: import msvcrt except ImportError: lowercase__ = None try: import fcntl except ImportError: lowercase__ = None # Backward compatibility # --------------...
203
1
import re def lowerCamelCase_ ( _a ): """simple docstring""" lowerCAmelCase__ : Optional[Any] = re.compile( R'''^(?:0|94|\+94|0{2}94)''' R'''7(0|1|2|4|5|6|7|8)''' R'''(-| |)''' R'''\d{7}$''' ) return bool(re.search(_a , ...
131
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 transform...
131
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : List[Any] = logging.get_logger(__name__) A__ : List[Any] = { 'SCUT-DLVCLab/lilt-roberta-en-base': ( 'https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/co...
209
"""simple docstring""" def _snake_case ( lowerCamelCase__ : int ) -> int: if not isinstance(lowerCamelCase__ , lowerCamelCase__ ): raise TypeError("only integers accepted as input" ) else: lowerCamelCase_ : str =str(abs...
209
1
'''simple docstring''' from collections.abc import Sequence from queue import Queue class snake_case : """simple docstring""" def __init__( self , UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase=None , UpperCamelCase=None ): ...
55
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_r...
318
0
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): if len(__lowerCAmelCase ) == 0: return array a__ , a__ = min(__lowerCAmelCase ), max(__lowerCAmelCase ) # Compute the variables ...
109
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
109
1
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # see ...
329
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class A__ ( _lowerCamelCase): A_ : Any = ['image_processor', 'tokenizer'] A_ : Optional[Any] = 'AutoImageProcessor' A_ : ...
86
0
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLayer...
350
from bisect import bisect from itertools import accumulate def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): A_ : List[Any] = sorted(zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) , ke...
65
0
"""simple docstring""" def lowercase_ ( _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" if not (isinstance(_UpperCAmelCase , _UpperCAmelCase ) and isinstance(_UpperCAmelCase , _UpperCAmelCase )): raise ValueError('''longest_co...
167
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase : int = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'...
167
1
'''simple docstring''' from __future__ import annotations def UpperCamelCase_( snake_case : int | float | str , snake_case : int | float | str ): '''simple docstring''' if nth_term == "": return [""] snake_case_ = int(snake_...
92
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_canine": ["CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP", "CanineConf...
92
1
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class __snake_case ( a ): U...
51
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase : List[str] = str(bin(UpperCamelCase__ ) ...
263
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase :List[Any] = logging.get_logger(__name__) lowerCAmelCase :int = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-...
359
'''simple docstring''' import math def lowerCamelCase ( lowerCAmelCase : float , lowerCAmelCase : float ): """simple docstring""" return math.pow(lowerCAmelCase , 2 ) - a def lowerCamelCase ( lowerCAmelCase : float ): """simple docstring"...
275
0
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = ...
68
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( __lowercase ): @staticmethod @abstractmethod def __A ( SCREAMING_SNAKE_CASE__ : ArgumentParser ) -> str: raise NotImplementedError() @abstractmethod def __A...
270
0
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE ) ->str: a__: Optional[int] = [False] * len(_SCREAMING_SNAKE_CASE ) a__: int = [-1] * len(_SCREAMING_SNAKE_CASE ) def dfs(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )...
357
"""simple docstring""" 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.util...
203
0
"""simple docstring""" def __lowerCAmelCase ( lowercase : Union[str, Any] ) -> List[str]: """simple docstring""" snake_case : List[str] = len(lowercase ) for i in range(length - 1 ): snake_case : List[str] = i for k in...
203
"""simple docstring""" def __lowerCAmelCase ( lowercase : Union[str, Any] ) -> List[str]: """simple docstring""" snake_case : List[str] = len(lowercase ) for i in range(length - 1 ): snake_case : List[str] = i for k in...
203
1
"""simple docstring""" def _snake_case ( _snake_case : int ): lowerCAmelCase : Optional[Any] = [1] lowerCAmelCase, lowerCAmelCase, lowerCAmelCase : int = 0, 0, 0 lowerCAmelCase : Tuple = ugly_nums[ia] * 2 lowerCAmelCase : Any = ugly...
314
"""simple docstring""" from math import sqrt def _snake_case ( _snake_case : int ): assert isinstance(_snake_case , _snake_case ) and ( number >= 0 ), "'number' must been an int and positive" lowerCAmelCase : Dict = True # 0 and 1 are none...
314
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { "hustvl/yolos-small": "https://huggin...
209
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_comm...
209
1
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) lowerCamelCase__ : Optional[Any] = loggi...
210
import gc import threading import time import psutil import torch class lowerCamelCase_ : '''simple docstring''' def __init__( self : Optional[Any] ): SCREAMING_SNAKE_CASE_ = psutil.Process() SCREAMING_SNAKE_CASE_ = False def ...
210
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A: List[str] = {"configuration_mbart": [...
109
"""simple docstring""" A: Union[str, Any] = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 1_0: "a", 1_1: "b", 1_2: "c", 1_3: "d", 1_4: "e", 1_5: "f", } def _snake_case ( UpperCamelCase ...
109
1
def lowercase_ ( lowerCAmelCase__ : Union[str, Any] , lowerCAmelCase__ : Optional[Any] ): """simple docstring""" return 1 if input_a == input_a else 0 def lowercase_ ( ): """simple docstring""" assert xnor_gate(0 , 0 ) ...
371
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _UpperCamelCase = logging.get_logger(__name__) class _A ( __SCREAMING_SNAKE_CASE ): def __init__( self , *__Uppe...
16
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (snake_case__ : list[int] , snake_case__ : int ): """simple docstring""" _snake_case : List[str] = 0 _snake_case : Optional[int] = len(snake_ca...
64
from manim import * class A ( UpperCAmelCase_ ): def lowercase_ (self : Union[str, Any] ) -> List[str]: """simple docstring""" UpperCAmelCase__ = Rectangle(height=0.5 , width=0.5 ) UpperCAmelCase__ ...
65
0
'''simple docstring''' lowerCamelCase_ = 8.314462 # Unit - J mol-1 K-1 def __lowercase ( __lowercase , __lowercase , __lowercase ) -> float: '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("Invalid inputs. Ent...
353
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attentio...
174
0
import os from math import logaa def _a ( SCREAMING_SNAKE_CASE_ : str = "base_exp.txt" ): __lowerCAmelCase = 0 __lowerCAmelCase = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE_ ) , SCREAMING_SNAK...
92
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def _a ( SCREAMING_SNAKE_CASE_ : Optional[Any] ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , set() ) @pytest.fixture def...
92
1
'''simple docstring''' from __future__ import annotations class A_ : def __init__( self : List[str] , snake_case_ : int ): _UpperCAmelCase = order # a_{0} ... a_{k} _UpperCAmelCase = [1.0] + [0.0] * order # b_{0} ... b...
367
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_t...
156
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { '''configuration_luke''': ['''LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LukeConfig'''], '''tokenization_luke''': ['''LukeTokenizer'''], } try: if not is_torc...
279
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase ( _a, unittest.TestCase ): ...
279
1
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __lowerCamelCase ( snake_case__ ) -> Optional[int]: # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia...
352
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def __lowerCamelCase ( snake_case__ ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE = prime_factors(snake_case__ ) if is_square_free(...
125
0
a_ :Union[str, Any] = "\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggingface/trans...
277
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.uti...
203
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_property from...
356
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.util...
201
0
def UpperCAmelCase_ ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = [1] SCREAMING_SNAKE_CASE__,SCREAMING_SNAKE_CASE__,SCREAMING_SNAKE_CASE__ = 0, 0, 0 SCREAMING_SNAKE_CASE__ = ugly_nums[ia] * 2 SCREAMING_SNAKE_CASE__ = ugly_nums[ia] * 3 ...
314
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : str = { '''vocab_file''': '''vo...
314
1
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters lowercase : Optional[int] = (720, 1280) # Height, Width lowercase : Any = (0.4, 0.6) # if height or width lower than this scale, drop it. lowercase : str ...
285
class __snake_case : def __init__( self ,snake_case ,snake_case=None ,snake_case=None ): '''simple docstring''' lowercase : Tuple = data lowercase : List[Any] = previous lowercase : List[str] = next_...
285
1
from __future__ import annotations import collections import pprint from pathlib import Path def UpperCAmelCase ( lowercase ): """simple docstring""" return "".join(sorted(lowercase ) ) def UpperCAmelCase ( lowercase ): """simple do...
210
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __a : int = logging.get_logger(__name__) __a : str = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.json""", } class _UpperCamelCa...
210
1
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 TFMo...
365
import argparse import os import re import packaging.version UpperCAmelCase__ : List[Any] ='''examples/''' UpperCAmelCase__ : List[str] ={ '''examples''': (re.compile(r'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.comp...
262
0
def a__ ( A_ ): '''simple docstring''' return 10 - x * x def a__ ( A_, A_ ): '''simple docstring''' if equation(A_ ) * equation(A_ ) >= 0: raise ValueError("""Wrong space!""" ) __magic_name__ = ...
88
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from ...
16
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class __snake_case ( unittest.TestCase ): ...
293
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .model...
293
1
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> int: snake_case_ = len(_SCREAMING_SNAKE_CASE ) for _ in range(_SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: ...
347
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase : Dict = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """Mvp...
174
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, requ...
364
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Optional[Any] = { "configuration_wav2vec2": ["WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP...
347
0