code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __a :List[Any] = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
86
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_...
182
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any]= logging.get_logger(__name__) _a : Dict= { "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json", } class UpperCamelCase ...
718
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_...
192
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowerCamelCase__ ( __lowerCamelCase : int ): __UpperCAmelCase : Optional[Any] = prime_factors(__lowerCamelCase ) if is_square_free(__lowerCamelCase ...
63
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
0
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup SCREAMING_SNAKE_CASE = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def lowercase_ ( __A : str = "mumbai" ) -> ...
704
'''simple docstring''' SCREAMING_SNAKE_CASE = 'Alexander Joslin' import operator as op from .stack import Stack def lowercase_ ( __A : str ) -> int: """simple docstring""" lowercase : int ={'''*''': op.mul, '''/''': op.truediv, '''+''': op.add, '''-...
8
0
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax i...
242
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ ): @register_to_config def __init__( self , *, ...
242
1
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""", """ConvBertConfig"""...
582
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, nes...
582
1
'''simple docstring''' 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 ModelMixi...
432
'''simple docstring''' _lowerCAmelCase = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" _lowerCAmelCase = [{"type": "code", "content": INSTALL_CONTE...
432
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_util...
717
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import T...
261
0
"""simple docstring""" from math import factorial def SCREAMING_SNAKE_CASE__ ( snake_case : int = 100 )-> int: '''simple docstring''' return sum(int(lowerCamelCase_ ) for x in str(factorial(lowerCamelCase_ ) ) ) if __name__ == "__main__": print(solution(in...
438
import os import sys import unittest UpperCamelCase__ : 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, create_dumm...
105
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase ( snake_case_ ,unittest.TestCase ): ...
664
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxConfig"]} try:...
664
1
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils imp...
40
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...
55
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer A = logging.get_logger(__name__) A = {"vocab_file"...
277
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging A = logging.get_logger(__name__) def __UpperCAmelCase...
277
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelC...
2
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_in...
2
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : List[Any] = { '''configuration_whisper''': ['''WHISPER_PRETRAINED...
700
from __future__ import annotations from scipy.special import comb # type: ignore class a__ : def __init__( self : Union[str, Any],_A : list[tuple[float, float]] ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = list_of_points # ...
316
0
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass SCREAMING_SNAKE_CASE_ = (3, 9, -11, 0, 7, 5, 1, -1) SCREAMING_SNAKE_CASE_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class snake_case_ : ...
34
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """microsoft/trocr-base-handwritten""": ( """https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config...
590
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available, ...
673
import random def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> dict: '''simple docstring''' SCREAMING_SNAKE_CASE = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than ...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[int] = { """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""], } try: if not is_to...
112
def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): _A : Union[str, Any] = len(snake_case_ ) _A : str = [[0] * n for i in range(snake_case_ )] for i in range(snake_case_ ): _A : Optional[Any] = y_points[i] for i in range(2,snake_case...
307
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase : Dict = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""]...
713
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCAmelCase : str = { """configuration_gpt_neox_japanese""": ["""GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MA...
474
0
'''simple docstring''' class lowerCAmelCase__ : '''simple docstring''' def __init__( self : Optional[Any] , a__ : Dict ): UpperCAmelCase = val UpperCAmelCase = None UpperCAmelCase = None def ...
51
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Optional[Any]: '''simple docstring''' def wrapper(*_UpperCAmelCase, **_UpperCAmelCa...
343
0
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar SCREAMING_SNAKE_CASE : Optional[Any] = TypeVar("KEY") SCREAMING_SNAKE_CASE : int = TypeVar("VAL") @datac...
707
'''simple docstring''' def _UpperCamelCase ( lowerCAmelCase__: int ,lowerCAmelCase__: float ,lowerCAmelCase__: float ) -> float: return round(float(moles / volume ) * nfactor ) def _UpperCamelCase ( lowerCAmelCase__: float ,lo...
238
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : str = logging.get_logger(__name__) _lowerCamelCase : Optional[Any] = { ...
121
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
1
"""simple docstring""" from itertools import permutations def A__ ( UpperCamelCase ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False ...
709
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def A__ ( UpperCamelCase ): A, A, A = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.29_89 * r + 0.58_70 * g + 0.11_40 * b def A__ ( UpperCamelCase ): ...
524
0
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset lowerCAmelCase : Optional[Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2),...
511
'''simple docstring''' 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 AcceleratorS...
152
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_config...
582
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import Token...
582
1
'''simple docstring''' def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Any ) -> Optional[Any]: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4...
421
'''simple docstring''' import re def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : str ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = re.compile(R"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$" ) if match := re.search(SCREAMING_SNA...
421
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class _snake_case (__SCREAMING_SNAKE_CASE): __A : Any ="SpeechT5FeatureExtractor" __A : List[str] ="SpeechT5Tokenizer" def __init__( self ,_snake_case ,_snake_case ): super().__in...
323
'''simple docstring''' import csv import tweepy # Twitter API credentials _lowerCamelCase = """""" _lowerCamelCase = """""" _lowerCamelCase = """""" _lowerCamelCase = """""" def a__ ( _SCREAMING_SNAKE_CASE : str ) -> None: ""...
323
1
"""simple docstring""" import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table impo...
680
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : Optional[Any] = logging.get_logger(__name__) snake_case_ : Any = { 'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resolve/main/conf...
212
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from tran...
720
"""simple docstring""" A_ : List[Any] =9.8_0665 def SCREAMING_SNAKE_CASE_ ( snake_case : float , snake_case : float , snake_case : float = g )-> float: if fluid_density <= 0: raise ValueError('Impossible fluid density' ) if...
222
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class A__ ( A__ ): """simple docstring""" def __init__( self : Dict , lowerCamelCase__ : Any , lowerCamelCase__ : Any ): a__ : str = params a__ : Any ...
37
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _UpperCAmelCase ( A , A , A , A=1024 ): '''simple docstring''' UpperCAmelCase__ , UpperCAmelCase__ ...
625
0
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowercase__ = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operator.ge, ">": op...
706
"""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 lowercase__ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( __...
63
0
'''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 ....
50
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _SCREAMING_SNAKE_CASE : Optional[int] = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available()...
550
0
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class lowercase__( _UpperCAmelCase ): '''simple docstring''' def __init__( self :Optional[int] , *lowerCamelCase_ :Union[str, Any] , **lowerCamelCase_ :str ) -> Optional[int]: ...
18
"""simple docstring""" import math def __A ( a_ : list , a_ : int )-> int: '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[int] = len(a_ ) SCREAMING_SNAKE_CASE : Optional[Any] = int(math.floor(math.sqrt(a_ ) ) ) ...
18
1
'''simple docstring''' 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:...
212
'''simple docstring''' def __snake_case ( _UpperCAmelCase : int, _UpperCAmelCase : str): UpperCamelCase = '''''' for i in table: res += inp[i - 1] return res def __snake_case ( _UpperCAmelCase : Dict): return data[1:] + data[0]...
212
1
'''simple docstring''' import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class a_ ( UpperCamelCase__ , unittest.TestCase ): lowerCamelCase__ : str = DownBl...
511
'''simple docstring''' def UpperCamelCase_ ( A__ , A__ ): while b: a_ , a_ = b, a % b return a def UpperCamelCase_ ( A__ , A__ ): return a if b == 0 else euclidean_gcd_recursive(A__ , a % b ) def UpperCamelCase_ ( ): print(F'''e...
511
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Dict = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvNextC...
605
# 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]' when switching bet...
605
1
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights fro...
366
"""simple docstring""" import os def lowercase_ ( ) -> List[str]: '''simple docstring''' __lowerCamelCase : Union[str, Any] = os.path.dirname(os.path.realpath(_lowerCamelCase ) ) __lowerCamelCase : int = os.path.join(_lowerCamelCase , ...
366
1
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
568
import comet # From: unbabel-comet import torch import datasets lowercase : List[Any] = datasets.logging.get_logger(__name__) lowercase : List[str] = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
568
1
import os import sys lowerCAmelCase = os.path.join(os.path.dirname(__file__), """src""") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceClassification, ...
715
lowerCAmelCase = 256 # Modulus to hash a string lowerCAmelCase = 1_000_003 def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> bool: '''simple docstring''' __UpperCAmelCase : List[str] = len(lowercase_ ) __UpperC...
675
0
"""simple docstring""" def _snake_case ( UpperCamelCase : int ): if len(lowercase__ ) < 2: return collection def circle_sort_util(UpperCamelCase : str , UpperCamelCase : Optional[int] , UpperCamelCase : List[str] ) -> bool: UpperCAmelCase : Any = ...
160
'''simple docstring''' import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from trans...
199
0
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCAmelCase__ ( unittest.TestCase ): '''simple docstring''' def __snake_case ( self : in...
570
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a__ : Optional[Any] = logging.get_logger(__name__) class lowerCAmelCase__ ( UpperCAmelCase_ ): '''simple docstring''' def __in...
570
1
import functools def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> int: # Validation if not isinstance(__snake_case , __snake_case ) or not all(isinstance(__snake_case , __snake_case ) for day in days ): raise ValueError("""The ...
108
def UpperCAmelCase__ (UpperCamelCase_ = 10_00 ): """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3 ,n + 1 ) ) if __name__ == "__main__": print(solution())
550
0
"""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, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffu...
707
"""simple docstring""" from typing import Any class UpperCamelCase : def __init__(self : List[str] , _A : Any) -> int: __snake_case : Any = data __snake_case : Dict = None def __repr__(self : ...
192
0
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_...
208
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCAmelCase ( __magic_name__ ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Dict =["image_processor", "tokenizer"] SCREAMING_SNAKE_CASE_ : ...
170
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json''', } class _lowerCAmel...
170
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionCo...
269
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor UpperCamelCase = logging.get_logger(__name__) class _A ( UpperCAmelCase_ ): def __init__( self : str , *lowerCamelCase__ : Optional[int] , **lowerCamelCase_...
269
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Optional[int] = { """con...
705
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Tuple = { """configuration_blip_2""": [ """BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
270
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _snake_case : str = { 'configuration_layou...
22
from pathlib import Path import fire def lowercase__ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase) -> Optional[int]: """simple docstring""" UpperCamelCase = Path(_UpperCamelCase) UpperCamelCase = Path(_UpperCamelCa...
280
0
from __future__ import annotations def lowerCamelCase__ ( a : list[int] , a : int ) -> int: """simple docstring""" if len(a ) < k or k < 0: raise ValueError("Invalid Input" ) a__ :Optional[int] = sum(array[:k] ) for i in range(len(a ) - k ): ...
373
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig snake_case__ = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''', '''albert-large-v1''': '''https://huggingfa...
373
1
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def snake_case_ ( lowercase__ ): UpperCAmelCase__ : List[Any] = [] UpperCAmelCase__ : Opt...
199
'''simple docstring''' import datasets __lowerCamelCase : int = """\ @InProceedings{conneau2018xnli, author = \"Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. ...
501
0
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(): ...
703
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _A ( __snake_case :int ) -> Optional[int]: """simple docstring""" if ( (cp >= 0x4E_00 and cp <= 0x9F_FF) or (cp >= 0x34_0...
214
0
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) lowerCamelCase__ : Optional[Any] = { """sample_size""": 3_2, """in_channels""": 3, """out_channels""": 3, """layers_per_bl...
12
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 transformers.testin...
12
1
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline,...
431
import copy import re class lowercase_ : __lowerCamelCase = "hp" __lowerCamelCase = {} __lowerCamelCase = None @classmethod def _snake_case ( cls , __A , __A ) -> Optional[int]: SCREAMIN...
431
1
"""simple docstring""" import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2vec-...
104
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers...
104
1
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table i...
707
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class a : """simple docstring""" def __init__( self , ...
83
0
def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Optional[int]: # Return True if there is node that has not iterated. _lowercase : List[str] = [False] * len(SCREAMING_SNAKE_CA...
66
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( Autoenco...
102
0
from __future__ import annotations from dataclasses import dataclass @dataclass class UpperCamelCase : a__ :Any = 42 a__ :List[Any] = None a__ :List[Any] = None def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : TreeNode | Non...
721
SCREAMING_SNAKE_CASE : List[Any] = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import A...
138
0
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class a_ ( a_ ): ...
318
def lowerCamelCase ( a_ ) -> list: lowerCAmelCase_ = len(a_ ) for _ in range(a_ ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: lowerCAmelCase_ , low...
318
1
"""simple docstring""" import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_se...
422
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def snake_case__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=False ) ->str: UpperCAmelCase__ = OmegaConf.load(_SCREAMING_SNAKE_CASE ) ...
422
1
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def a__ ( _SCREAMING_SNAKE_CASE : int ) -> Dict: """simple docstring""" def is_in_circle(_SCREAMING_SNAKE_CASE : ...
71
import pytest _lowerCamelCase ="""__dummy_dataset1__""" _lowerCamelCase =""" import json import os import datasets REPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\" URLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", \"validation\": REPO_URL + \"wikiann-bn...
681
0
def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ , UpperCamelCase__ ): def get_matched_characters(UpperCamelCase__ , UpperCamelCase__ ) -> str: UpperCamelCase__ : Optional[int] = [] UpperCamelCase__ : Optional[int] = min(len(_stra ) , len(_stra ) ...
462
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": [ "BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP",...
462
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, 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 from ....
538
'''simple docstring''' import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase_ ( _lowercase , _lowercase=False ) -> Dict: '''simple docstring''' lowerCamelCase_ : Tuple = OmegaConf.load(_lowerca...
422
0
'''simple docstring''' 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, ...
721
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE:List[Any] = (KDPMaDiscreteS...
126
0
"""simple docstring""" lowercase__ = 8.3144598 def __lowerCamelCase ( __UpperCamelCase , __UpperCamelCase ) -> float: """simple docstring""" if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("...
610
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ = { """configuration...
610
1
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 BatchFeature from ...utils import Tens...
715
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__: Optional[Any] = {"configuration_plbart": ["PLBART_PRETRAINED_CONFIG_ARCH...
311
0
"""simple docstring""" from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neu...
661
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, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaT...
31
0
'''simple docstring''' 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 UpperCAmelCase__ ( ...
713
'''simple docstring''' def UpperCAmelCase_ (__a : int ): """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 _a : Optional[Any] = 1 _a : str = 1 while repunit: _a : Union[str, Any] = (1_0 * repunit...
319
0
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_trans...
315
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, ...
315
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) _UpperCamelCase : Dict ={ "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "SPEECHT5_PRETRA...
721
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCamelCase : Tuple ={ "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], }...
575
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 _snake_case ( unittest.TestCase ): def lowercase__ ( self): ...
12
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .token...
574
0
'''simple docstring''' from maths.prime_factors import prime_factors def UpperCamelCase( UpperCAmelCase_ ): if not isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): UpperCAmelCase : Tuple = F"""Input value of [number={number}] must be an integer""" raise TypeError(UpperCAm...
704
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. 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/LIC...
695
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig",...
28
"""simple docstring""" # Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
213
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class Upp...
710
_lowerCAmelCase = frozenset( [ """prompt""", """height""", """width""", """guidance_scale""", """negative_prompt""", """prompt_embeds""", """negative_prompt_embeds""", """cross_attention_kwargs""", ] ) _lowerCAmelCase = ...
306
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Tuple =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : List[Any] ={ '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/...
428
import copy import random from transformers import CLIPTokenizer class A_ ( __a ): def __init__( self : Tuple , *snake_case__ : Any , **snake_case__ : Tuple ): super().__init__(*snake_case__ , **snake_case__ ) lowercase ...
428
1
"""simple docstring""" import argparse import os from accelerate.test_utils import execute_subprocess_async def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any]=None ) -> Any: if subparsers is not None: _lowerCAmelCase : Optional[Any] = subparsers.add_parser("""t...
718
"""simple docstring""" import argparse import json import subprocess def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[Any] ,_lowerCamelCase : Any ) -> List[Any]: _lowerCAmelCase : Tuple = [] _lowerCAmelCase : Optional[int] = ( f"curl -H \"Accept: applic...
663
0
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list[int] ): SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) for i in range(UpperCamelCase__ ): for j in range(i + 1 , UpperCamelCase__ ): if numbers[j] < numbers[i]: SCREAMING_SNAKE_CASE__ , ...
6
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase = logging.getLogger(__name__) if __name__ == "__main__": _lowerCamelC...
6
1
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class UpperCamelCase__ : '''simple docstring''' __a : int __a : Node | N...
436
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ ...
436
1
'''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_extraction...
42
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A_ = logging.get_logger(__name__) A_ = {"vocab_file": "vocab.json", "merges...
42
1
def _lowerCamelCase ( snake_case , snake_case ): _lowerCAmelCase = len(snake_case ) _lowerCAmelCase = len(snake_case ) _lowerCAmelCase = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] _lowerCAmelCase = ...
225
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() _lowercase: Optional[int] = logging.get_logger(__name__) def _lowerCamelCase ( snake_case , snake_case ...
225
1
"""simple docstring""" import os __lowerCAmelCase : List[str] = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def __lowerCAmelCase ( __UpperCamelCase : str ): '''simple docstring''' ...
58
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : List[Any] = logging.get_logger(__name__) __...
58
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ : List[Any] = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torc...
302
"""simple docstring""" import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import (...
302
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logge...
83
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowerCAmelCase ...
469
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ = 3 ) -> qiskit.result.counts.Counts: if isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): ...
69
import numpy class A__ : def __init__( self : Tuple , a : numpy.ndarray , a : numpy.ndarray ): '''simple docstring''' lowerCAmelCase__ : int = input_array # Random initial weights...
69
1
'''simple docstring''' from __future__ import annotations def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): # Checks if the entire collection has been sorted if len(SCREAMING_SNAKE_CASE__ ) <= 1 or n <= 1: return insert_next(SCREAMI...
597
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCamelCase__ ) class lowerCAmelCase ( lowerCamelCase__ ): """simp...
597
1
"""simple docstring""" from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbedding...
497
"""simple docstring""" import os from datetime import datetime as dt from github import Github UpperCamelCase_ : List[str] = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""",...
497
1
'''simple docstring''' 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 ...tes...
526
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. 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/LICENS...
526
1
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
700
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
0
'''simple docstring''' import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers...
28
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _lowerCAmelCase :Tuple = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-larg...
506
0
'''simple docstring''' import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : str = logging.get_logger(__name__) UpperCamelCase : List[str...
706
'''simple docstring''' from math import factorial UpperCamelCase : dict[str, int] = {str(digit): factorial(digit) for digit in range(10)} def A__ ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeErro...
9
0
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vis...
10
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
10
1
import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( UpperCamelCase_ = "AAPL" ) -> str: UpperCamelCase_ = F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' UpperCamelCase_ = BeautifulSoup(requests.get(UpperCamelCase_ ).text , "html.p...
712
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase =...
371
0
"""simple docstring""" _lowerCamelCase = { "joule": 1.0, "kilojoule": 10_00, "megajoule": 1_00_00_00, "gigajoule": 10_00_00_00_00, "wattsecond": 1.0, "watthour": 36_00, "kilowatthour": 3_60_00_00, "newtonmeter": 1.0, "calorie_nutr": 41_86.8, "kilocalorie_nutr"...
674
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=UpperCAmelCase_): __SCREAMING_SNAKE_CASE = ['''torch''', '''scipy'''] def __init__( self , *lowercase , **lowercase ) -> int: requires_bac...
601
0
"""simple docstring""" def _a ( _snake_case ): """simple docstring""" return "".join([hex(_snake_case )[2:].zfill(2 ).upper() for byte in list(_snake_case )] ) def _a ( _snake_case ): """simple docstring""" if (le...
701
"""simple docstring""" from __future__ import annotations from typing import Any class lowerCamelCase__ : def __init__( self ,A = 6 ): UpperCAmelCase = None UpperCAmelCase = None self.create_linked_list(A ) ...
74
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaIm...
29
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 ConfigTester from ...
518
0
import collections import importlib.util import os import re from pathlib import Path _A : Optional[Any] = '''src/transformers''' # Matches is_xxx_available() _A : str = re.compile(r'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} _A : Optional[...
189
_A : Tuple = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def __lowerCAmelCase ( ) -> None: __lowerCamelCase: Optional[int] = input("""Enter message: """ ) __lowerCamelCase: Dict = input("""Enter key [alphanumeric]: """ ) __lowerCamelCase: List[Any] =...
189
1
import math from collections.abc import Iterator from itertools import takewhile def __lowerCamelCase ( __lowerCAmelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Nega...
269
from collections.abc import Iterable from typing import Generic, TypeVar UpperCamelCase = TypeVar('_T') class _A ( Generic[_T] ): def __init__( self : int , lowerCamelCase__ : Iterable[_T] | None = None ): """simple docstring""" __UpperCamelCase : ...
269
1
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IF...
709
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _UpperCAmelCase = argparse.ArgumentParser( description=( """Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Lear...
36
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 lowerCamelCase (unittest.TestC...
406
def lowercase__ ( __snake_case : list , __snake_case : list ): '''simple docstring''' _validate_point(__snake_case ) _validate_point(__snake_case ) if len(__snake_case ) != len(__snake_case ): raise ValueError('Both points must...
406
1
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) f...
80
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCamelCase__( nn.Module): UpperCAmelCase__ : int UpperCAmelCase__ : int UpperCAmelCase_...
80
1
from __future__ import annotations def UpperCamelCase ( __magic_name__ : list[int] ) -> list[int]: # This function is recursive """simple docstring""" lowercase__ = len(__magic_name__ ) # If the array contains only one element, we return it (it's the sto...
15
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( lowercase): __SCRE...
684
0
'''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 _lowercase ...
44
'''simple docstring''' import argparse import copy def __UpperCamelCase ( a : Union[str, Any] ) ->Tuple: snake_case = {} with open(a ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: snake_case = [] _list.append([line.split...
44
1