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 typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_cas...
625
"""simple docstring""" def snake_case__ ( _snake_case : int ): """simple docstring""" if number > 0: raise ValueError("input must be a negative integer" ) UpperCamelCase__ = len(bin(_snake_case )[3:] ) UpperCamelCase__ ...
516
0
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class A_ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): @register_to_config d...
706
a ="""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_librosa_available, is_note_seq...
337
0
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, ...
293
import math import os import sys def lowerCamelCase__ (_UpperCAmelCase): SCREAMING_SNAKE_CASE = '' try: with open(_UpperCAmelCase , 'rb') as binary_file: SCREAMING_SNAKE_CASE = binary_file.read() for dat in data: SCREAMING_SNAKE_CASE ...
73
0
"""simple docstring""" import unittest from knapsack import greedy_knapsack as kp class _lowercase ( unittest.TestCase ): """simple docstring""" def UpperCAmelCase_ ( self : Dict ) -> List[Any]: '''simple docstr...
296
"""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 ...
296
1
import sys def __magic_name__ ( __lowerCAmelCase : str ) -> Union[str, Any]: __lowerCamelCase = len(__lowerCAmelCase ) __lowerCamelCase = [[0 for x in range(__lowerCAmelCase )] for x in range(__lowerCAmelCase )] __lowerCamelCase = ...
298
def __magic_name__ ( __lowerCAmelCase : Any , __lowerCAmelCase : Optional[int] ) -> Optional[Any]: __lowerCamelCase = [1] for i in range(2 , __lowerCAmelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * ...
298
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCAmelCa...
711
'''simple docstring''' import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoToken...
540
0
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import B...
655
from __future__ import annotations class lowerCAmelCase : def __init__( self :Union[str, Any] , _lowercase :List[Any]=None ): '''simple docstring''' lowercase__ = data lowercase__ = None def __repr__( self :Dict ...
655
1
from maths.prime_factors import prime_factors def A ( _UpperCAmelCase : int ) -> int: '''simple docstring''' if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): _UpperCAmelCase = F"Input value of [number={number}] must be an integer" ...
710
from collections import Counter from timeit import timeit def A ( _UpperCAmelCase : str = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def A ...
639
0
import datasets from .evaluate import evaluate _lowerCAmelCase : Tuple ='''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, journal={arXiv preprint arXiv:2103.062...
113
"""simple docstring""" from jiwer import compute_measures import datasets __lowerCAmelCase : Tuple = '''\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title ...
58
0
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _snake_case ( __lowercase ): _lowerc...
705
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, ...
444
0
'''simple docstring''' from timeit import timeit a_ : List[Any] = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a p...
675
'''simple docstring''' from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration a_ : Optional[int] = HfArgumentParser(InitializationArguments) a_ : str = parser.pa...
675
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampl...
712
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig...
299
0
"""simple docstring""" 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 @re...
289
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from t...
615
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProce...
713
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def a__ ( a : Namespace ): """simple docstring""" return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_du...
87
0
'''simple docstring''' 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 lowerCAmelCase__ = ...
596
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): ...
596
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, requi...
657
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
1
"""simple docstring""" from __future__ import annotations def a__ ( SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : list[list[int]] = [] lowerCAmelCase : list[int] = [] ...
645
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Union[str, Any] = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } ...
419
0
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, ...
704
'''simple docstring''' def lowercase_ ( _lowercase = 1_000 ) -> int: '''simple docstring''' lowerCamelCase_ : Any = -1 lowerCamelCase_ : Optional[Any] = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a...
357
0
class __A : def __init__( self :List[str] , __snake_case :str , __snake_case :Optional[Any] ): '''simple docstring''' __magic_name__ : int =name __magic_name__ : Optional[int] =val def __str__( self ...
21
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_dif...
717
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( __A : list[int] , __A : list[int] , __A : int ) -> bool: return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__A ) ) def SCREAMING_SNA...
418
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cach...
418
1
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_tok...
1
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Acceler...
1
1
'''simple docstring''' from itertools import product def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): _snake_case = sides_number _snake_case = max_face_number * dice_number _snake_case = [0] * (max_total + 1) _snake_case = 1 ...
585
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <host> --key_...
282
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A = logging.get_logger(__name__) A = {'vocab_file...
449
'''simple docstring''' # Imports import numpy as np class __snake_case : def __init__( self, A=None, A=None, A=None, A=None, A=None ): """simple docstring""" self.set_matricies(red=A, green=A, blue=A, red_edge=A, nir=A ...
449
1
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm ...
108
'''simple docstring''' def lowerCamelCase ( _snake_case : int = 50_000_000 ): '''simple docstring''' lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 ,prime_square_...
267
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenizati...
715
'''simple docstring''' def _SCREAMING_SNAKE_CASE( snake_case_ : float ) ->float: '''simple docstring''' if edge <= 0 or not isinstance(snake_case_ , snake_case_ ): raise ValueError('''Length must be a positive.''' ) ...
411
0
'''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 __lowerCAmelCase ...
452
'''simple docstring''' 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_aut...
452
1
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class ...
703
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ : Tuple = logging.get_logger(__name__) lowerCAmelCase_ : List[str]...
378
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer _UpperCAmelCase : str = logging.get_logger(_...
683
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils i...
683
1
'''simple docstring''' # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git w...
7
'''simple docstring''' 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 __magi...
7
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def _lowercase ( lowerCamelCase__ ...
168
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __lowercase ( UpperCAmelCase_ ): """simple docstring""" def _SCREAMING_SNAKE_CASE ( self : List[Any] , lowerCAmelCase__ ...
671
0
"""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 ...
109
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( ...
109
1
import argparse import json from tqdm import tqdm def __snake_case ( ): """simple docstring""" A_ = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" ,type=__UpperCamelCase ,default="biencoder-nq-dev.j...
86
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) a = { "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "SPEECHT5_PRETRAINE...
518
0
"""simple docstring""" import os from distutils.util import strtobool def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' for e in env_keys: __SCREAMING_SNAKE_CASE = int(os.environ.get(lowerCAmelCase_ , -1 ) )...
553
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' __SCREAMING_SNAKE_CASE = str(lowerCAmelCase_ ) return n == n[::-1] def UpperCAmelCase__ (lowerCAmelCase_ = 100_0000 ): ...
553
1
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE ( _a ): """simple docstring""" _SCREAMING_SNAKE_CASE = (IPNDMSchedule...
430
'''simple docstring''' import argparse import os import re _lowerCamelCase : int = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict _lowerCamelCase : Union...
430
1
'''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() except OptionalDependencyNotA...
319
'''simple docstring''' import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer __lowerCAm...
319
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import ...
52
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from t...
571
0
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.model...
711
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments _lowercase : Any =logging.getLogger(__name__) @dataclass class SCREAMING_SNAKE_CASE_ ( lowerCAmelCa...
661
0
'''simple docstring''' import re from filelock import FileLock try: import nltk A_ : Optional[int] = True except (ImportError, ModuleNotFoundError): A_ : List[Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) ...
38
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : List[str] = logging.get_logger(__name__) UpperCAmelCase : Any = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-large'''...
239
0
class UpperCamelCase__ : def __init__( self : Optional[int] , UpperCamelCase__ : List[Any] , UpperCamelCase__ : Dict , UpperCamelCase__ : int ): '''simple docstring''' lowercase_ = name ...
712
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor import transformers from transf...
650
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ : Tuple = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
0
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 Conversation A__ ...
183
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ : Dict = { "configuration_efficientnet": [ "EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
703
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availa...
616
0
from __future__ import annotations import math def _A( UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : bool , UpperCamelCase__ : list[int] , UpperCamelCase__ : float ) -> int: '''si...
332
import unittest from knapsack import knapsack as k class a ( unittest.TestCase ): """simple docstring""" def UpperCAmelCase_ ( self : List[Any] ) -> List[str]: """simple docstring""" __lowercase = 0 __lowercase = ...
332
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : List[str] = logging.get_logger(__name__) a_ : str = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json', } class _sn...
444
a_ : Tuple = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '......
444
1
"""simple docstring""" from math import pi, sqrt def lowerCamelCase__ ( __snake_case ) -> float: """simple docstring""" if num <= 0: raise ValueError('''math domain error''' ) if num > 171.5: raise OverflowError('''mat...
19
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowerCamelCase__ ( __snake_case ) -> Optional[Any]: """simple docstring""" ...
19
1
"""simple docstring""" from __future__ import annotations __lowerCAmelCase : Union[str, Any] = list[tuple[int, int]] __lowerCAmelCase : Optional[int] = [ [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, ...
158
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __lowerCAmelCase : Optional[int] = namedtuple( ...
158
1
from __future__ import annotations def lowerCAmelCase_ ( __lowerCamelCase ): if len(__lowerCamelCase ) == 0: return array __snake_case , __snake_case : List[Any] = min(__lowerCamelCase ), max(__lowerCamelCase ) # Compu...
81
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available if is_vision...
81
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCamelCase : Dict = { "configuration_biogpt": ["BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BioGptConfig"], "tokenization_biogpt": ["BioGpt...
457
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowerCamelCase : Any = { "configuration_mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegaConfig", "MegaOnnxConfig"], } try: if not is_torch_availa...
457
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : int = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/co...
17
from collections import defaultdict def a__ (__lowercase :str , __lowercase :str ) -> bool: _A : Union[str, Any] = first_str.lower().strip() _A : int = second_str.lower().strip() # Remove whitespace _A : int = first_str.replac...
206
0
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
2
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("""The given input must be positive""" ) # get the generated string sequence snake_case_ ...
2
1
from __future__ import annotations import math def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> Optional[int]: SCREAMING_SNAKE_CASE : List[Any] = u for i in range(1 , __lowerCAmelCase ): SCREAMING_SNAKE_CASE : Optional[i...
352
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, Be...
277
0
from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Tuple ): """simple docstring""" return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
547
from __future__ import annotations lowerCamelCase__ = """Muhammad Umer Farooq""" lowerCamelCase__ = """MIT""" lowerCamelCase__ = """1.0.0""" lowerCamelCase__ = """Muhammad Umer Farooq""" lowerCamelCase__ = """contact@muhammadumerfarooq.me""" lowerCamelCase__ = """Alpha""" import re from html.parser im...
547
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { ...
94
from __future__ import annotations from typing import Any class __UpperCamelCase : '''simple docstring''' def __init__( self , lowerCamelCase__ ): UpperCAmelCase__: Optional[int] = num_of_nodes UpperCAmelCase__: list[list[int]] = [] UpperCAmel...
113
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 belongs to V an...
536
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = 1 / sqrt(2 ) ): """simple docstring""" A__...
536
1
'''simple docstring''' import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is...
460
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowerCamelCase : str = lo...
460
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json' ...
718
def _lowerCamelCase ( A_ : int , A_ : int ) -> int: '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def _lowerCamelCase ( ) -> None: '''simple docstring''' assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , ...
582
0
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) _snake_case = lo...
655
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_torch @require_tor...
655
1
import datasets from .evaluate import evaluate __SCREAMING_SNAKE_CASE : Any = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv p...
702
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class lowercase_ ( datasets.BuilderConfig ): _lowerCamelCase = None class lowercase_ ( datasets.Ar...
580
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 a...
35
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
322
0
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.uti...
476
UpperCAmelCase_ = { '''Pillow''': '''Pillow<10.0.0''', '''accelerate''': '''accelerate>=0.20.3''', '''av''': '''av==9.2.0''', '''beautifulsoup4''': '''beautifulsoup4''', '''black''': '''black~=23.1''', '''codecarbon''': '''codecarbon==1.2.0''', '''cookiecutter''': '''cook...
476
1
'''simple docstring''' import math def __UpperCamelCase( _A : int ): '''simple docstring''' if not isinstance(_A , _A ): UpperCAmelCase__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_A ) if number < 1: Upp...
614
'''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', level=logging...
614
1
import qiskit def A ( lowercase = 2 ) -> qiskit.result.counts.Counts: '''simple docstring''' UpperCamelCase = qubits # Using Aer's simulator UpperCamelCase = qiskit.Aer.get_backend('aer_simulator' ) # Creating a Quantum Circuit acting on the q register UpperCamelCase...
3
from collections.abc import Callable def A ( lowercase , lowercase , lowercase ) -> float: '''simple docstring''' UpperCamelCase = a UpperCamelCase = b if function(lowercase ) == 0: # one of the a or b is a root for the function return a elif function(lowerc...
3
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorT...
68
"""simple docstring""" import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import Generatio...
682
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 lowercase : Dict = collections.named...
159
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available fr...
159
1
'''simple docstring''' import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='''%(message)s''') def __a ( _UpperCamelCase: Any ) -> np.ndarray: """simple docstring""" return input_array.re...
185
def __a ( __lowerCAmelCase ) -> List[str]: stooge(__lowerCAmelCase , 0 , len(__lowerCAmelCase ) - 1 ) return arr def __a ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> int: if i >= h: return ...
352
0
'''simple docstring''' import numpy as np def UpperCamelCase__ ( _lowercase : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
466
'''simple docstring''' def UpperCamelCase__ ( _lowercase : int ) -> int: if not isinstance(_lowercase , _lowercase ): __UpperCAmelCase: List[str] = F'''Input value of [number={number}] must be an integer''' raise TypeError(_lowercase ) if number < 1: __...
466
1
'''simple docstring''' def A (__lowerCamelCase :str ): _lowerCAmelCase = len(__lowerCamelCase ) while cur > 1: # Find the maximum number in arr _lowerCAmelCase = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi _low...
5
"""simple docstring""" import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE...
156
0
"""simple docstring""" import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING fr...
712
"""simple docstring""" from __future__ import annotations from functools import lru_cache from math import ceil SCREAMING_SNAKE_CASE : str = 100 SCREAMING_SNAKE_CASE : str = set(range(3, NUM_PRIMES, 2)) primes.add(2) SCREAMING_SNAKE_CASE : int for prime in...
229
0
'''simple docstring''' import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __UpperCAmelCase ( __a ): __A : Dict = (DDIMParallelScheduler,) __A : int = (('eta', 0.0), ('num_inference_steps', 50)) ...
274
'''simple docstring''' from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE_ = CustomTokenizer pass
316
0
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_c...
703
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() __snake_case : str = [ """word_embeddings_laye...
365
0
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = '▁' ...
558
import random from .binary_exp_mod import bin_exp_mod def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE=1000 ) -> Optional[int]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd lowerCamelCa...
311
0
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def SCREAMING_SNAKE_CASE ( lowercase_ : Optional[Any] , lowercase_ : Tuple ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(lowerca...
703
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO, ) lowercase_ : ...
653
0
'''simple docstring''' import os def UpperCamelCase ( ) -> str: '''simple docstring''' with open(os.path.dirname(lowercase_ ) + '''/grid.txt''' ) as f: lowercase =[] # noqa: E741 for _ in range(2_0 ): l.append([int(lowercase_ ) for x in f.readline().split()] ) lowe...
72
'''simple docstring''' def a__ ( UpperCamelCase_ : int | float | str ): try: UpperCAmelCase__ :Union[str, Any] = float(UpperCamelCase_ ) except ValueError: raise ValueError('''Please enter a valid number''' ) UpperCAmelCase__ :List[str] ...
467
0
"""simple docstring""" from math import factorial def lowerCAmelCase_ ( UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : float ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to tri...
442
"""simple docstring""" # Algorithm for the pigeonhole sorting def lowerCAmelCase_ ( UpperCamelCase__ : Dict ): """simple docstring""" __lowercase = min(UpperCamelCase__ ) # min() finds the minimum value __lowercase = max(UpperCamelCase__ ) # ma...
442
1
from __future__ import annotations from dataclasses import dataclass @dataclass class _A : SCREAMING_SNAKE_CASE : float SCREAMING_SNAKE_CASE : TreeNode | None = None SCREAMING_SNAKE_CASE : TreeNode | None = None def A_ ( a ): """simple docstring""" def is_...
511
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
511
1
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _UpperCAmelCase = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Lear...
715
_UpperCAmelCase = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': 'ABBAA', 'o': 'ABBAB', 'p': 'ABBB...
371
0
'''simple docstring''' def _snake_case ( A = 3 , A = 7 , A = 1000000 ) -> int: lowerCAmelCase__ = 0 lowerCAmelCase__ = 1 for current_denominator in range(1 , limit + 1 ): lowerCAmelCase__ = ...
90
"""simple docstring""" import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput SCREAMING_SNAKE_CASE_ = '''scheduler_config.json''' class _UpperCAmelCase ( SCREAMI...
373
0
"""simple docstring""" import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch __SCREAMING_SNAKE_CASE ="sshleifer/b...
477
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def lowercase__( ): print('Making key files...' ) make_key_files('rsa' , 10_24 ) print('Key files generation...
477
1
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase__ : Optional[int] = 6_3_7_8_1_3_7.0 UpperCAmelCase__ : Any = 6_3_5_6_7_5_2.3_1_4_2_4_5 UpperCAmelCase__ : List[str] = 6_37_81_37 def A...
48
'''simple docstring''' def A ( UpperCamelCase_ : str , UpperCamelCase_ : int ) -> list: '''simple docstring''' lowerCAmelCase__ = word.split() def justify(UpperCamelCase_ : list , UpperCamelCase_ : int , UpperCamelCa...
48
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = {"v...
705
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision,...
92
0
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig 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_configurat...
42
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def __UpperCamelCase ( A ): UpperCamelCase__ = args.pruning_method UpperCamelCase__ = args.threshold UpperCame...
415
0
"""simple docstring""" import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( ...
710
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[Any] = { """asapp/sew-d-tiny-100...
229
0
'''simple docstring''' import math import qiskit def A_( A : int = 1 , A : int = 1 , A : int = 1): if ( isinstance(A , A) or isinstance(A , A) or isinstance(A , A) ): raise TypeError(...
3
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_...
161
0
'''simple docstring''' from scipy.stats import pearsonr import datasets __magic_name__ = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-...
712
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
314
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
473
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor,...
536
0
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowercase : """simple docstring""" _a = 42 # [batch_size x 3] _a = 42 # [batch_size x 3] _a = 42 # [batch_size x 3] _a ...
280
'''simple docstring''' class lowercase : """simple docstring""" def __init__( self , UpperCamelCase_ ): '''simple docstring''' UpperCamelCase__ :Union[str, Any] = n UpperCamelCase__ :Tuple = [None] * self.n UpperCamelCase...
280
1
"""simple docstring""" 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 ...
549
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : List[Any] = {'''conf...
549
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __SCREAMING_SNAKE_CASE( a_ , a_ ): @register_to_config def __init__( self: List[Any] , *, UpperCamelCase: int ...
719
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_...
372
0
"""simple docstring""" import math def a ( __UpperCAmelCase : list , __UpperCAmelCase : int ) -> int: __magic_name__: str = len(__UpperCAmelCase ) __magic_name__: Optional[int] = int(math.floor(math.sqrt(__U...
96
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) snake_case : int = {} try: if not is_sentencepiece_available...
545
0
'''simple docstring''' import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self , snake_case_ , snake_case_ , snake_case_ ): '''simple docstring''' if dst_width < 0 or d...
389
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __...
389
1
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionCo...
21
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 lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase ...
170
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class lowerCamelCase_ ( UpperCAmelCase_ ): ...
452
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipel...
452
1
from __future__ import annotations import math def _lowerCamelCase ( __A : int ) -> int: 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 nu...
485
from __future__ import annotations from collections.abc import MutableSequence class UpperCAmelCase_ : """simple docstring""" def __init__( self: List[Any] , _UpperCAmelCase: int , _UpperCAmelCase: MutableSequence[float] ): if len(_UpperCAmelCase ) != degree...
687
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil a = 100 a = set(range(3, NUM_PRIMES, 2)) primes.add(2) a = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in...
347
'''simple docstring''' import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common i...
347
1
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 Accelerator from datasets imp...
623
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, UNetaDConditionModel from diffusers.u...
623
1
"""simple docstring""" import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Ber...
714
"""simple docstring""" import argparse import copy def lowerCamelCase (a_ :Union[str, Any]) -> Tuple: lowercase :Dict = {} with open(a_) as f: for line in f: if line.split()[0] not in dict_of_neighbours: ...
475
0
"""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 impo...
642
"""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
1
def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ ): if discount_rate < 0: raise ValueError("Discount rate cannot be negative" ) if not cash_flows: raise ValueError("Cash flows list cannot be empty" ) lowerCamelCase_ = sum( cash_flow ...
706
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): def SCREAMING_SNAKE_CASE_( self ) -> None: lowerCamelCase_ = Vector([1, 2, 3] ...
313
0
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def ...
552
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransforme...
555
0
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version UpperCamelCase_...
714
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseConfig, ...
381
0