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""" from __future__ import annotations import math from collections.abc import Callable def lowercase__( __SCREAMING_SNAKE_CASE : Callable[[int | float], int | float] , __SCREAMING_SNAKE_CASE : int | float , __SCREAMING_SNAKE_CASE : int | ...
213
"""simple docstring""" __SCREAMING_SNAKE_CASE =[ "DownloadConfig", "DownloadManager", "DownloadMode", "StreamingDownloadManager", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloa...
213
1
from collections import defaultdict def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> bool: """simple docstring""" _snake_case = first_str.lower().strip() _snake_case = second_str.lower().strip() # Remove whitespace _snake_case = first_s...
362
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, Pi...
278
0
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL A : Optional[int] = version.parse(version.parse(torch.__version__).base_version) < version.parse('1.11') def __lowerCAmelCase ( a__ , a__ ...
6
'''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 :Tuple = 1.0_5_4_5_7_1_8_1_7E-3_4 # unit of ℏ : J * s lowerCAmelCase :Union[str, Any] = 3E8 # unit ...
331
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils ...
370
import logging from transformers import PretrainedConfig __SCREAMING_SNAKE_CASE : Any = logging.getLogger(__name__) __SCREAMING_SNAKE_CASE : int = { 'bertabs-finetuned-cnndm': 'https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/mai...
284
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "BAAI/AltCLIP": "https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json", # See all AltC...
66
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration...
66
1
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : int , __lowerCamelCase : int ): '''simple docstring''' return x if y == 0 else greatest_common_divisor(UpperCAmelCase__ , x % y ) def lowerCamelCase__ ( __lowerCamelCase : ...
371
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_a...
242
0
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class a_ ( snake_case_ ): '''simple docstring''' UpperCamelCase = '''EncodecFeatureExtractor''' UpperCamelCase = ('''...
58
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging UpperCAmelCase : in...
95
0
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not...
62
0
"""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 _UpperCAmelCase (...
292
"""simple docstring""" def A__ ( UpperCamelCase , UpperCamelCase = False ): if not isinstance(UpperCamelCase , UpperCamelCase ): A = F"Expected string as input, found {type(UpperCamelCase )}" raise ValueError(UpperCamelCase ) ...
292
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 _snake_case : Optional[Any] = logging.get_logger(__name__) _snake_case : List[str] =...
362
from __future__ import annotations _snake_case : Union[str, Any] = [] def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): for i in range(len(__lowerCamelCase ) ): if board[row][i] == 1: ...
134
0
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...
48
import colorsys from PIL import Image # type: ignore def _SCREAMING_SNAKE_CASE ( a , a , a ) -> float: __A : List[str] = x __A : str = y for step in range(a ): # noqa: B007 __A : Union[str, Any] = a * ...
280
0
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transf...
370
__UpperCamelCase : Dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def __A ( ) -> None: a = input("""Enter message: """ ) a = input("""Enter key [alphanumeric]: """ ) a = input("""Encrypt/Decrypt [e/d]: """ ) if mode.lower().startswit...
347
0
"""simple docstring""" import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exis...
217
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltF...
41
0
'''simple docstring''' from __future__ import annotations def A__ ( UpperCAmelCase_ , UpperCAmelCase_ ): # Checks if the entire collection has been sorted if len(UpperCAmelCase_ ) <= 1 or n <= 1: return insert_next(UpperCAmelCase_ , n - 1 ) rec_...
236
'''simple docstring''' import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def A__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ): # Initialise...
236
1
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __A : Tuple = logging.get_logger(__name__) def __UpperCamelCase ( _A : Optional[Any] , _A : List[str] ) ->Dict: """simple docstrin...
154
from __future__ import annotations import math def __UpperCamelCase ( _A : int , _A : int , _A : bool , _A : list[int] , _A : float ) ->int: """simple docstring""" if depth < 0: raise ValueError("""Depth cannot be less than 0""" ) ...
154
1
"""simple docstring""" import argparse import struct import unittest class lowerCamelCase__ : '''simple docstring''' def __init__( self , __UpperCAmelCase ) -> None: _lowerCAmelCase =data # Initialize hash values _lowerCAmelC...
341
"""simple docstring""" import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common...
341
1
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def snake_case ( *snake_case__ :Optional[Any]) -> Any: if not isinstance(_A , _A): _A = list(_A) for i in range(len(_A)): ...
180
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _A = '''scheduler_config.json''' class A ( __UpperCAmelCase ): __snake_case = 1 __snake_case = 2 ...
278
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common...
357
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCAmelCase_( metaclass=SCREAMING_SNAKE_CASE_ ): '''simple docstring''' __lowercase : int = ['''sentencepiece'''] def __init__( self ,*__UpperCAmelCase ,**__UpperCAmelCase ...
184
0
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_lo...
99
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( 'kwargs, expected', [ ({'num_shards': 0, 'max_num_jobs': 1}, []), ({'num_shards': 10, 'max_num_jobs': 1}, [range(10 )]), ({'num_shards': ...
284
0
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase ): if length <= 0 or not isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise ValueError("""Length must be a positive integer.""" ) return [n * (2 * n - 1) for n in range(__UpperCAmelCase )] ...
336
"""simple docstring""" import cva import numpy as np class UpperCamelCase : """simple docstring""" def __init__( self ,UpperCAmelCase_ ,UpperCAmelCase_ ): if k in (0.04, 0.06): _lowercase : Optional[Any] = k _lowercase : Option...
336
1
from typing import List import numpy as np def UpperCAmelCase ( a_ ) -> int: """simple docstring""" __A = {key: len(a_ ) for key, value in gen_kwargs.items() if isinstance(a_ , a_ )} if len(set(lists_lengths.values() ) ) > 1: raise RuntimeError...
15
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowercase_ ( __UpperCAmelCase ) ->...
242
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase ) class a ( UpperCAmelCase ): _lowercase = field(default="image-classification" ...
352
from __future__ import annotations from random import choice def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: Any ) -> Optional[int]: return choice(lowerCAmelCase ) def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: list[int] , lowerCAmelCase: int ) -> int: _...
189
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
22
from __future__ import annotations import math class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ ) -> None: __UpperCamelCase =size # approximate the overall size of segment tree with given value __UpperCame...
62
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
147
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/license...
147
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase : Dict ={ 'configuration_albert': ['ALBERT_PRETR...
9
'''simple docstring''' import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __snake_case : Tuple = { '<': operator.lt, '<=': operator.le, '==': operator.eq, '!=': operator.ne, '>=': operator.ge, '>': operato...
134
0
'''simple docstring''' import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast __SCREAMING_SNAKE_CASE :List[str] = datasets.utils.logging.get_logger(__name__) ...
156
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer __SCREAMING_SNAKE_CASE :List[str] = logging.g...
156
1
'''simple docstring''' a__ : int = { 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 _lowercase ( ...
349
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ....
347
0
"""simple docstring""" import baseaa def a__ ( A__ ): return baseaa.baaencode(string.encode('utf-8' ) ) def a__ ( A__ ): return baseaa.baadecode(A__ ).decode('utf-8' ) if __name__ == "__main__": lowerCAmelCase...
364
import math import unittest def a__ ( A__ ): assert isinstance(A__, A__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3...
162
0
from __future__ import annotations class __lowerCAmelCase : def __init__( self: Union[str, Any] , _lowerCAmelCase: int ): lowercase :Optional[int] = data lowercase :Node | None = None lowercase :Node | None = None ...
236
from typing import Union import fire import torch from tqdm import tqdm def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = "cpu", lowerCamelCase = None ): lowercase :Optional[Any] = torch.load(lowerCamelCase, map_location=lowerCamelCase ) for k, v in tqdm(state_dict.items...
236
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( snake_case : int ) -> int: """simple docstring""" if n == 1 or not isinstance(snake_case , snake_case ): return 0 elif n == 2: return 1 else: a : Any ...
363
'''simple docstring''' import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : str = logging.get_logger(__name__) UpperCamelCase : List[str] = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/da...
345
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, FlaxT...
101
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_info()...
302
0
import torch from torch import nn class __snake_case ( nn.Module): def __init__( self : List[Any] , __lowerCAmelCase : Optional[Any] , __lowerCAmelCase : Optional[int] , __lowerCAmelCase : List[str] , __lowerCAmelCase : int , _...
371
"""simple docstring""" import math def snake_case_ ( A_ : int ): '''simple docstring''' return math.sqrt(A_ ) * math.sqrt(A_ ) == num def snake_case_ ( A_ : int ): '''simple docstring''' _lowerCamelCase : Dict ...
175
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.f...
47
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from...
184
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, ) _A : int ={'''configuration_vit''': ['''VIT_PRETRAINED_CONFI...
359
'''simple docstring''' from math import asin, atan, cos, radians, sin, sqrt, tan _A : List[str] =637_8137.0 _A : Dict =635_6752.31_4245 _A : int =6_378_137 def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ...
129
0
def a__ ( UpperCAmelCase : int ) -> list[int]: if length <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(UpperCAmelCase )] if __name__ == "__main__": print(hexa...
336
from __future__ import annotations def a__ ( UpperCAmelCase : list[list[int]] ) -> bool: UpperCAmelCase : Union[str, Any] = len(UpperCAmelCase ) # We need to create solution object to save path. UpperCAmelCase : int = [[0 for _ in range(UpperCAmelCase )] fo...
336
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, ) UpperCamelCase : Any = { """configuration_roformer""": ["""...
345
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig UpperCamelCase : Optional[Any] = logging.getLogger(__name__) class UpperCamelCase ( a_ ): """simple docstring""" A : Tuple = "masked_bert" ...
345
1
"""simple docstring""" import requests A_ = '''YOUR API KEY''' def UpperCAmelCase__ (snake_case__ : str , snake_case__ : str = giphy_api_key ): """simple docstring""" _snake_case : List[Any] = """+""".join(query.split() ) _...
64
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, ...
189
0
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tens...
82
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_to...
82
1
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
147
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, ra...
147
1
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
356
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME __UpperCamelCase : int = ['''small''', '''medium''', '''large'''] __UpperCamelCase : str = '''lm_head.decoder.weight''' __UpperCamelCase : Dict = '''lm_hea...
309
0
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_co...
156
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_ava...
156
1
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _lowercase : Tuple = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'a...
86
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
86
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device UpperCAmelCase = False class UpperCAmelCase_ ( unittest.Tes...
256
'''simple docstring''' from __future__ import annotations class A__ : def __init__( self , UpperCamelCase__=None ) -> Any: '''simple docstring''' A_ = data A_ = None def __repr__( self ) -> List[str]:...
162
0
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" __UpperCamelCase : str = 0 __UpperCamelCase : Dict = len(_lowerCAmelCase ) - 1 while i < j: i...
355
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE_:Any = """src/diffusers""" # Matches is_xxx_available() SCREAMING_SNAKE_CASE_:Optional[Any] = re.com...
115
0
def A ( a_ ) -> int: if not isinstance(a_ ,a_ ): raise ValueError('multiplicative_persistence() only accepts integral values' ) if num < 0: raise ValueError('multiplicative_persistence() does not accept negative values' ) ...
71
'''simple docstring''' class A__ : def __init__( self :List[str] ) -> List[Any]: '''simple docstring''' _a : Tuple =0 _a : Any =0 _a : int ={} ...
276
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowercase : Optional[int] = logging....
368
'''simple docstring''' 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...
91
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
62
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 a_ = False try: a_ = _is_package_available('goog...
175
0
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig lowerCamelCase_ : List[Any] = logging.get_logger(__name__) class a__ : def __init__(...
366
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.util...
197
0
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np __snake_case =typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 __snake_case =typing.Union[np.floataa, int, float] # noqa: UP...
4
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowerCAmelCase__ ( lowerCamelCase_ : Optional[Any]): # picklable for multiprocessi...
129
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ (unittest.TestCase ): '''...
351
"""simple docstring""" 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 ...
23
0
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''': ['''ROFORMER_PRETRAINED_CONFIG_ARCHIVE...
345
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _snake_case ( __snake_case , unittest.TestCase ): '''simple docstring''' A...
345
1
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) ...
89
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A : List[str] = ...
89
1
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _UpperCAmelCase ( ): """simpl...
82
A__ = [0, 2, 4, 6, 8] A__ = [1, 3, 5, 7, 9] def _UpperCAmelCase ( snake_case , snake_case , snake_case , snake_case ): """simple docstring""" if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return 0 ...
82
1
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgument...
367
def snake_case (UpperCAmelCase__ ) -> int: assert isinstance(UpperCAmelCase__ , UpperCAmelCase__ ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: UpperCamelCase_: List[Any] = F'''The input value of [n={number}]...
292
0
'''simple docstring''' import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow _lowerCamelCase : Dict = logging.getLogger() @unitte...
28
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
0
def SCREAMING_SNAKE_CASE_ ( __A : list ) -> list: """simple docstring""" a_ : Optional[int] = len(_UpperCamelCase ) for _ in range(_UpperCamelCase ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[...
359
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP...
120
0
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {"""vocab_file""":...
86
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFM...
86
1
from __future__ import annotations import math def _lowercase ( UpperCamelCase_ ) -> list[int]: '''simple docstring''' if num <= 0: SCREAMING_SNAKE_CASE__ = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(UpperCamelCase...
358
from __future__ import annotations from statistics import mean def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> list[int]: '''simple docstring''' SCREAMING_SNAKE_CASE__ = [0] * no_of_processes SCREAMING_SNAKE_CASE__ ...
169
0
"""simple docstring""" def lowercase_ ( _lowerCamelCase: float , _lowerCamelCase: float , _lowerCamelCase: int ) -> float: '''simple docstring''' if principal <= 0: raise Exception("Principal borrowed must be > 0" ) if rate_per...
135
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, Im...
115
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ...
366
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" if len(_SCREAMING_SNAKE_CASE ) < 2: return collection def circle_sort_util(_SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE ...
187
0
"""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, L...
60
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, ...
91
0
"""simple docstring""" import numpy as np lowerCamelCase_ : Union[str, Any] = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """...
215
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar lowerCamelCase_ : List[Any] = TypeVar("""T""") class __A ( Generic[T] ): """simple docstring""" def __init__( self , __A ...
215
1
"""simple docstring""" import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def __a ( __l...
61
"""simple docstring""" from scipy.stats import pearsonr import datasets __lowerCAmelCase : List[Any] =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calcula...
197
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils impo...
198
def UpperCamelCase ( _A : str , _A : str )-> str: """simple docstring""" A__ = len(_A ) A__ = len(_A ) A__ = ( first_str_length if first_str_length > second_str_length else second_str_length ...
198
1
import os import numpy import onnx def lowerCamelCase__ ( a__ : str , a__ : Optional[Any] ) -> int: UpperCamelCase_ = a.name UpperCamelCase_ = b.name UpperCamelCase_ = '''''' UpperCamelCase_ = '''''' ...
122
'''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 SCREAMING_S...
23
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version UpperCAmelCase_ : Dict = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize UpperC...
198
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCamelCase ( _A : List[Any] , _A : List[str]=7 )-> Optional[Any]: """simple docstring""" A__ = None if token is ...
198
1
'''simple docstring''' import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from...
89
'''simple docstring''' def __lowerCamelCase ( ) -> Tuple: for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def __lowerCamelCase ( lowerCAmelCase_ ) -> List[Any]: _a : Any = 1 _a : Tuple = 2 while i * i...
89
1
def lowercase_ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ): """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def lowercase_ ( ): """simple docstring""" assert nand_gate(0 , 0 ) == 1 asse...
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''' def a ( __a ) -> Any: '''simple docstring''' UpperCamelCase__ :Any = 1 UpperCamelCase__ :Optional[int] = 2 while i * i <= n: UpperCamelCase__ :Optional[Any] = 0 while n % i == 0: ...
97
"""simple docstring""" _snake_case : Optional[int] = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager impor...
292
0
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTest...
354
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): while b: __SCREAMING_SNAKE_CASE ,__SCREAMING_SNAKE_CASE = b, a % b return a def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): return a if b == 0 else euclidean_gcd_r...
255
0
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot fro...
28
'''simple docstring''' import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecu...
120
0
_lowerCamelCase : List[Any] = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''': '''flax>=0.4.1'...
191
class lowerCamelCase : """simple docstring""" def __init__( self : int, _UpperCAmelCase : Dict, _UpperCAmelCase : str ) -> Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CAS...
191
1
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput __A = "scheduler_config.json" class lo...
148
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_bas...
169
0
"""simple docstring""" from __future__ import annotations from random import choice def snake_case (A_ :Union[str, Any] ): '''simple docstring''' return choice(A_ ) def snake_case (A_ :list[int] , A_ :int ): '''simple docstring''' a ...
186
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def snake_case (A_ :np.ndarray , A_ :np.ndarray ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(A_ , ...
186
1
'''simple docstring''' 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,...
34
from __future__ import annotations lowercase__ : str = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowerCamelCase__ ( _A , _A , _A , _A , _A , ): '''simple docstring''' snake_case_...
187
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __A ( a , a , ...
262
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
1
'''simple docstring''' from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import * ...
215
'''simple docstring''' # using dfs for finding eulerian path traversal def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=None )-> List[str]: '''simple docstring''' _UpperCAmelCase : Any = (path or...
215
1
def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> bool: """simple docstring""" a = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
330
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> List[str]: """simple docstring""" monkeypatch.setattr('''datasets.utils.deprecation_utils._emitted_deprecation_warning...
330
1
'''simple docstring''' from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def __UpperCamelCase ( UpperCAmelCase ): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.config ...
198
'''simple docstring''' from __future__ import annotations from random import random class UpperCAmelCase : '''simple docstring''' def __init__( self , __lowerCAmelCase = None ) -> str: lowercase__ : Any = value lowercase__ : Union[str, Any] = ...
198
1
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( '''kwargs, expected''' , [ ({'''num_shards''': 0, '''max_num_jobs''': 1}, []), ({'''num_shards''': 10, '''max_num_jobs''': 1}, [range(10 )...
167
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class A ( __UpperCAmelCase ): __snake_case = ['i...
167
1
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ): if mass < 0: raise ValueError('''The mass of a body cannot be negative''' ) return 0.5 * mass * abs(UpperCAmelCase ) * abs(UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testm...
198
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __a: Optional[int] = 4 __a: Optional[Any] = 3 class UpperCAmelCase (...
198
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCamelCase_ = { '''configuration_perceiver''': ['''PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PerceiverCo...
34
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_ = logging.get_logger(__name__) lowerCamelCase_ = { '''google/mobilenet...
34
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", } ...
59
"""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
"""simple docstring""" UpperCAmelCase_ : int = """ # 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/transf...
318
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-4...
318
1
def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> int: lowercase , lowercase : Union[str, Any] = len(SCREAMING_SNAKE_CASE__ ), len(grid[0] ) if ( min(SCREAMING_SNAKE_CAS...
20
"""simple docstring""" def lowercase__ ( _UpperCAmelCase ) -> None: '''simple docstring''' lowercase : Union[str, Any] = generate_pascal_triangle(_UpperCAmelCase ) for row_idx in range(_UpperCAmelCase ): # Print left spaces ...
255
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2Config''', ''...
358
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( lowercase ):...
133
0
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import dedup...
191
"""simple docstring""" def __lowerCamelCase ( a_ : Union[str, Any] ) -> Optional[int]: __SCREAMING_SNAKE_CASE :List[str] = 1 __SCREAMING_SNAKE_CASE :Dict = 2 while i * i <= n: __SCREAMING_SNAKE_CASE :Tuple = 0 ...
191
1
def _A ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" return x if y == 0 else greatest_common_divisor(SCREAMING_SNAKE_CASE , x % y ) def _A ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE ...
148
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def _A ( SCREAMING_SNAKE_CASE : Optional[int] , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : Tuple ): """simple docstring""" a__ : List[Any] ={ "...
148
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): A_ : Optional[Any] = {} A_ : str = job['''started_at'''] A_ : Optional[Any] = job['''completed...
186
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available(): ...
186
1
"""simple docstring""" import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowerCamelCase__ ( SCREAMING_SNAKE_C...
362
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase =logging.get_logger(__name__) UpperCAmelCase ={ "distilbert-base-unca...
77
0
# 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 be considered # since t...
262
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class snake_case__( unittest.TestCase ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Tuple = JukeboxTokenizer SCREAMING_SNAKE_CASE__ ...
262
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A_ : int = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """S...
349
'''simple docstring''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowercase ( _lowerCamelCase ): """simple docstring""" de...
349
1
def a__ ( _UpperCamelCase : int ): __lowerCamelCase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
330
from __future__ import annotations from typing import Generic, TypeVar a_ = TypeVar("""T""") class __lowerCAmelCase ( Generic[T] ): def __init__( self , __UpperCAmelCase ): '''simple docstring''' __lowerCamelCase = data __lowerCamelCase = self ...
330
1
from __future__ import annotations def __lowerCamelCase ( _lowercase , _lowercase ) -> list[int]: UpperCAmelCase : Dict = 0 UpperCAmelCase : Union[str, Any] = len(_lowercase ) - 1 while i < j: if nums[i] + nums[j] == targ...
355
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : List[Any] = { """configuration_m2m_100""": ["""M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP""", """M2M100Config""", """M2M100On...
338
0
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowercase_ ( _UpperCAmelCase , _UpperCAmelCase=1 ): """simple docstring""" if n_shave_prefix_segments >= 0: ...
167
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test...
167
1
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoMod...
79
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets a : Tuple = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "...
79
1
'''simple docstring''' 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 OptionalDependencyNot...
34
'''simple docstring''' from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_u...
34
1
'''simple docstring''' UpperCamelCase__ = ''' # 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 ''' UpperCamelCase_...
358
'''simple docstring''' import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, B...
299
0
from math import factorial, pi def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 30 ) -> float: if not isinstance(SCREAMING_SNAKE_CASE__ , (int, float) ): raise ValueError("""maclaurin_sin() requires either an int or float for theta""" ) ...
20
"""simple docstring""" from scipy.stats import spearmanr import datasets a = ''' The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive correlati...
315
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[int] = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { """microsoft/trocr-base-handwritten""": ( """https://huggingface.co/microsoft/troc...
231
from __future__ import annotations from typing import Any class UpperCamelCase_ : '''simple docstring''' def __init__( self : str , UpperCAmelCase__ : int , UpperCAmelCase__ : int , UpperCAmelCase__ : float = 0) ->None: '''simple d...
231
1