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
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = { '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if not is_torch_available(): raise OptionalDependencyNotA...
122
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Con...
201
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN,...
364
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeatur...
288
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A : Union[str, Any] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
260
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __a = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerC...
66
0
import datasets from .evaluate import evaluate __a = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } ''' __a = ''' ...
173
from __future__ import annotations from math import ceil, floor, sqrt def __lowercase ( _UpperCamelCase = 2000000 ) ->int: """simple docstring""" lowercase : list[int] = [0] lowercase : int for idx in range(1, ceil(sqrt(target * 2 ...
173
1
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
101
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def a ( __a ) -> int: '''simple docstring''' for param in module.parameters(): UpperCamelCase__ :Dict = False def a ( ) -> Union[str, Any]: ...
97
0
"""simple docstring""" import argparse import importlib from pathlib import Path # Test all the extensions added in the setup __lowercase = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cud...
359
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : int = 1_0_0_0 ): """simple docstring""" __UpperCamelCase =-1 __UpperCamelCase =0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c ...
85
0
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
196
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils imp...
99
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Optional[int] = { """sayakpaul/vit-msn-base""": """https://huggin...
369
"""simple docstring""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) lowerCAmel...
168
0
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) UpperCamelCase__ = pytest.mark.integration @pyt...
181
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils impor...
181
1
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require...
305
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def a__ ( __UpperCamelCase ): return x + 2 class lowerCamelCase (unittest.TestCase ): """simple docstring""" def __A ( self : ...
305
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ), # See all TrOCR models at...
36
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=_UpperCAmelCase ): """simple docstring""" __a : Dict = ['''keras_nlp'''] def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ ) -> Tuple: '''si...
210
0
import warnings from functools import wraps from typing import Callable def UpperCAmelCase_ ( __UpperCAmelCase : Callable ) -> Callable: @wraps(__UpperCAmelCase ) def _inner_fn(*__UpperCAmelCase : str , **__UpperCAmelCase : List[Any] ...
353
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import tor...
210
0
import qiskit def lowerCamelCase__ ( a__ : int , a__ : int ) -> qiskit.result.counts.Counts: UpperCamelCase_ = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register UpperCamelCase_ = qiskit.Q...
122
from __future__ import annotations def lowerCamelCase__ ( a__ : int | float | str , a__ : int | float | str ) -> list[str]: if nth_term == "": return [""] UpperCamelCase_ = int(a__ ) UpperCamelCase_ = int(a__ ) U...
122
1
'''simple docstring''' import inspect import unittest from transformers import MobileNetVaConfig 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_common i...
242
'''simple docstring''' from string import ascii_uppercase lowercase ={str(ord(c) - 55): c for c in ascii_uppercase} def lowerCamelCase__ ( __lowerCamelCase : int , __lowerCamelCase : int ): '''simple docstring''' if isinstance(__lowerCamelCase , __lo...
242
1
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation ...
85
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor __lowerCAmelCase : List[Any] = logging.get_logger(__name__) class snake_case__ (_UpperCamelCase ): """simple docstring""" def __init__( self : Union[str, Any]...
107
0
"""simple docstring""" import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState f...
365
"""simple docstring""" import unittest from transformers import BertGenerationConfig, 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_modelin...
321
0
'''simple docstring''' 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 impor...
125
"""simple docstring""" def lowercase ( _snake_case : int , _snake_case : int ) ->str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __snake_case : Tuple = str(bin(_snake_case ) ...
102
0
'''simple docstring''' def UpperCamelCase ( a ) -> list: '''simple docstring''' if len(a ) <= 1: return [tuple(a )] __magic_name__ = [] def generate(a , a ): __magic_name__ = [0] * n res.append(tu...
98
'''simple docstring''' 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_extractio...
98
1
"""simple docstring""" from collections.abc import Callable def _snake_case ( _snake_case : Callable[[float], float] , _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' _A = a _A ...
315
import string def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: str ) -> None: '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): A__ = "" for symbol in message: if symbol in string.ascii_uppercase: ...
68
0
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE_ ( __a ): """simple docstring""" __lowercase : Optional[int] = ['''image_processor''', '''tokenizer'''] ...
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
from __future__ import annotations import queue class __snake_case : def __init__( self : Dict , _snake_case : Optional[int]): """simple docstring""" UpperCAmelCase_ = data UpperCAmelCase_ ...
51
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ ...
288
0
'''simple docstring''' import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transfor...
229
'''simple docstring''' import os def A (): with open(os.path.dirname(__lowerCamelCase ) + """/grid.txt""" ) as f: _lowerCAmelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(__lowerCamelCase ) for x in f.readline().split()] ) ...
229
1
"""simple docstring""" def __magic_name__ ( lowercase ): SCREAMING_SNAKE_CASE_: Tuple =0 # if input_string is "aba" than new_input_string become "a|b|a" SCREAMING_SNAKE_CASE_: str ="""""" SCREAMING_SNAKE_CASE_: Optional[int] ="""""" # append eac...
173
"""simple docstring""" def __magic_name__ ( lowercase , lowercase ): SCREAMING_SNAKE_CASE_: Union[str, Any] =int(lowercase ) # Initialize Result SCREAMING_SNAKE_CASE_: str =[] # Traverse through all denomination for denomination in reversed(l...
173
1
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm import ...
63
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {''...
63
1
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common...
51
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : Optional[Any...
85
0
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem _lowercase : str = importlib.util.find_spec("s3fs") is not None ...
264
'''simple docstring''' import qiskit def snake_case_ ( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): """simple docstring""" lowercase_ : List[Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Cre...
264
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform fr...
81
'''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_retribert import RetriBertTokenizer a_ : str = ...
168
0
"""simple docstring""" import math import random from typing import Any from .hill_climbing import SearchProblem def __a ( __lowerCamelCase, __lowerCamelCase = True, __lowerCamelCase = math.inf, __lowerCamelCase = -math.inf, __lowerCamelCase = math.inf, __lowerCamelCase = -math.inf, __lowe...
363
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A_ (unittest.TestCase ): '''simple docstring''' def Upp...
23
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class...
305
# 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 require...
305
1
'''simple docstring''' lowerCAmelCase__ : int = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", ...
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowerCAmelCase__ = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False) parser.add_...
108
import csv import tweepy # Twitter API credentials __a : Union[str, Any] = """""" __a : Union[str, Any] = """""" __a : Union[str, Any] = """""" __a : List[Any] = """""" def UpperCAmelCase ( lowercase ): """simple docstring""" __l...
210
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=__lowerCamelCase ) class a ( __lowerCamelCase ): __lowerCAmelCase : str =...
44
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ...
44
1
"""simple docstring""" def lowercase_ ( __UpperCAmelCase ) -> bool: if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): lowerCAmelCase__ : Union[str, Any] = f"""Input value of [number={number}] must be an integer""" raise TypeErro...
242
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _A = logging.get_logger(__name__) class _lowerCamelCase : def __init__( sel...
242
1
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> str: """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
60
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Union[str, Any] = { """BridgeTower/bridgetow...
60
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import ...
339
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/microsoft/unisp...
320
0
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, XLMR...
138
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_available(): from .tokenization_xlnet import...
138
1
"""simple docstring""" from math import isqrt def a_ ( lowerCamelCase ): return all(number % divisor != 0 for divisor in range(2 , isqrt(lowerCamelCase ) + 1 ) ) def a_ ( lowerCamelCase = 1_0**6 ): UpperCAmelCase__ = 0 U...
98
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowerCAmelCase__ : Optional[int] = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight...
98
1
class a : def __init__( self :Optional[Any] ): snake_case__ : str = '''''' snake_case__ : Union[str, Any] = '''''' snake_case__ : int = [] def __lowerCamelCase ( self :str ,__lowe...
44
def _lowerCAmelCase ( __lowerCAmelCase ) -> int: """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 snake_case__ : List[str] = 1 snake_case__ : int = 1 while repunit: snake_case__ : Dic...
44
1
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets lowerCAmelCase__ = datasets.logging.get_logger(__name__) lowerCAmelCase__ = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavi...
108
"""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
"""simple docstring""" __A = """ # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git """ __A = [{"""type""": """code""", """content""": INSTALL_CONTENT}] __A ...
352
"""simple docstring""" from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __A (_SCREAMING_SNAKE_CASE = "" ) ->dict[str, float]: """simple docstring""" lowerCAmelCase__ :Optional[Any] = url or 'https://www.imdb.com/ch...
254
0
'''simple docstring''' class _lowercase : '''simple docstring''' def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE__ : int ) -> Any: __lowerCAmelCase = n __lowerCAmelCase = [None] * self.n __lowerCAmelCase ...
229
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' def a ( self : int ) -> Optional[Any]: return ...
229
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __a :List[str] = TypeVar('T') class _a ( Generic[T] ): """simple docstring""" def __init__( self : Any , UpperCAmel...
351
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __a :int = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __a :Any = [file for file in filepaths if file != file.lower...
329
0
'''simple docstring''' def _lowerCamelCase ( lowercase : int = 200 ) -> int: _a = [1, 2, 5, 10, 20, 50, 100, 200] _a = [0] * (pence + 1) _a = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(lowercase , pence +...
63
'''simple docstring''' def _lowerCamelCase ( lowercase : bytes ) -> str: return "".join([hex(lowercase )[2:].zfill(2 ).upper() for byte in list(lowercase )] ) def _lowerCamelCase ( lowercase : str ) -> bytes: # Check data validity, fol...
63
1
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCamelCase__ : Optional[int] = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.self', ...
210
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def UpperCAmelCase_ ( __UpperCAmelCase : Optional[int] ) -> int: if not is_accelerate_available(): return method SCREAMING_SNAKE_...
210
1
"""simple docstring""" from __future__ import annotations from typing import TypedDict class _UpperCAmelCase ( lowerCAmelCase__): _lowerCAmelCase : str _lowerCAmelCase : int def __lowercase ( _a ): if not isinstance(_a , _a ): raise TypeError('''The p...
264
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
264
1
'''simple docstring''' def __lowerCamelCase ( __snake_case : list[list[int]], __snake_case : int, __snake_case : int, __snake_case : list[int] ) -> Tuple: """simple docstring""" if graph[path[curr_ind - 1]][next_ver] == 0: return False ...
367
'''simple docstring''' from __future__ import annotations from typing import Any class lowerCamelCase : '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase_ : int ) -> None: '''simple docstring''' A__ : Any =num...
136
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase ={ "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LxmertConfig"], "tokeniz...
334
'''simple docstring''' from manim import * class SCREAMING_SNAKE_CASE( A__ ): """simple docstring""" def A ( self : Union[str, Any] ) -> List[str]: UpperCAmelCase : Optional[Any] = Rectangle(height=0.5 , widt...
23
0
def __magic_name__ ( __a : list ): '''simple docstring''' UpperCamelCase__ = len(__a ) for _ in range(__a ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: UpperCamelCase__ , UpperCamelCas...
178
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
178
1
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ...
45
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__na...
37
0
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 snake_case : int = logging.get_logger(__name__) snake_case ...
41
from __future__ import annotations snake_case : Optional[int] = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } class _snake_case : def __init__( self , _a , ...
41
1
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_...
44
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ) -> List[Any]: # noqa: E741 _lowerCAmelCase : Optional[int] = len(_lowerCamelCase ) _lowerCAmelCase : str = 0 _lowerCAmelCase : Any = [0] * n ...
44
1
'''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.exists(U...
243
'''simple docstring''' from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a__ : Optional[Any] = logging.get_logger(__name__) a__ : List[str] = { 'nielsr/canine-s'...
243
1
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer snake_case__ : Optional[Any] = logging.getLogger(__name__) def _snake_case ( ): lowerCAmelCase : Tuple = argparse.ArgumentParser( ...
60
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def _snake_case ( _snake_case : list[list[float]] ): lowerCAmelCase : str = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implement...
60
1
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def a__ ( __SCREAMING_SNAKE_CASE = 8 ) -> str: __lowerCAmelCase: int = ascii_letters + digits + punctuation r...
108
"""simple docstring""" from __future__ import annotations from math import pi def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> dict[str, float]: if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError("One an...
108
1
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, get...
138
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging.se...
138
1
'''simple docstring''' def UpperCAmelCase ( lowerCamelCase_ :int ): '''simple docstring''' snake_case_ : str = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
8
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.ut...
8
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _a : List[Any] = logging.get_logger(__name__) _a : Optional[int] = { ...
44
"""simple docstring""" from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : int ) ...
44
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_torch_available(): ...
357
import math from collections import defaultdict 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 KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def lowerCamelCase__ ( ...
29
0
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: str ): __SCREAMING_SNAKE_CASE : str = """""" 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 lowerCAmelCase_ ( _lowerCamelCase: st...
112
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: if not is_t...
254
0
'''simple docstring''' import math import sys def _A (lowerCAmelCase__ :Union[str, Any] ) -> Optional[int]: '''simple docstring''' _a = '' try: with open(lowerCAmelCase__ , 'rb' ) as binary_file: ...
355
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import...
104
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, log...
324
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 tokenizers lower...
329
0
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_ ): # Initialise PyTo...
364
from __future__ import annotations def lowerCAmelCase_ ( snake_case_ ): create_state_space_tree(snake_case_,[],0,[0 for i in range(len(snake_case_ ) )] ) def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_,): if index == len(snake...
343
0
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, require_tokenizers, require_torch, s...
210
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCAmelCase ( lowercase ): """simple docstring""" if not isinstance(lowercase , lowercase ): raise TypeError('''Undefined for non-integers''' ) elif precision < 1: ...
210
1
"""simple docstring""" from __future__ import annotations _UpperCAmelCase : Optional[Any] = tuple[int, int, int] _UpperCAmelCase : Dict = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase _UpperCAmelCase : List[str] = "ABCDEFGHI...
365
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __lowerCAmelCase ( lowerCAmelCase): _a = (DDIMParallelScheduler,) _a = (('''eta''', 0.0), ('''num_inference_steps''', 50)) def SCREAMING_SNAKE_CAS...
158
0
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configurat...
14
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> list: '''simple docstring''' lowercase_ = len(__lowerCAmelCase ) lowercase_ = [[0] * n for i in range(__lowerCAme...
136
0
def __lowercase ( a__ ) -> str: return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
350
import os def __lowercase ( a__ = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(a__ ) , a__ ) ) as input_file: __SCREAMING_SNAKE_CASE = [ [int(a__ ) for element in line.split(',' )]...
118
0
from collections import defaultdict def __UpperCAmelCase ( a_ , a_): snake_case_ = first_str.lower().strip() snake_case_ = second_str.lower().strip() # Remove whitespace snake_case_ = first_str.replace(' ' , '') s...
178
lowercase = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" lowercase = [{"type": "code", "content": INSTALL_CONTENT}] lowercase = { ...
178
1
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> str: return " ".join( """""".join(word[::-1] ) if len(UpperCAmelCase__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() prin...
101
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_blenderbot''': [ ...
101
1
'''simple docstring''' import heapq import sys import numpy as np _A : Dict =tuple[int, int] class _lowercase : def __init__( self: List[str] ): lowerCamelCase__ : List[str] = [] lowerCamelCase_...
41
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome...
41
1
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, blender...
197
from __future__ import annotations import numpy as np def lowerCAmelCase( __lowerCamelCase ): return np.maximum(0 , __lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
197
1
"""simple docstring""" UpperCamelCase_ = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.co...
243
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from tra...
243
1
class _snake_case : def __init__( self : Union[str, Any] , UpperCAmelCase : Optional[int] , UpperCAmelCase : Dict ): __lowerCamelCase : str = name __lowerCamelCase : Dict = val def __...
354
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils im...
64
0
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def a_...
108
"""simple docstring""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from tran...
108
1
"""simple docstring""" import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging _A = logging.get_logger(__name__) class lowerCamelCase : '''simple docstring''' SCREAMING_SNAKE_CASE = None ...
350
"""simple docstring""" import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase ( lowerCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE = (DDIMParallelScheduler,) SCREAMING_SNAKE_CASE = ...
166
0
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): snake_case_ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
8
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
8
1
def __lowerCamelCase ( lowerCamelCase__ : Optional[Any] , lowerCamelCase__ : Any , lowerCamelCase__ : Optional[Any] ): '''simple docstring''' return round(float(moles / volume ) * nfactor ) def __lowerCamelCase ( lowerCamelCase_...
361
import math import tensorflow as tf from packaging import version def __lowerCamelCase ( lowerCamelCase__ : Optional[Any] ): '''simple docstring''' lowerCamelCase = tf.convert_to_tensor(lowerCamelCase__ ) lowerCamelCase = 0.5 * (1.0 + tf.math....
66
0
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets snake_case_ : Optional[int] = datasets.logging.get_logger(__name__) snake_case_ : Tuple = "\\n@inproceedings{bleurt,\n title={BLEURT: Learning Robust Metrics for...
51
__UpperCAmelCase = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', 'dataclasses': 'd...
29
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent A : str = {'UserAgent': UserAgent().random} def __lowerCAmelCase ( a__ ) -> dict: __a = script.contents[0] __a = j...
33
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A : Optional[int] = { 'configuration_roberta': ['ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MA...
33
1
def lowerCamelCase_ ( UpperCamelCase__ : Any ) -> int: """simple docstring""" stooge(UpperCamelCase__ , 0 , len(UpperCamelCase__ ) - 1 ) return arr def lowerCamelCase_ ( UpperCamelCase__ : Dict , ...
90
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''facebook/...
104
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : Optional[int] = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """...
355
from __future__ import annotations def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' snake_case_ = [] create_all_state(1 , UpperCamelCase__ , UpperCamelCase__ , [] , ...
200
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
80
import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
343
0
'''simple docstring''' import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_...
366
'''simple docstring''' from __future__ import annotations import requests def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return requests.get(_lowerCAmelCase ).json() ...
48
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( ) -> int: _a : List[Any] =0 for i in range(1 ,1001 ): total += i**i return str(SCREAMING_SNAKE_CASE_ )[-10:] if __name__ == "__main__": print(solution())
276
'''simple docstring''' import math import unittest def __a(SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' assert isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number <...
158
0
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
365
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...
237
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 transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity_info() A : ...
118
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, get_t...
118
1
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def UpperCAmelCase__ ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
357
from collections.abc import Iterable from typing import Generic, TypeVar _UpperCAmelCase : Any = TypeVar("_T") class __lowerCAmelCase ( Generic[_T]): def __init__( self: Union[str, Any] , _lowerCAmelCase: Iterable[_T] | None = None ): lowercase ...
158
0
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowercase__ :Dict = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operator.ge, ">": operator.gt, } def UpperCamelCase ...
101
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
101
1
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class __snake_case( _UpperCAmelCase ...
371
'''simple docstring''' from __future__ import annotations def _snake_case ( _SCREAMING_SNAKE_CASE : int | str ) -> bool: """simple docstring""" lowerCAmelCase = str(_SCREAMING_SNAKE_CASE ) return n == n[::-1] def _snake_c...
187
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 : Tuple =logging.get_logger(__name__) __lowerCAmelCase : ...
197
"""simple docstring""" from __future__ import annotations from typing import Any class _A : def __init__( self , __lowerCAmelCase = 6 ): """simple docstring""" lowercase = None lowercase ...
197
1
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, requ...
356
"""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.a...
181
0
"""simple docstring""" import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging __UpperCamelCase = logging.get_logger(__name__) class UpperCamelCase ( lowerCAmelCase__ ): ...
69
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCAmelCase__ (snake_case__ : Optional[int] , snake_case__ : Any=7 ): """simple docstring""" _snake_case...
64
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
368
import math import random def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value UpperCamelCase = 0.02 def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ...
65
0
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __UpperCAmelCase = TypeVar('T') class _SCREAMING_SNAKE_CASE ( Generic[T] ): UpperCAmelCase_ :deque[T] # Cache store of keys ...
84
'''simple docstring''' import numpy # List of input, output pairs lowerCamelCase = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) lowerCamelCase = (((515, 22, 13), 555), ((61, 35, 49), 150)) lowerCamelCase = [2, ...
166
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, rescal...
363
'''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_available()...
346
0
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 lowerCamelCase__ ( ): raise RuntimeError("CUDA out of memory.") class _UpperCamelCase ( nn.Module ...
76
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_bac...
66
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : Union[str, Any] = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOn...
357
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) def _A ( SCREAMING_SNAKE_CASE :...
148
0
"""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...
33
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __A : str = argparse.ArgumentParser() parser.add_ar...
33
1
'''simple docstring''' 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 ( Autoen...
353
'''simple docstring''' 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 VQDiff...
242
0
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig 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_common import Con...
89
'''simple docstring''' from typing import Any class lowercase__ : '''simple docstring''' def __init__( self , __snake_case ): _SCREAMING_SNAKE_CASE : Dict = data _SCREAMING_SNAKE_CASE : Optional[int] = None ...
200
0
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : list[int] ): """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) _snake_case : Any = sum(snake_case__ ) / len(snake_case__ ) # Calcu...
357
"""simple docstring""" from __future__ import annotations from math import gcd def UpperCAmelCase__ (snake_case__ : int , snake_case__ : int = 2 , snake_case__ : int = 1 , snake_case__ : int = 3 , ): """simple docstring""" if num < 2: ...
132
0