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
from __future__ import annotations from random import random from typing import Generic, TypeVar SCREAMING_SNAKE_CASE = TypeVar('KT') SCREAMING_SNAKE_CASE = TypeVar('VT') class __UpperCAmelCase ( Generic[KT, VT] ): """simple docstring"""...
99
'''simple docstring''' def A_ ( snake_case = 600851475143 ): try: SCREAMING_SNAKE_CASE:str = int(snake_case ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater tha...
143
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase = { 'configuration_blenderbot': [ ...
344
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : List[Any] ) -> str: """simple docstring""" global f # a global dp table for k...
344
1
from collections import namedtuple import requests from lxml import html # type: ignore lowercase_ = namedtuple('covid_data', 'cases deaths recovered') def SCREAMING_SNAKE_CASE ( _UpperCAmelCase = "https://www.worldometers.info/coronavirus/" ) -> covid_data: _a = '''...
562
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { 'uw-madison/mra-base-512-4': 'https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json', } class UpperCAme...
322
0
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optuna, default_hp...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : Tuple = { '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP...
333
0
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_rou...
16
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class a__ ( __SCREAMING_SNAKE_CASE ): _A = (KDPMaDiscreteScheduler,) _A = 10 def ...
423
0
def _lowercase ( lowercase__ = 1_0_0_0 ): __lowerCAmelCase : Dict = -1 __lowerCAmelCase : Optional[Any] = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c __lowerCAmelCase : ...
712
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCamelCase = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "tokenization_gpt_neox_j...
583
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine impor...
122
"""simple docstring""" 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_...
83
0
"""simple docstring""" import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib SCREAMING_SNAKE_CASE...
720
"""simple docstring""" import math def __lowerCAmelCase( __UpperCAmelCase ): """simple docstring""" if not isinstance(__UpperCAmelCase ,__UpperCAmelCase ): _lowercase : List[Any] = F'''Input value of [number={number}] must be an integer''' raise TypeError(__UpperCA...
283
0
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAme...
100
'''simple docstring''' # 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 : int = TypeVar("""T""") class lowerCAmelCase_ ( Gen...
349
0
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ ( __A , __A ): '''simple docstring''' lo...
253
from __future__ import annotations def __a ( __UpperCAmelCase : list[int | str] ) -> None: """simple docstring""" create_state_space_tree(__UpperCAmelCase , [] , 0 , [0 for i in range(len(__UpperCAmelCase ) )] ) def __a ( __Upper...
253
1
"""simple docstring""" import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A__ : int = logging.get_logger(__name__) A__...
153
def lowercase ( a , a , a , a ): '''simple docstring''' SCREAMING_SNAKE_CASE_ :int = [False] * len(a ) SCREAMING_SNAKE_CASE_ :List[Any] = [] queue.append(a ) SCREAMING_SNAKE_CASE_ :int = True while queue: SCREAMING_SNAKE_CASE_...
631
0
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated A_ : List[str] = collections.namedtuple("_D...
706
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCamelCase__ ...
419
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json' ), } ...
306
from __future__ import annotations _lowercase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowercase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def __lowerCAmelCase ( _UpperCamelCase ) -> list[float]: '''simple docstrin...
306
1
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tens...
703
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokeniz...
26
0
import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef _snake_case : Union[str, Any] = ( 'This metric will be removed from the...
53
def _UpperCamelCase ( lowercase__ = 10**9 ): __SCREAMING_SNAKE_CASE : List[str] = 1 __SCREAMING_SNAKE_CASE : int = 2 __SCREAMING_SNAKE_CASE : Union[str, Any] = 0 __SCREAMING_SNAKE_CASE : Dict = 0 __SCREAMING_SNAKE_CA...
696
0
import argparse import copy def __magic_name__( SCREAMING_SNAKE_CASE__ : List[str] ) -> int: '''simple docstring''' A__ = {} with open(SCREAMING_SNAKE_CASE__ ) as f: for line in f: if line.split()[0] not in dict_of_neig...
709
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Toke...
586
0
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __magic_name__ ( ): '''simple docstring''' UpperCamelCase__ = ArgumentParser( description=( ...
513
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMSc...
513
1
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_...
490
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def SCREAMING_SNAKE_CASE ( a_ : Tuple ): # This defines a "chinese character" as anything in the CJK Unicode block: # https:/...
490
1
"""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_m...
549
import os import pytest from attr import dataclass SCREAMING_SNAKE_CASE__ : int = "us-east-1" # defaults region @dataclass class snake_case : lowercase_ = 42 lowercase_ = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' lowercase_ = { '...
85
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : List[str] = logging.get_logger(__name__) lowercase : Dict = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json', ...
703
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.models.wavave...
105
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar _A = TypeVar('T') class lowerCamelCase (Generic[T] ): '''simple docstring''' def __init__( self : Tuple , ...
159
"""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 _A = 'http://w...
159
1
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCa...
613
def __UpperCAmelCase( lowercase_ ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection _lowerCamelCase : Tuple = len(lowercase_ ) _lowerCamelCase : List[str]...
613
1
from __future__ import annotations from collections.abc import Generator def snake_case ( ) -> Generator[int, None, None]: _A = {} _A = 2 while True: _A = factor_map.pop(snake_case__ , snake_case__) if factor: ...
401
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class a ( __lowerCAmelCase ): """simple docstring""" ...
401
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ :Optional[Any] = logging.get_logger(__name__) UpperCAmelCase__ :List[str] = { """SCUT-DLVCLab/lilt-roberta-en-base""": ( """https://huggingface....
721
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase () -> str: """simple docstring""" __lowerCamelCase : Any = HfArgumentParser(_lowercase ) __lowerCamelCase : List[str]...
483
0
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/v...
574
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.tes...
81
0
"""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 import BertTokenizer __UpperCAmelCase =logging.get_l...
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
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.sch...
287
'''simple docstring''' import heapq def a__ ( _SCREAMING_SNAKE_CASE : dict ) -> set[int]: """simple docstring""" UpperCAmelCase_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq...
71
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :int = {} class A_ ( _UpperCAmelCase ): _lowerCamelCase ...
704
'''simple docstring''' import sys from collections import defaultdict class A_ : def __init__( self : Dict ): _UpperCAmelCase = [] def lowercase ( self : Union[str, Any] , snake_case_ : List[str] ): return self.node_positi...
119
0
"""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 __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING...
357
"""simple docstring""" def A_ ( __lowercase , __lowercase , __lowercase ): if len(__lowercase ) != len(__lowercase ): raise ValueError('The length of profit and weight must be same.' ) if max_weight <= 0: raise ValueError('max_weight must greater than zero.' ) if any(p < 0 for p in pro...
357
1
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __UpperCAmelCase ( lowerCAmelCase__ ): A__ : Dict = ["image_processor", "tokenizer"] A__ : List[str] = "AutoImageProcessor" A...
709
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a ={ 'configuration_albert': ['ALBERT_PRET...
132
0
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase_ : """simple docstring""" UpperCAmelCase__ : int UpperCAmelCase__ : TreeNode | None = None ...
664
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingf...
664
1
'''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 # n...
603
'''simple docstring''' import argparse __snake_case = """docs/source/_static/js/custom.js""" def A_ ( SCREAMING_SNAKE_CASE_ ) ->Any: with open(SCREAMING_SNAKE_CASE_ , encoding="""utf-8""" , newline="""\n""" ) as f: lowercase_ = f.readlines() lowercase_ = 0 # First le...
603
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ : Tuple = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], 'configuration_maskformer_swin': ['MaskForm...
456
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import require_toke...
456
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : List[Any] = logging.get_logger(__name__) __a : Any = { """facebook/xglm-564M""": """https://huggingface.co/facebook/xglm-564M/resolve/main/config.json""", # See all XGLM models at ht...
522
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) __a ...
522
1
from collections.abc import Sequence def lowerCAmelCase_ ( lowerCamelCase = None ): if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) __magic_name__ : str =nums[0] for i in range(1 , len(lowerCamelCase ) ...
21
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowercase = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMv2Config"], "p...
632
0
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, StableDiffusionPipe...
169
def A (__A : str ) -> list: """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__A ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("doctest").testmod() ...
169
1
import numpy class _snake_case : def __init__( self : Dict, __lowercase : numpy.ndarray, __lowercase : numpy.ndarray ): lowercase__ = input_array # Random initial weights are assigned where first argument is the # number...
413
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggi...
413
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, ...
706
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CO...
380
0
"""simple docstring""" from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer lowerCAmelCase__ = logging.get_logge...
645
"""simple docstring""" from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( lowercase ): """simple docstring""" a : int ="SpeechT5FeatureExtractor" a : Any ="SpeechT5Tokenizer" def __init__( self , snake_case...
645
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/ma...
355
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def __lowercase (_SCREAMING_SNAKE_CASE :List[Any] ): return x + 2 class a__ ( unittest.TestCase ): def lowercase__ ...
355
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
433
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": UpperCAmelCase = argparse.ArgumentParser() parser.add_argument( '--ch...
433
1
"""simple docstring""" def UpperCamelCase_ ( lowerCamelCase : int , lowerCamelCase : Tuple ) -> Tuple: """simple docstring""" __magic_name__ : Dict = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k...
713
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar A = TypeVar("""T""") A = TypeVar("""U""") class _UpperCamelCase ( Generic[T, U] ): """simple docstring""" def __init__( self : Any , snake_case : ...
147
0
'''simple docstring''' from __future__ import annotations from collections import deque class _a : '''simple docstring''' def __init__( self, A ): '''simple docstring''' S...
28
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 t...
225
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.se...
109
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTest...
109
1
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowerCamelCase__ : int = '2.13.1' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('3.7')...
31
import operator as op def UpperCAmelCase_ ( __UpperCAmelCase : str ) -> Any: SCREAMING_SNAKE_CASE_ = [] SCREAMING_SNAKE_CASE_ = lambda __UpperCAmelCase , __UpperCAmelCase : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNA...
31
1
import os def __SCREAMING_SNAKE_CASE ( ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE__ = os.path.dirname(os.path.realpath(__UpperCamelCase ) ) SCREAMING_SNAKE_CASE__ = os.path.join(__UpperCamelCase , """triangle.txt"...
379
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast __lowerCamelCase : Union[str, Any] = datasets.utils.logging.get_logger(__name__) @da...
379
1
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging...
482
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class A__( unittest.TestCase ): def _a ( self : List[str] ) -> str: """simple docstring""" __SCREAM...
482
1
"""simple docstring""" from __future__ import annotations import time __snake_case = list[tuple[int, int]] __snake_case = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, ...
285
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 10_00 ): """simple docstring""" _a , _a = 1, 1 _a = 2 while True: _a = 0 _a = fa + fa _a , _a = fa, f index += 1 ...
285
1
# 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 re...
99
from __future__ import annotations def lowerCAmelCase__(__snake_case ,__snake_case ) -> list[int]: '''simple docstring''' lowerCamelCase__ = 0 lowerCamelCase__ = len(__snake_case ) - 1 while i < j: if nums[i] + nums[j] == target: retur...
481
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config...
709
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
324
0
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transf...
161
def lowerCamelCase_ ( lowerCAmelCase: str )-> str: _snake_case : str = 0 # if input_string is "aba" than new_input_string become "a|b|a" _snake_case : List[Any] = '' _snake_case : Dict = '' # append each character + "|" in new_strin...
411
0
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 ...test_pipeline_mixin im...
707
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy a...
178
0
'''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.apach...
26
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tok...
225
0
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase ( __a): '''simple docstring''' __magic_name__ : int = ["image_processor", "tokenizer"] __magic_nam...
41
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import ...
41
1
import argparse 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 from accelerate import Acceler...
121
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class a__ ( _snake_case ): """sim...
314
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testin...
314
1
'''simple docstring''' from collections import deque from .hash_table import HashTable class lowerCamelCase ( lowerCamelCase ): '''simple docstring''' def __init__( self : Union[str, Any] , *UpperCAmelCase__ : Optional[Any] , **UpperCAmelCase__ : ...
390
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowercase__ : Union[str, Any] = [ ...
390
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Union[str, Any] = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } ...
423
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 lowercase : int = logging.get_logger(__name__) ...
423
1
'''simple docstring''' import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _UpperCamelCase : Any = False...
284
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODE...
284
1
def __magic_name__ ( __a : List[Any] , __a : Optional[Any] ): '''simple docstring''' UpperCamelCase__ = len(__a ) UpperCamelCase__ = [] for i in range(len(__a ) - pat_len + 1 ): UpperCamelCase__ = True for j in range(__a ): ...
701
from __future__ import annotations lowerCamelCase_ = '''#''' class __A: """simple docstring""" def __init__(self ): UpperCamelCase__ = {} def UpperCAmelCase_ (self , SCREAMING_SNAKE_CASE_ ): UpperCamelCase__ = self._trie for char in text: ...
86
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_environm...
511
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logging ...
511
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiec...
450
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort __A : ...
450
1
"""simple docstring""" from __future__ import annotations __A = list[tuple[int, int]] __A = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, ...
346
'''simple docstring''' import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto...
119
0
'''simple docstring''' from sklearn.metrics import mean_squared_error import datasets a : Union[str, Any] = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. ...
672
'''simple docstring''' from collections.abc import Callable import numpy as np def __lowerCamelCase ( _lowercase , _lowercase , _lowercase , _lowercase , _lowercase ) -> np.array: UpperCAmelCase : Optional[Any] = int(np.ceil((x_end - xa) / st...
672
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaConfig", "D...
109
'''simple docstring''' import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import ...
109
1
def _A ( _UpperCamelCase , _UpperCamelCase ): _UpperCAmelCase : Tuple = len(_UpperCamelCase ) _UpperCAmelCase : Tuple = len(_UpperCamelCase ) _UpperCAmelCase : Dict = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] _UpperCAmelCase : List[A...
416
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class lowerCAmelCase_ : def __init__( self : Any , UpperCAmelCase_ : Collection[float] | None = None ) -> None: '''simple...
416
1
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor import At...
10
def lowerCamelCase__ ( snake_case_ : int = 1000 ) -> int: __snake_case = 2**power __snake_case = str(snake_case_ ) __snake_case = list(snake_case_ ) __snake_case = 0 for i in list_num: sum_of_num += int(snake_case_ ) ...
592
0
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP A__ = False try: A__ = _is_package_available("goo...
184
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 __UpperCamelCase ( SCREAMING_SNAKE_CASE , unittest.TestCase ): _lowercase : str = DownBlockaD # noqa...
184
1
import re def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ ): UpperCamelCase__ : Optional[int] = re.compile( R'''^(?:0|94|\+94|0{2}94)''' R'''7(0|1|2|4|5|6|7|8)''' R'''(-| |)''' R'''\d{7}$''' ) return bool(re.search(UpperCamelCase__ , UpperCamelCase__ ) ) if _...
285
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_model...
285
1
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') _SCREAMING_SNAKE_CASE = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) _SCREAMING_SNAKE_CASE = requ...
718
import colorsys from PIL import Image # type: ignore def snake_case ( snake_case__ :float , snake_case__ :float , snake_case__ :int) -> float: _A = x _A = y for step in range(snake_case__): # noqa: B007 _A ...
83
0
'''simple docstring''' from scipy.stats import spearmanr import datasets SCREAMING_SNAKE_CASE = '\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no co...
94
'''simple docstring''' def UpperCamelCase_ ( _UpperCAmelCase : int ) -> list: """simple docstring""" _UpperCAmelCase : Tuple = int(_UpperCAmelCase ) if n_element < 1: _UpperCAmelCase : Tuple = ValueError("a s...
244
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTok...
283
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_tru...
283
1
import numpy as np def UpperCAmelCase__( __UpperCAmelCase : List[str] ): return 1 / (1 + np.exp(-vector )) def UpperCAmelCase__( __UpperCAmelCase : int ): return vector * sigmoid(SCREAMING_SNAKE_CASE__ ) if __name__ == "__main__": import doc...
576
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Union[str, Any] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatureEx...
336
0
import os def A_ ( ) ->Tuple: """simple docstring""" SCREAMING_SNAKE_CASE = os.path.join(os.path.dirname(lowercase_ ) , 'num.txt' ) with open(lowercase_ ) as file_hand: return str(sum(int(lowercase_ ) for line in file_hand ) )[:1_0] if __name__ == "__main__": ...
259
import numpy as np class a_: """simple docstring""" def __init__( self : Any) -> Dict: """simple docstring""" SCREAMING_SNAKE_CASE = (0, 0) SCREAMING_SNAKE_CASE = None SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE...
259
1
'''simple docstring''' 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 impor...
597
'''simple docstring''' from statistics import mean, stdev def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 3 ): __a : List[str] = min(SCREAMING_SNAKE_CASE__ ) __a : Tuple = max(SCREAMING_SNAKE_CASE...
597
1
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALU...
705
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": _lowercase = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=None, type=str, required=True, help="Path to the chec...
526
0
"""simple docstring""" import inspect import re 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 : Tuple = '''src/transformers''' # ...
555
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, loggin...
555
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class snake_case_ ( unittest.TestCase ): """simple docstr...
102
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from datas...
102
1
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __snake_case :Tuple ='https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def lowerCamelCase_ ( lowerCAmelCase__ : str = "mumbai" ) -> Generator[tu...
106
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class lowercase__ ( __SCRE...
475
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase : str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass el...
711
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _A( unittest.TestCase ): """simple docstring""" def UpperCAmelCase_ ( self ): debug_launcher(test_script.main ) de...
77
0
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowerCAmelCase__ ( a , a ): """simple docs...
627
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, )...
627
1
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_proper...
145
'''simple docstring''' _UpperCAmelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def UpperCamelCase ( ) -> None: '''simple docstring''' lowercase =input('''Enter message: ''' ) lowercase =input('''Enter key [alphanumeric]: ''' ) lowercase =i...
145
1
"""simple docstring""" 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, to...
391
"""simple docstring""" import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, Charac...
391
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET...
633
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ :Tuple = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBlipQFormerConfig", ...
633
1
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelC...
271
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class snake_case__(_UpperCamelCase ): """simple docstring""" lowercase_ = (IPNDMScheduler,) lowercase_ = (("""num_inference_steps""", 5_0),) ...
496
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() ex...
707
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase : Tuple =logging.get_logger(__name__) def _lowercase ( ...
237
0
import math def __lowerCAmelCase ( a__ , a__ ) -> int: __a = len(_UpperCamelCase ) __a = int(math.floor(math.sqrt(_UpperCamelCase ) ) ) __a = 0 while arr[min(_UpperCamelCase , _UpperCamelCase ) - 1] < x: ...
219
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase : Union[str, Any] = logging...
405
0
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 PaddingStrategy, l...
718
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretra...
492
0
"""simple docstring""" from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_to...
142
"""simple docstring""" import os def lowerCamelCase_ ( ): lowerCamelCase_ = os.path.dirname(os.path.realpath(_lowerCamelCase ) ) lowerCamelCase_ = os.path.join(_lowerCamelCase , '''triangle.txt''' ) with open(_lowerCamelCase ) as f: ...
142
1
"""simple docstring""" import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils....
614
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() d...
614
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : List[str] = { "configuration_whisper": ["WHI...
261
'''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 .....
261
1
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class a_ : def __init__( self ): a_ = [] a_ = 0 a_ = 0 def lowerCAmelCase__ ( self ): return self.head == self.tail ...
715
'''simple docstring''' import math def UpperCamelCase_ ( A__ ): a_ = [True] * n a_ = False a_ = False a_ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): a_ = i * 2 while index < n: a_ = False a_ = index + i ...
511
0
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging a_ = logging.get_logger(__name__) class lowercase__ : a_ =None @experimental def _a ( UpperCamelCase_ : str , UpperCamelCase_ : ...
339
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowercase ( UpperCamelCase__ ): _a = ["i...
307
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Tuple ) -> list[int]: if num <= 0: raise ValueError('Input must be a positive integer' ) __lowercase = [True] * (num + 1) __lowercase = 2 while p * p <= num: if primes[p]: for i in r...
721
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { """google/umt5-small""": """https://huggingface.co/g...
688
0
from __future__ import annotations import time a_ = list[tuple[int, int]] a_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0...
25
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
0
from collections.abc import Callable import numpy as np def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> np.ndarray: lowerCamelCase : List[Any] ...
262
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets snake_case_ = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, auth...
262
1
"""simple docstring""" from typing import Any def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ,lowercase ,lowercase ,): """simple docstring""" _validation( lowercase ,lowercase ,lowercase ,lowercase ,lowercase ,) # Creates data structures and fill initial step _UpperC...
277
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDi...
277
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/bit-50": "htt...
707
# 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 # # U...
291
0
import string def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int) -> List[Any]: '''simple docstring''' for key in range(len(string.ascii_uppercase)): __UpperCamelCase : int = "" for symbol in message...
557
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]...
34
0
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin fr...
720
from __future__ import annotations a__ = 10 def __UpperCAmelCase ( __a : list[int] ) -> list[int]: """simple docstring""" _a : Union[str, Any] = 1 _a : str = max(__a ) while placement <= max_digit: # declare and initi...
578
0