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
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 TokenizerTester...
29
def __magic_name__ ( A : str ): '''simple docstring''' a = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def __magic_name__ ( A : str ): '''simple docstring''' ...
107
0
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tup...
371
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( A__ : int | float | str , A__ : int | float | str ): '''simple docstring''' if nth_term == "": return [""] lowerCAmelCase_ : str = i...
89
0
def lowercase_ (A : Optional[Any] , A : Tuple , A : Dict ): snake_case__ : int = len(__lowerCAmelCase ) snake_case__ : Optional[int] = [[0] * n for i in range(__lowerCAmelCase )] for i in range(__lowerCAmelCase ): snake_...
277
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np UpperCAmelCase : Union[str, Any] = re.compile(r"\b(a|an|the)\b", re.UNICODE) UpperCAmelCase : Optional[Any] = None def _SCREAMING_...
136
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Optional[Any] = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransf...
370
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __UpperCamelCase ( ...
6
0
'''simple docstring''' import argparse import json from tqdm import tqdm def UpperCAmelCase_ ( ) -> Union[str, Any]: '''simple docstring''' _UpperCAmelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" ,...
22
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class A ( _UpperCAmelCase ): ...
7
0
'''simple docstring''' from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _A ( ) -> str: _lowercase : List[Any] = { "repo_name": ["test_repo1", "test_repo2", "test_repo3"...
199
'''simple docstring''' from timeit import timeit def _A ( snake_case ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) _lowercase : Union[str, Any] = 0 while number: number &= number - 1 result += 1 ...
199
1
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCAmelCase ( __SCREAMING_SNAKE_CAS...
15
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
15
1
'''simple docstring''' 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 .lo...
370
'''simple docstring''' import os def _lowerCAmelCase ( ) -> List[str]: """simple docstring""" _SCREAMING_SNAKE_CASE =os.path.dirname(os.path.realpath(_UpperCamelCase ) ) _SCREAMING_SNAKE_CASE =os.path.join(_UpperCamelCase , 'triangle.txt' ) w...
114
0
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( lowercase : Any , lowercase : Tuple , lowe...
63
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixi...
89
0
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' for param in module.parameters(): A : Optional[Any] = False ...
311
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowercase : Optional[int] = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/...
311
1
def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' UpperCAm...
65
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup A : str = logging.get_logger(__name__) class __A( a ): def...
6
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, logging, ) logging.set_ve...
369
from math import pi, sqrt, tan def UpperCAmelCase_( a__ ): """simple docstring""" if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def UpperCAmelCase_( a__ , a__ , a__ ): ""...
19
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline lowerCamelCase = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value network 'scale_grad_by_st...
199
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common imp...
199
1
'''simple docstring''' from __future__ import annotations a__ : List[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class UpperCAmelCase__ : ...
360
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class UpperCAmelCase__ : __SCREAMING_SNAKE_CASE = 42...
243
0
"""simple docstring""" def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" A__ = [1] for i in range(2 , __lowerCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < fac...
221
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
114
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor lowercase__ = logging.get_logger(__name__) class A_ ( _snake_case ): '''simple docstring''' def __init__( self : ...
280
'''simple docstring''' def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ ): if b == 0: return 1 if (b % 2) == 0: return actual_power(UpperCAmelCase_ , int(b / 2 ) ) * actual_power(UpperCAmelCase_ , int(b / 2 ) ) else: return a * actual_power(UpperCAmelCase_ , in...
280
1
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def lowercase ( __magic_name__ ): '''simple docstring''' for param in module.parameters(): UpperCAmelCase : Any = False def lowercase ...
311
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : Union[str, Any] = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "fea...
311
1
import json import sys def A ( _UpperCAmelCase : Optional[int] , _UpperCAmelCase : Optional[int] ) -> List[str]: '''simple docstring''' with open(_snake_case , encoding='utf-8' ) as f: _UpperCAmelCase = json.load(_...
352
from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCAmelCase__ = {"tokenization_bertweet": ["BertweetTokenizer"]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys UpperCAmelCase__ = _LazyModule(__name__, globals()["__...
290
0
"""simple docstring""" from collections import deque class _UpperCamelCase : '''simple docstring''' def __init__( self , __a , __a , __a ): __lowerCAmelCase = process_name # process name __lowerCAmelCase = arrival_time # arrival tim...
57
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 HeunDiscreteScheduler from ......
19
0
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import l...
77
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
77
1
'''simple docstring''' import inspect import unittest from transformers import BitConfig 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_backbone_common i...
4
"""simple docstring""" import baseaa def UpperCamelCase ( UpperCAmelCase ) ->bytes: """simple docstring""" return baseaa.baaencode(string.encode("utf-8" ) ) def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" return baseaa.baadecode(UpperCAmelCase ).dec...
243
0
"""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 ) -> int: '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(...
365
"""simple docstring""" def snake_case (A_ :int ): '''simple docstring''' if isinstance(A_ , A_ ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(A_ , A_ ): raise TypeError('\'str\' object cannot be interpreted...
186
0
import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import Dat...
280
from heapq import heappop, heappush import numpy as np def _SCREAMING_SNAKE_CASE ( a , a , a , a , ) -> tuple[float | int, list[tuple[int, int]]]: __A , __A : int = grid.shape __A : Any = [-1, 1, 0, 0] __A...
280
1
lowerCamelCase__ = {str(digit): digit**5 for digit in range(10)} def lowerCAmelCase__ ( a__ ) ->Tuple: '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(a__ ) ) def lowerCAmelCase__ ( ) ->Dict: '''simple docstring''' return sum(...
359
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def lowerCAmelCase__ ( a__ , a__ , a__ , a_...
63
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipel...
17
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky....
290
0
'''simple docstring''' from __future__ import annotations import pandas as pd def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : Union[str, Any] = [0] * no_of_processes lowerCAm...
184
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" def count_of_possible_combinations(UpperCamelCase ) -> int: if target < 0: return 0 if target == 0: ...
184
1
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def a_ ( ): '''simple docstring''' raise RuntimeError('CUDA out of memory.' ...
77
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class UpperCAmelCase_ : def __init__( self , a ) -> List[str]: if isinstance(a ...
77
1
import random class A : """simple docstring""" @staticmethod def snake_case__ ( lowercase_ : str )-> tuple[list[int], list[int]]: '''simple docstring''' A__ = [ord(lowercase_ ) for i in text]...
353
import datasets from .evaluate import evaluate lowercase_ = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016}\n}\n" l...
282
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''YituTech/c...
108
import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ConfigTester from ...te...
186
0
"""simple docstring""" def lowercase__(A ) ->int: """simple docstring""" lowercase__ : Tuple= [1] lowercase__, lowercase__, lowercase__ : int= 0, 0, 0 lowercase__ : List[str]= ugly_nums[ia] * 2 lowerc...
150
"""simple docstring""" from __future__ import annotations def lowercase__(A , A ) ->list[str]: """simple docstring""" if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions >...
150
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionP...
74
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Dict = logging.get_logger(__name__) lowerCAmelCase_ : int = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacod...
63
0
import os import pytest from transformers.dynamic_module_utils import get_imports UpperCamelCase__ = "\nimport os\n" UpperCamelCase__ = "\ndef foo():\n import os\n return False\n" UpperCamelCase__ = "\ndef foo():\n def bar():\n if True:\n import ...
354
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin Up...
143
0
import datasets from .evaluate import evaluate A : Dict = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint arXiv:2103.06...
184
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationT...
184
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase_ = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP"...
14
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_utils import...
14
1
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_c...
31
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _lowerCamelCase : int = False class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): '''simple...
282
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_canine''': [''...
353
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. ...
64
0
"""simple docstring""" from __future__ import annotations def lowerCAmelCase__ ( _UpperCamelCase : int ) -> list[int]: """simple docstring""" snake_case = [True] * limit snake_case = False snake_case = False snake_case ...
150
"""simple docstring""" import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import Padd...
150
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCon...
131
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): return base * power(_UpperCAmelCase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('''Raise base to the power of exponent using recursion...''') __snake_case :List[Any] = int(inp...
131
1
'''simple docstring''' 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 __A ( UpperCamelCase__ , unitt...
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class __snake_case ( _lowerCamelCase ): @staticmethod @abstractmethod def __a ( __UpperCamelCase ) -> Dict: '''simple docstring''' raise NotImplementedEr...
143
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy UpperCAmelCase__ = logging.get...
369
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : List[Any] , __lowerCamelCase : Dict , __lowerCamelCase : Optional[int] , __lowerCamelCase : Tuple ) -> Union[str, Any]: # Return True if there is node that has not iterated. _snake_case = [False]...
40
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : int = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
14
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> "list[int]": """simple docstring""" if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) A__ = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 ...
14
1
a__: List[Any] = { 'meter': 'm', 'kilometer': 'km', 'megametre': 'Mm', 'gigametre': 'Gm', 'terametre': 'Tm', 'petametre': 'Pm', 'exametre': 'Em', 'zettametre': 'Zm', 'yottametre': 'Ym', } # Exponent of the factor(meter) a__: str = { 'm': 0, ...
366
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__: List[Any] = logging.get_logger(__name__) a__: Optional[Any] = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/microsoft/unispeec...
39
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available lowerCamelCase_ : Any = { """configuration_audio_spectrogram_transformer""": [ """AUDIO_SPECTROGRAM_TR...
81
"""simple docstring""" import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with...
64
0
def lowerCAmelCase_ ( UpperCamelCase_ = 1000 ) -> int: UpperCamelCase_ = 2**power UpperCamelCase_ = str(UpperCamelCase__ ) UpperCamelCase_ = list(UpperCamelCase__ ) UpperCamelCase_ = 0 for i in list_num: ...
367
import math def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> List[str]: if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(UpperCamelCase_ ) else: if x == 0...
328
0
from typing import Any class _a : def __init__( self : Optional[int] , _SCREAMING_SNAKE_CASE : Any )-> Tuple: lowerCAmelCase__ : str = data lowerCAmelCase__ : List[str] = None def __repr__( self ...
131
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
131
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
147
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : list ): if len(__lowerCamelCase ) <= 1: return lst lowercase_ :Optional[Any] = 1 while i < len(__lowerCamelCase ): if lst[i - 1] <= lst[i]: i += 1 else: ...
147
1
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Any ) -> int: __lowercase = 1 for i in range(1 , num + 1 ): fact *= i return fact def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Optional[int] ) -> int:...
325
"""simple docstring""" import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def lowercase ( A_ )-> List[Any]: '''simple docstring''' monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_w...
40
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' if ( (cp >= ...
311
'''simple docstring''' from __future__ import annotations def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' A : List[str] = 2 A : Dict = [] while i * i <= n: if n % i: i += 1 else:...
311
1
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 import ConfigTester from ....
82
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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set...
39
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_availa...
132
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger A_ = '''<<<<<<< This should probably be modified because it mentions: ''' A_ ...
132
1
from ...configuration_utils import PretrainedConfig class __lowerCamelCase ( snake_case__): """simple docstring""" UpperCamelCase__ = "bert-generation" def __init__( self , UpperCAmelCase=5_0358 , UpperCAmelCase=1024 ,...
39
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlitea import s...
328
0
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler,...
361
def a_ ( __lowercase : int = 50_000_000 ) -> int: _snake_case = set() _snake_case = int((limit - 24) ** (1 / 2) ) _snake_case = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ...
130
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _a ( unittest.T...
147
from __future__ import annotations from typing import Any class _a : def __init__(self, SCREAMING_SNAKE_CASE_ = 6 ) -> None: UpperCAmelCase_: Node | None = None UpperCAmelCase_: Node | None = None self.create_linked_list(...
147
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowerCamelCase_ ( UpperCamelCase__ : Tuple ) -> Optional[Any]: """simple docstring""" def wrappe...
351
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils imp...
348
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowercase ( __magic_name__ ): '''simple docstring''' if ( (cp >= 0X4E00 and cp <= 0X9FFF) ...
311
'''simple docstring''' def lowercase ( __magic_name__ ): '''simple docstring''' if number > 0: raise ValueError("input must be a negative integer" ) UpperCAmelCase : List[Any] = len(bin(__magic_name__ )[3:] ) UpperCAmelCase...
311
1
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( __A : int = 1_00_00_00 ) -> int: _SCREAMING_SNAKE_CASE = set(range(3 , lowerCamelCase_ , 2 ) ) primes.add(2 ) for p in range(3 , lowerCamelCase_ , 2 ): if p not in primes: continue primes...
356
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' wh...
111
0
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __a (UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Optional[int] = ["""image_processor""", """tokenizer"""] _SCREAMI...
132
"""simple docstring""" from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
132
1
from __future__ import annotations import numpy as np def lowerCamelCase ( a_ ) -> Any: return np.maximum(0 , UpperCAmelCase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
362
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_available(): from ..model...
14
0
import os def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = os.path.dirname(os.path.realpath(lowerCamelCase__ ) ) lowerCamelCase = os.path.join(lowerCamelCase__ , """triangle.txt""" ) with open(lowerCamelCase__ ) as f: lowerCamelCase ...
252
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effic...
130
0
import csv import tweepy # Twitter API credentials lowerCAmelCase_ = '''''' lowerCAmelCase_ = '''''' lowerCAmelCase_ = '''''' lowerCAmelCase_ = '''''' def lowerCamelCase_ ( _UpperCamelCase ) -> None: """simple docstring""" snake_case_ : O...
279
def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring""" if number > 0: raise ValueError('''input must be a negative integer''' ) snake_case_ : List[str] = len(bin(_UpperCamelCase )[3:] ) snake_case_ : str ...
279
1
'''simple docstring''' import os import sys import unittest UpperCamelCase__: Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies impor...
23
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionScheduler from ...utils imp...
348
0
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils...
364
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO ) __magic_n...
138
0
"""simple docstring""" import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, re...
91
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor __UpperCAmelCase : Tuple = logging.get_logger(__name__) class __snake_case ( __lowerCamelCase ): '''simple docstring''' def __i...
111
0
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class SCREAMING_SNAKE_CASE (UpperCAmelCase ): def __i...
367
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availabl...
269
0
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState from...
101
import requests from bsa import BeautifulSoup def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> str: """simple docstring""" A__ = BeautifulSoup(requests.get(lowercase_ , params=lowercase_ ).content , '''html.parser''' ) A__ ...
14
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : Dict = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', 'XCLIPVisionC...
284
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf __SCREAMING_SNAKE_CASE : str = logging.get_logge...
284
1
import os from collections.abc import Iterator def lowerCamelCase_ ( _UpperCamelCase = "." ) -> Iterator[str]: """simple docstring""" for dir_path, dir_names, filenames in os.walk(_UpperCamelCase ): snake_case_ : List[str] = [d for d in dir_names if d !...
279
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common impor...
279
1
'''simple docstring''' import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Con...
368
'''simple docstring''' import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...
345
0
"""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...
77
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipelin...
138
0
'''simple docstring''' import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def _snake_case ( _SCREAMING_SNAKE_CASE : Dataset , _SCREAMING_...
187
'''simple docstring''' from __future__ import annotations import pandas as pd def _snake_case ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : int ) -> list[int]: """si...
187
1
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter...
10
"""simple docstring""" import gc import threading import time import psutil import torch class A__ : '''simple docstring''' def __init__( self: str) -> Optional[Any]: """simple docstring""" __lowerCAmelCase : Optional[Any] ...
269
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : List[Any] = { 'configuration_time_series_transformer': [ 'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimeS...
358
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common imp...
252
0
import os from collections.abc import Iterator def a_ ( lowerCAmelCase_ : str = "." ): for dir_path, dir_names, filenames in os.walk(lowerCAmelCase_ ): __lowerCAmelCase = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] for filename in filenames: if filenam...
284
from __future__ import annotations import math def a_ ( lowerCAmelCase_ : int, lowerCAmelCase_ : int, lowerCAmelCase_ : bool, lowerCAmelCase_ : list[int], lowerCAmelCase_ : float ): if depth < 0: raise ValueError('Depth cannot be less than 0' ) if len(lowerC...
284
1
"""simple docstring""" import math import qiskit def __A ( a_ :int = 1 , a_ :int = 1 , a_ :int = 1) -> qiskit.result.counts.Counts: if ( isinstance(a_ , a_) or isinstance(a_ , a_) or isinstance(a_ , a_) ...
354
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets A = datasets.logging.get_logger(__name__) A = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
188
0
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.test_...
343
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__snake_case ) class _snake_case ( __snake_case ): '''simple docstring''' A__ : str ...
345
0
"""simple docstring""" # using dfs for finding eulerian path traversal def UpperCamelCase ( _A, _A, _A, _A=None ): """simple docstring""" __magic_name__ : Dict = (path or []) + [u] for v in graph[u]: if visited_edge[u][v] is...
367
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before t...
138
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor lowercase__ : List[str] = logging.get_logger(__name__) class UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' def __init__( ...
187
import argparse import collections import json import os import re import string import sys import numpy as np lowercase__ : Tuple = re.compile(R"\b(a|an|the)\b", re.UNICODE) lowercase__ : Optional[int] = None def lowerCamelCase__ ( ): ...
187
1
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A (unittest.TestCase ): ...
276
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask ...
276
1
import numpy as np from transformers import Pipeline def lowerCamelCase_ ( UpperCamelCase__ : List[Any] ) -> Any: """simple docstring""" __lowerCamelCase = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase_...
90
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : List[str] = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", "XCLIPVisionConfig...
252
0
import colorsys from PIL import Image # type: ignore def lowerCAmelCase_ ( __UpperCAmelCase: float , __UpperCAmelCase: float , __UpperCAmelCase: int ) -> float: UpperCamelCase__ : Dict = x UpperCamelCase__ : Dict ...
247
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO, ) UpperCAmelCase_ = ...
247
1
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int = 1000000 ) -> Optional[Any]: __lowercase = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , ...
325
from __future__ import annotations def UpperCAmelCase__ ( _A : float , _A : float , _A : float , ): '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values'...
188
0
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> ...
360
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = '▁' _UpperCAmelCase = {'vocab_file': 'spiece.model'} _UpperCAmelCase = ...
328
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import BitConfig, ...
36
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRobert...
138
0
import numpy as np def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase = 1e-12, lowerCamelCase = 100, ): assert np.shape(lowerCamelCase )[0] == np.shape(lowerCamelCase )[1] # Ensure proper dimensionality. assert np.shape(lowerCamelCase )[0] == np.shape...
364
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import...
158
0
'''simple docstring''' import argparse import os import re import packaging.version A__: Optional[Any] = '''examples/''' A__: Optional[Any] = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version...
276
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available A__: str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except Optional...
276
1
import functools from typing import Any def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> bool: # Validation if not isinstance(UpperCamelCase_ , UpperCamelCase_ ) or len(UpperCamelCase_ ) == 0: raise ValueError("the string sho...
360
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = '▁' _UpperCAmelCase = {'vocab_file': 'spiece.model'} _UpperCAmelCase = ...
328
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
"""simple docstring""" import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPI...
247
1
'''simple docstring''' from __future__ import annotations from statistics import mean def _lowerCAmelCase ( _UpperCamelCase : list[int] , _UpperCamelCase : list[int] , _UpperCamelCase : int ) -> list[int]: """simple docstring""" _SCREAMING_S...
114
'''simple docstring''' import os import sys import unittest lowerCamelCase : Optional[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files...
114
1
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowercase = "\\n\n" lowercase = "\nPerplexity (PPL) is one of the most common metrics for evaluating language...
178
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
328
0
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from tr...
366
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subprocess_async, g...
180
0
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __lowerCAmelCase ( unittest.TestCase ): """simple docstring"...
159
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def __a(SCREAMING_SNAKE_CASE_ ...
158
0
"""simple docstring""" import math import sys def lowerCAmelCase (__UpperCamelCase : int ): """simple docstring""" if number != int(__UpperCamelCase ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueE...
85
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin __lowercase = get_tests_dir('''fix...
85
1
"""simple docstring""" import requests lowerCAmelCase__ : Optional[int] = 'YOUR API KEY' def a_ ( lowerCamelCase , lowerCamelCase = giphy_api_key ): UpperCAmelCase__ = '+'.join(query.split() ) UpperCAmelCase__ = f'''https://a...
98
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
328
0
"""simple docstring""" import torch from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer from .base import PipelineTool class _lowerCamelCase ( a_ ): _lowerCamelCase :Dict = "facebook/bart-large-mnli" _lowerCamelCase :Union[str, Any] = ( ...
370
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.sp...
212
0
import random class a : """simple docstring""" @staticmethod def UpperCAmelCase ( __lowercase : str ) -> tuple[list[int], list[int]]: __UpperCAmelCase : Union[str, Any] = [ord(__lowercase ) for i in text] ...
114
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class a ( lowercase__ ): """simple docstring""" a : List[str] = 'MCTCTFeatureExtractor' a : str = 'AutoTokenizer' def __init...
114
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
304
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from ...
304
1
'''simple docstring''' import qiskit def snake_case_ ( lowerCAmelCase_ = 2 )-> qiskit.result.counts.Counts: '''simple docstring''' _UpperCAmelCase : List[str] = qubits # Using Aer's simulator _UpperCAmelCase : str = qiskit.Aer.get...
215
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): """simple docstring""" lowerCamelCase :Tuple = JukeboxTokenizer lowerCamelCase :str = { '''artist...
180
0
'''simple docstring''' def a ( lowerCamelCase__ , lowerCamelCase__ ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) A_ : Optional[Any] = str(bin(lowerCamelCase__ ) )[2:] # remove the ...
135
'''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...
135
1
'''simple docstring''' # This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def UpperCamelCase_( snake_case ...
85
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
85
1
import argparse import os import re import packaging.version lowerCAmelCase : Optional[int] = """examples/""" lowerCAmelCase : int = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
366
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase : Optional[int] = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} try:...
127
0