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
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[int] ): # This function is recursive __UpperCAmelCase = len(snake_case_ ) # If the array contains only one element, we return it (it's the stop condition of # recu...
49
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Union[str, Any] = { """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP...
112
0
import colorsys from PIL import Image # type: ignore def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> float: """simple docstring""" A : Optional[int] = x A : int = y for step in range(_lowerCAmelCase ): # noqa: B...
520
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring'''...
520
1
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def _A ( A ) -> Optional[Any]: if "model" in orig_key: lowercase : str = orig_key.replace("model." ,"" ) if "norm1" in orig_key: lowercase : Any ...
372
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
372
1
from typing import List import numpy as np def __magic_name__( __UpperCAmelCase ) -> int: '''simple docstring''' _lowerCamelCase = {key: len(__UpperCAmelCase ) for key, value in gen_kwargs.items() if isinstance(__UpperCAmelCase , __UpperCAmelCase )} if le...
638
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerF...
638
1
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def _a ( ): """simple docstring""" assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand...
43
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeli...
544
0
'''simple docstring''' # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u bel...
630
'''simple docstring''' from collections import Counter from timeit import timeit def lowercase (_A = "" , ): """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values()...
630
1
"""simple docstring""" # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to...
4
"""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:%S''', ...
4
1
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _lowerCAmelCase = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-lar...
715
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: lowerCAm...
160
0
'''simple docstring''' from jiwer import compute_measures import datasets __UpperCamelCase = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and R...
26
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : str = logging.get_logger(__name__) UpperCAmelCase : List[Any] = { "facebook/vit-mae-base": "https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json", # See all ViT MAE models...
457
0
"""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, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDCond...
718
"""simple docstring""" import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
659
0
"""simple docstring""" def snake_case ( A__ ): UpperCAmelCase_ : List[str] = [] UpperCAmelCase_ : Optional[int] = [] UpperCAmelCase_ : Dict = { "^": 3, "*": 2, "/": 2, "%": 2, "+": 1, "-": 1, } # Priority of each ope...
95
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common impor...
373
0
"""simple docstring""" from sklearn.metrics import recall_score import datasets _A : Union[str, Any] = """ Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true p...
518
"""simple docstring""" _A : List[Any] = """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""" def __magic_name__ ( __snake_case : bytes ) -> bytes: # Make sure the supplied data is a bytes-like object if not isinstance(__snake_case ...
518
1
def A ( ) -> int: return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(__UpperCamelCase , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f'{solution() = }')
9
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowercase__ :str = {'configuration_fnet': ['FNET_...
522
0
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar a = TypeVar('T') class UpperCamelCase__ ( Generic[T] ): def __init__( self : ...
650
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 impo...
650
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer fro...
361
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ : Tuple =logging.get_logger(__name__) A_ ...
274
0
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, 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 ..image_utils impo...
321
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 10, """max_num_jobs""": 1}, [range...
321
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _a ( un...
449
"""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 A = importlib.util.find_spec('s3fs') is not None if _has_safs:...
449
1
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def A_ ( __UpperCamelCase : int ): def wrapper(*__UpperCamelCase : Any , **__UpperCamelCase : ...
717
"""simple docstring""" import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename __lowerCAmelCase = '''http:...
396
0
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversatio...
698
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn...
698
1
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline UpperCAmelCase_ = datasets.utils.loggin...
709
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoMo...
476
0
"""simple docstring""" def _A ( __lowercase = 10**9 ): """simple docstring""" lowerCamelCase__ = 1 lowerCamelCase__ = 2 lowerCamelCase__ = 0 lowerCamelCase__ = 0 lowerCamelCase__ = 0...
129
"""simple docstring""" import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE...
281
0
import numpy as np from transformers import Pipeline def lowerCAmelCase_ ( __a ) -> List[str]: """simple docstring""" lowerCamelCase__: List[str] =np.max(__a , axis=-1 , keepdims=__a ) lowerCamelCase__: Any =np.exp(outputs - maxes ) return shifted_...
437
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer __A = logging.get_logger(__name__) __A =...
437
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ :Tuple = logging.get_logger(__name__) UpperCamelCase__ :Optional[int] = { """facebook/wav2vec2-base-960h""": """https://huggingface.c...
355
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A( unittest.TestCase...
355
1
from typing import Union import fire import torch from tqdm import tqdm def lowercase__( A , A = "cpu" , A = None ): snake_case__ : Optional[Any] = torch.load(A , map_location=A ) for k, v in tqdm(state_dict.items() ): if not isinstance(A , to...
303
import operator as op def lowercase__( A ): snake_case__ : Optional[int] = [] snake_case__ : int = lambda A , A : int(x / y ) # noqa: E731 integer division operation snake_case__ : Union[str, Any] = { '^': op.p...
303
1
"""simple docstring""" import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from acceler...
255
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_tor...
514
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_blip_2': [ 'BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Blip2Config', 'Blip2QFormerConfig', ...
715
'''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 (...
8
0
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_processi...
271
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class _snake_case ( lowercase__): UpperCamelC...
413
0
"""simple docstring""" class SCREAMING_SNAKE_CASE__ : def __init__( self : Optional[Any] , lowerCAmelCase : Tuple , lowerCAmelCase : int , lowerCAmelCase : str ): lowerCAmelCase = name lowerCAmelCase = ...
529
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class SCREAMING_SNAKE_CASE__ : def __init__( self : Union[str, Any] ): lowerCAmelCase = {} def __lowercase ( self ...
529
1
'''simple docstring''' from collections.abc import Generator from math import sin def _SCREAMING_SNAKE_CASE ( __snake_case : bytes ): if len(__snake_case ) != 3_2: raise ValueError('Input must be of length 32' ) _A = B'' for i in [3, 2, 1, 0]: ...
107
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( __snake_case : int | str ): _A = str(__snake_case ) return n == n[::-1] def _SCREAMING_SNAKE_CASE ( __snake_case : int = 1_0_0_0_0_0_0 ): _A = 0 f...
107
1
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _A = 'src...
682
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): return 1 if input_a == input_a else 0 def _UpperCAmelCase ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 ...
682
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase ={ "configuration_mobilebert": [ "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE...
697
'''simple docstring''' def a ( _UpperCAmelCase ) -> int: """simple docstring""" assert column_title.isupper() a_ = 0 a_ = len(_UpperCAmelCase ) - 1 a_ = 0 while index >= 0: a_ = (ord(column_title[index] ) - 6_4) * po...
697
1
def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase = False ) -> bool: '''simple docstring''' if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly che...
242
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subproc...
242
1
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
340
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase ={ "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ...
546
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''', '''tiiuae/falcon-7b''': '''https://huggingface.co/...
713
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models at https://huggingf...
373
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_tf cla...
419
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass cla...
681
0
import glob import os import random from string import ascii_lowercase, digits import cva a_ = '''''' a_ = '''''' a_ = '''''' a_ = 1 # (0 is vertical, 1 is horizontal) def _a ( ) -> None: """simple docstring""" lowerCAmelCase__ , low...
720
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate dep...
115
0
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def snake_case__ ( *__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = None , __SCREAMING_SNAKE_CASE=True , __SCREAMING_SNAKE_CASE=2 ) -> Any: from .. import __version__ ...
579
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class __snake_case ( __magic_name__ ): @staticmethod @abstractmethod def _snake_case ( UpperCamelCase_ ) -> Dict: raise NotImplementedError()...
368
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstri...
716
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available,...
245
0
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __A ( SCREAMING_SNAKE_CASE_ ): def __init__( self : Tuple , __snake_case : Any , __sn...
96
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def a ( __UpperCAmelCase : str ) -> Optional[int]: def decorator(__UpperCAmelCase : List[str] ): __magic_name__: Union[str, Any] = ...
96
1
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase =logging.get_logger(__name__) lowercase ={ 'vocab_file': 'vocab.json', 'merges_fi...
331
'''simple docstring''' from __future__ import annotations lowercase ='Muhammad Umer Farooq' lowercase ='MIT' lowercase ='1.0.0' lowercase ='Muhammad Umer Farooq' lowercase ='contact@muhammadumerfarooq.me' lowercase ='Alpha' import re from html.parser import HTMLParser from...
331
1
'''simple docstring''' import argparse import os import re __a = 'src/transformers/models/auto' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __a = re.compile(R'[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedD...
494
'''simple docstring''' import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline __a = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value network 'scale_g...
494
1
'''simple docstring''' import unittest import torch from torch import nn from diffusers.models.activations import get_activation class lowercase_ ( unittest.TestCase ): def _lowercase ( self: List[str]): '''simple docstring''' __lowerCAmelCase ...
716
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) __A : int = {"configuration_beit": ["BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BeitConfig", "BeitOnnxConfig"]} try: if not...
334
0
# 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/LICENSE-2.0 # # Unless requ...
16
import os def __a ( ): SCREAMING_SNAKE_CASE = os.path.join(os.path.dirname(A__ ) , "num.txt" ) with open(A__ ) as file_hand: return str(sum(int(A__ ) for line in file_hand ) )[:10] if __name__ == "__main__": print(so...
16
1
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 transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging....
70
import numpy as np _UpperCAmelCase = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ] ...
70
1
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path...
509
import numpy as np class __lowerCAmelCase : """simple docstring""" def __init__( self : Union[str, Any] ): __lowercase : Optional[int] = (0, 0) __lowercase : List[str] = None __low...
509
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_...
713
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 snake_case = logging.get_logger(__name__) snake_case = "▁" snake_case ...
587
0
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils i...
85
'''simple docstring''' import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMI...
301
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiec...
715
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeli...
479
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Tuple = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''', ...
72
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case ( __UpperCAmelCase ): '''simple docstring''' _A : Optional[int] = 'SpeechT5FeatureExtractor' _A : List[Any] = 'SpeechT...
522
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
708
"""simple docstring""" import string import numpy def A ( snake_case :int , snake_case :int ) -> int: return b if a == 0 else greatest_common_divisor(b % a , snake_case ) class __lowerCAmelCase : lowercase = string.ascii_uppercase + string.digits #...
293
0
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask lowerCamelCase_ = logging.getLogger(__name__) class __a ( __lowerCamelCase ): """simple docstring""" def __init__( self...
151
def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase, __UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ =len(__UpperCamelCase ), len(grid[0] ) if ( min(__UpperCamelCase, __UpperCamelCase ...
151
1
'''simple docstring''' import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import ...
705
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowercase__ ): def __init__( self : Union[str, Any] , *UpperCA...
88
0
from string import ascii_uppercase __UpperCAmelCase : List[str] = {char: i for i, char in enumerate(ascii_uppercase)} __UpperCAmelCase : List[str] = dict(enumerate(ascii_uppercase)) def lowerCamelCase_ ( UpperCamelCase_ , UpperCamelCase_ ): _a : Uni...
471
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __UpperCAmelCase : Union[str, Any] = 299_792_458 # Symbols __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase : Any = symbo...
471
1
from collections.abc import Callable class UpperCamelCase__ : def __init__( self : List[Any] , UpperCamelCase__ : Callable | None = None ): '''simple docstring''' lowercase_ = [] # Stores indexes of each ite...
650
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 impo...
650
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDC...
32
"""simple docstring""" import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed ...
353
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __snake_case : Optional[int] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvaila...
365
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split,...
365
1
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCAmelCase : Optional[int] = TypeVar('KEY') UpperCAmelCase : List[Any] = TypeVar('VAL') @dataclass(frozen=a , slots=a ) class...
627
"""simple docstring""" a_ = { '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', 'd...
76
0
# 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/LICENSE-2.0 # # Unless required by...
701
from __future__ import annotations def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase ): if len(__UpperCamelCase ) == 0: return False SCREAMING_SNAKE_CASE__ =len(__UpperCamelCase ) // 2 if a_list[midpoint] == item: return True if item < a_list[...
588
0
'''simple docstring''' import math def snake_case_ ( ): '''simple docstring''' _snake_case = input("Enter message: " ) _snake_case = int(input(f'''Enter key [2-{len(SCREAMING_SNAKE_CASE__ ) - 1}]: ''' ) ) _snake_case = input("Encryption...
672
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : Optional[int] = logging.get_logger(__name__) __magic_name__ : Optional[int] = { """microsoft/git-base""": """http...
672
1
def _lowerCamelCase ( _a = 2_0_0 ): """simple docstring""" _lowerCamelCase = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] _lowerCamelCase = [0] * (pence + 1) _lowerCamelCase = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(_a , pen...
297
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 import array_cast from ..utils...
297
1
import math def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" return math.sqrt(a_ ) * math.sqrt(a_ ) == num def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" __A = 0 __A = n while left <= r...
55
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, se...
55
1
from __future__ import annotations def lowerCAmelCase_ ( snake_case_,snake_case_ ): _A : list[list[int]] = [] _A : list[int] = [] _A : str = 0 _A : Optional[Any] = sum(lowerCAmelCase_ ) create_state_space_tree(lowerCAmelCa...
706
def lowerCAmelCase_ ( snake_case_,snake_case_ ): _A : Union[str, Any] = """""" for i in table: res += inp[i - 1] return res def lowerCAmelCase_ ( snake_case_ ): return data[1:] + data[0] def lowerCAmelCase_ ( snake_case_,s...
54
0
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 __A = logging.get_logger(__name__) __A = "▁" __A ...
59
"""simple docstring""" def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return x if y == 0 else greatest_common_divisor(lowerCAmelCase__ , x % y ) def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return (x * y) // greatest_common_divisor(lowerCA...
82
0
'''simple docstring''' from typing import Any class a__: def __init__( self : Dict , __snake_case : Any ): a : Dict = data a : Union[str, Any] = None class a__: def __init__( self : int ): a ...
195
'''simple docstring''' from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowerCAmelCase: List[str] = TypeVar('T') def lowerCamelCase__ ( _A ): return (position - 1) // 2 def lowerCamelCase__ ( _A ): return (2 * position) + 1 def ...
195
1
'''simple docstring''' import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @re...
418
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase__ ( UpperCAmelCase ): """simple docstring""" _UpperCamelCase : int = (DDIMParallelScheduler,) _UpperCamelCase : List[Any] ...
551
0
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : Tuple = list(range(len(UpperCamelCase ) ) ) low...
160
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase ): """simple docstring""" while a != 0: lowerCAmelCase__ , lowerCAmelCase__ : Optional[Any] = b % a, a return b def _SCREAMING_SNAKE_CASE ...
160
1
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase = {"""configuration_mmbt""": ["""MMBTConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
174
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.p...
174
1
"""simple docstring""" import re def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : str ): '''simple docstring''' if len(re.findall("""[ATCG]""" , SCREAMING_SNAKE_CASE ) ) != len(SCREAMING_SNAKE_CASE ): raise ValueError("""Invalid Strand""" ...
716
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_co...
393
0
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ...
196
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments A_ : Optional[Any] = logging.getLogger(__name__) @dataclass class ...
196
1
'''simple docstring''' from __future__ import annotations from cmath import sqrt def UpperCamelCase ( lowercase_ , lowercase_ , lowercase_ ) -> List[str]: '''simple docstring''' if a == 0: raise ValueError("""Coefficient \'a\' must not be zero.""" ) lowercase...
718
lowerCamelCase__ : Any = """0.18.2""" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_...
495
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json', # See all Cvt models at ht...
110
"""simple docstring""" import random def lowerCamelCase ( _snake_case ): UpperCAmelCase__ : Tuple = num - 1 UpperCAmelCase__ : Dict = 0 while s % 2 == 0: UpperCAmelCase__ : Optional[int] = s // 2 t += 1 for _ in...
110
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp im...
719
'''simple docstring''' import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration SCREAMING_SNAKE_CASE_ = [ # tf -> hf ('/', '.'), ('layer_', 'layers.'), ('k...
201
0
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils i...
148
import numpy as np def __lowercase ( a__ , a__ , a__ = 1E-12 , a__ = 1_00 , ) -> tuple[float, np.ndarray]: assert np.shape(a__ )[0] == np.shape(a__ )[1] # Ensure proper dimensionality. assert np.shape(a__ )[0] == np.shape(a__ )[0] # Ensure i...
148
1
'''simple docstring''' def lowercase_ ( __A : str , __A : str ) -> int: """simple docstring""" if len(__A ) != len(__A ): raise ValueError('''String lengths must match!''' ) lowercase : List[Any] =0 for chara, chara in zip(__A ...
712
'''simple docstring''' import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import Padd...
8
0
def lowerCamelCase_ ( _UpperCamelCase = 1_000 ) -> int: """simple docstring""" snake_case_ : Any = -1 snake_case_ : Optional[int] = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and ...
60
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase__ : Any = logging.get_logger(__name__) UpperCamelCase__ : Any = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/ma...
105
0
import numpy as np def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Tuple , __UpperCamelCase : Optional[int] ) -> Tuple: """simple docstring""" return np.where(vector > 0 , _snake_case , (alpha * (np.exp(_snake_case ) - 1)) )...
711
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState from...
55
0
'''simple docstring''' from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor from .base import PipelineTool class __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE_ ): __a ="""openai/whisper-base""" __a =( """This is a tool...
448
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = """▁""" a_ = ...
437
0
'''simple docstring''' import random from .binary_exp_mod import bin_exp_mod def __UpperCamelCase ( _A : List[str] , _A : Optional[int]=10_00 ) -> Any: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd lowe...
646
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCamelCase ( _A : np.ndarray , _A : float ) -> np.ndarray: """simple docstring""" lowerCAmelCase : Union[str, Any] = math.sqrt(_A ) lowerCAmelCase : ...
646
1
import os import sys import unittest lowercase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_mapping, ...
354
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, ) lowercase_ = { '''configuration_albert''': ['''ALBER...
354
1
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets _UpperCamelCase : List[Any] = datasets.logging.get_logger(__name__) _UpperCamelCase : str = """\ @inproceedings{bleurt, title={BLEURT:...
720
"""simple docstring""" # 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 #...
118
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A : Optional[int] = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], 'tokenizatio...
15
'''simple docstring''' import math def _a ( __lowerCAmelCase : int ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ...
347
0
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def A_ ( snake_case , snake_case , snake_case , snake_case ): SCREAMING_SNAKE_CASE:Optional[int] = { "en": "Machine learning is great, isn...
465
'''simple docstring''' def A_ ( snake_case , snake_case ): SCREAMING_SNAKE_CASE:Optional[int] = word.split() def justify(snake_case , snake_case , snake_case ) -> str: SCREAMING_SNAKE_CASE:str = max_width - width SCREAMING_SNAKE...
465
1
"""simple docstring""" import math def _lowerCAmelCase(a : int ) -> str: _SCREAMING_SNAKE_CASE =0 _SCREAMING_SNAKE_CASE =0 while num > 0: _SCREAMING_SNAKE_CASE =num % 8 _SCREAMING_SNAKE_CASE =octal + (remainder * math.floor(math.pow(10 , a ) )) ...
255
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) UpperCAmelCase_ : Union[str, Any] = { '''sample_size''': 3_2, '''in_channels''': 3, '''out_chan...
255
1
def __UpperCamelCase ( _lowerCAmelCase : Dict ): """simple docstring""" UpperCAmelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" UpperCAmelCase = "" UpperCAmelCase = "" # append each charac...
711
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from a...
405
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : int = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_bert': ['RoCBer...
89
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Dict = { 'configuration_bigbird_pegasus': [ 'BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BigBirdPegasusConfig', 'BigBirdPegasusOnnxCon...
16
0
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def __snake_case ( UpperCamelCase ) -> str: """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): raise TypeError('''Undefined for non-integers''' ) ...
158
"""simple docstring""" import math def __snake_case ( ) -> None: """simple docstring""" a__ = input('''Enter message: ''' ) a__ = int(input(f"Enter key [2-{len(UpperCamelCase ) - 1}]: " ) ) a__ = input('''Encryption/Decryption [e/d]: ''...
158
1
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
58
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ : Union[str, Any] = logging.get_logger(__name__) lowercase_ : Any = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer...
572
0
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate depr...
381
from __future__ import annotations UpperCamelCase__ =[True] * 100_0001 UpperCamelCase__ =2 while i * i <= 100_0000: if seive[i]: for j in range(i * i, 100_0001, i): UpperCamelCase__ =False i += 1 def lowerCamelCase__ (__lowerCamelCase ):...
381
1
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
import argparse import json from tqdm import tqdm def _A ( ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__snake_case , defau...
693
1
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import require_lza, require...
440
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_ut...
440
1
"""simple docstring""" from __future__ import annotations from random import random class __a : '''simple docstring''' def __init__( self , _lowerCamelCase = None ) -> str: '''simple docstring''' __lowe...
118
"""simple docstring""" def lowerCAmelCase__ ( __magic_name__ = 1_0 ) ->str: if not isinstance(__magic_name__ , __magic_name__ ) or n < 0: raise ValueError("Invalid input" ) __lowercase = 1_0**n __lowercase = 2_8_4_3_3 * (pow(2 ,...
118
1
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 XLNe...
715
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_se...
294
0
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def _a (lowercase__ : Optional[Any] ) -> Optional[Any]: """simple docst...
56
'''simple docstring''' import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class _lowercase ( __lo...
56
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule snake_case_ = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys ...
706
'''simple docstring''' import requests snake_case_ = """YOUR API KEY""" def _lowerCamelCase( UpperCamelCase__ : str , UpperCamelCase__ : str = giphy_api_key ) -> list: A : Optional[Any] = '''+'''.join(query.split() ) A : List[Any] ...
537
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType A_ : ...
650
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
268
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : Any = { 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ] } try: if not is_torch_available(): ...
703
lowerCamelCase : Union[str, Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' lowerCamelCase : ...
684
0
import string def lowercase ( __A : str ) -> str: '''simple docstring''' snake_case : Union[str, Any] = """""" for i in sequence: snake_case : Optional[int] = ord(__A ) if 65 <= extract <= 90: output += chr(155 ...
36
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __UpperCAmelCase ( unittest.TestCase , _UpperCamelCase ): def UpperCAmelCase ( self : Dict ) -> List[Any]: '''simple do...
642
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : Any = { '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface...
706
"""simple docstring""" def _lowerCAmelCase(a : int = 3 , a : int = 7 , a : int = 100_0000 ) -> int: _SCREAMING_SNAKE_CASE =0 _SCREAMING_SNAKE_CASE =1 for current_denominator in range(1 , limit + 1 ): _SCREAMING_SNAKE_CASE =cu...
165
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''', ...
510
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : List[Any]= logging.get_logger(__name__) A__ : Any= { """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", #...
703
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""): A__ : str= { """linear""": PIL.Image.Resampling.BILINEAR, """...
20
0