code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_uti...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class __a ( metaclass=A__ ): """simple docstring""" SCREAMING_SNAKE_CASE_ = ['keras_nlp'] def __init__( self : str , *lowercase_ : int , **lowercase_ : int )...
357
"""simple docstring""" import argparse import os import re _SCREAMING_SNAKE_CASE : List[str] = """src/diffusers""" # Pattern that looks at the indentation in a line. _SCREAMING_SNAKE_CASE : Optional[int] = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in grou...
157
0
'''simple docstring''' UpperCamelCase__ = '''0.21.0''' from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from ...
181
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def snake_case_ ( A_ : Tuple, A_ : int, A_ : Dict ): ...
72
0
'''simple docstring''' import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext fr...
366
'''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, Table...
67
0
from __future__ import annotations _lowerCamelCase : Optional[Any] = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowerCamelCase : Any = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def SCREAMING_SNAKE_CASE ( lowercase_ ) -> ...
14
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: ...
309
0
'''simple docstring''' 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_g...
360
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class UpperCAmelCase__ : __SCREAMING_SNAKE_CASE = 42...
243
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase_ = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTConf...
345
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCamelCase_ ( _a : List[Any] ): '''simple docstring''' UpperCAmelCase_ : Optional[int] = [ """decoder.version""", ...
345
1
from ..utils import DummyObject, requires_backends class a ( metaclass=lowercase__ ): _lowercase = ['onnx'] def __init__( self , *A_ , **A_ ): '''simple docstring''' requires_backends(self , ["onnx"] ) @classmethod def _U...
358
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 a ( UpperCAmelCase ): _lowercase = ["image_proc...
189
0
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArgum...
97
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def lowercase__ ( __UpperCamelCase , __UpperCamelCase , ...
321
0
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForMultipleCh...
122
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case : Union[str, Any] = { """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONF...
122
1
def lowercase ( SCREAMING_SNAKE_CASE__ : int = 600_851_475_143 ) -> int: try: _snake_case : int = int(SCREAMING_SNAKE_CASE__ ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: raise ValueError("""Par...
317
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """xlm-roberta-base""": """https://huggingface.co/xlm-roberta-base/re...
317
1
from bisect import bisect from itertools import accumulate def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = sorted(zip(SCREAMING_SNAKE_CASE , SCREAMI...
93
import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets lowerCAmelCase = '\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n and Saurav Kadavath\n and Akul A...
93
1
'''simple docstring''' import math lowerCamelCase :List[str] = 1_0 lowerCamelCase :List[str] = 7 lowerCamelCase :Dict = BALLS_PER_COLOUR * NUM_COLOURS def a ( lowerCamelCase__ = 20 ): '''simple docstring''' A_ : int = math.comb(low...
206
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a ( lowerCamelCase_...
206
1
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.huggingfac...
65
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import ...
65
1
from random import shuffle import tensorflow as tf from numpy import array def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase): SCREAMING_SNAKE_CASE = int(_UpperCAmelCase) assert noofclusters < len(_UpperCAmelCase) # Find out the dimensionality SCREAMING_SNAKE_CASE ...
137
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def lowerCamelCase__ (_UpperCAmelCase): SCREAMING_SNAKE_CASE = test_file.split(os.path.sep) if components[0:2] !=...
137
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _snake_case : Any = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], 'configuration_data2vec_text'...
207
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _UpperCAmelCase ( unittest.TestCase ): """simple docstring""" def lowercase ( self : Any ) -> Optional[int]: ...
207
1
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _snake_case = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone video of the" ...
26
"""simple docstring""" from ..utils import DummyObject, requires_backends class __A ( metaclass=A_ ): '''simple docstring''' lowerCAmelCase : List[str] = ["torch", "torchsde"] def __init__( self : Tuple ,*_snake_c...
16
0
def SCREAMING_SNAKE_CASE ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase) -> Optional[Any]: return round(float(moles / volume) * nfactor) def SCREAMING_SNAKE_CASE ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase) -> Union[str, Any]: retu...
367
from math import isqrt def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(__UpperCamelCase) + 1)) def SCREAMING_SNAKE_CASE ( __UpperCamelCase = 10**6) -> int: a = 0 a = 1 ...
180
0
from math import sqrt def lowerCamelCase_ ( _a : Union[str, Any] = 100_0000 ): '''simple docstring''' UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int while num_cuboids <= limit: max_cuboid_size += 1 ...
345
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1_337 , num_examples=42 , dataset_name='''my_dataset'''...
182
0
'''simple docstring''' from __future__ import annotations import math def UpperCamelCase_( snake_case : int ): '''simple docstring''' if num <= 0: snake_case_ = f'{num}: Invalid input, please enter a positive integer.' raise ValueE...
92
'''simple docstring''' _SCREAMING_SNAKE_CASE : Optional[int] = "Alexander Joslin" import operator as op from .stack import Stack def UpperCamelCase_( snake_case : str ): '''simple docstring''' snake_case_ = {"*": op.mul, "/": op.truediv, "...
92
1
"""simple docstring""" 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_...
246
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
246
1
"""simple docstring""" import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCase ( snake_case...
363
"""simple docstring""" from math import factorial def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' if successes > trials: raise ValueError("""successes must be lower or equal to trials"...
324
0
"""simple docstring""" import re def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return [char.split() for char in re.split(R"[^ a-z A-Z 0-9 \s]" , str_ )] def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = split_...
57
"""simple docstring""" import sys from collections import defaultdict class _UpperCamelCase : '''simple docstring''' def __init__( self ): __lowerCAmelCase = [] def snake_case ( self , __a ): return self.node_position[vertex] d...
57
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils ...
371
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = {'vocab_file': 'vocab.json'} _a = { 'vocab_file': { 'mgp-str': 'https:/...
23
0
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A__ = """.""" if __name__ == "__main__": A__ = os.path.join(REPO_PATH, """utils/documentation_tests.txt""") A__ = [] A__...
82
'''simple docstring''' import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging...
34
0
"""simple docstring""" from __future__ import annotations from typing import Any class __lowerCAmelCase : def __init__( self , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase = 0 ): '''simple docstring''' __UpperCamelCase , __UpperCamelCase ...
263
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class __lowerCAmelCase : def __init__( self , __UpperCAmelCase ): '''simple docstring''' __UpperCamelCase = str(id_ ) __UpperCamelCase = None __UpperCamelCase...
263
1
"""simple docstring""" from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class A__ ( _lowerCamelCase): def __init__( self , _SCREAM...
86
"""simple docstring""" import unittest from typing import Dict, List, Optional, Union 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 ImageProcessingSavin...
60
0
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) class __a : """si...
356
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE : List[str] = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBi...
157
0
'''simple docstring''' # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/...
319
'''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 UpperCamelCase = logging.get_logger(__name__) ...
319
1
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa im...
257
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_collator...
257
1
'''simple docstring''' import os def UpperCamelCase_ ( ) -> int: '''simple docstring''' with open(os.path.dirname(snake_case_ ) + """/p022_names.txt""" ) as file: __lowerCAmelCase = str(file.readlines()[0] ) __lowerCAmelCase ...
229
'''simple docstring''' import argparse import gc import json import os 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 ...
229
1
"""simple docstring""" # 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...
365
def __UpperCamelCase ( lowercase__ : str ) -> bool: '''simple docstring''' lowerCAmelCase_ : Any = 0 for ch in input_str: lowerCAmelCase_ : Any = ord(lowercase__ ) lowerCAmelCase_ : Dict = pow(2 , lowerc...
28
0
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging log...
262
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand from...
262
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, ...
358
class _UpperCAmelCase : """simple docstring""" def __init__( self : Union[str, Any] , lowerCAmelCase_ : List[str] , lowerCAmelCase_ : int , lowerCAmelCase_ : Dict ) -> List[str]: __lowerCAmelCase = name __lowerCAmelCase = value ...
207
0
"""simple docstring""" from __future__ import annotations snake_case_ = 10 def _lowerCAmelCase ( lowercase_ ): UpperCAmelCase = 1 UpperCAmelCase = max(lowercase_ ) while placement <= max_digit: # declare and ini...
78
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( lowercase_ , lowercase_ , lowercase_ ): UpperCAmelCase = list(range(len(lowercase_ ) ) ) UpperCAmelCase = [v / w for v, w in zip(lowercase_ , lowercase_ ...
78
1
from __future__ import annotations from typing import Any class __a : def __init__( self , lowerCAmelCase__ ) -> None: '''simple docstring''' lowercase__: int = num_of_nodes lowercase__: list[list[int]] = ...
288
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def snake_case_ ( snake_case = 3 ) -> qiskit.result.counts.Counts: if isinstance(snake_case , snake_case ): raise...
288
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ :List[str] = { '''configuration_clap''': [ '''CLAP_PRETRAINED_MODEL_ARCHIVE_LIST''', '''ClapAudioConfig''', '''ClapConfig''', ...
71
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCAmelCase__ : List[Any] =input('''Enter image url: ''').strip() print(F'''Downloading image from {url} ...''') lowerCAmelCase__ : int =BeautifulSoup(requests.get(u...
257
0
'''simple docstring''' import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class ...
360
'''simple docstring''' from math import factorial def _a( UpperCamelCase__ : int = 1_0_0 ): '''simple docstring''' return sum(int(UpperCamelCase__ ) for x in str(factorial(UpperCamelCase__ ) ) ) if __name__ == "__main...
222
0
import cva import numpy as np class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ , A_ ) -> Optional[Any]: if k in (0.04, 0.06): __UpperCamelCase =k __UpperCamelCase =window_size ...
62
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase : Optional[Any] = { "configuration_whisper": ["WHISPER_PR...
204
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowercase : Optional[int] = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GraphormerConfig'], } ...
294
'''simple docstring''' from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')
294
1
import math import random from typing import Any from .hill_climbing import SearchProblem def _UpperCamelCase ( snake_case__, snake_case__ = True, snake_case__ = math.inf, snake_case__ = -math.inf, snake_case__ = math.inf, snake_case__ = -math.inf, snake_case__ = False, snake_case_...
157
def _UpperCamelCase ( snake_case__ ) -> int: __UpperCAmelCase : list[list[int]] = [[0 for _ in range(snake_case__ )] for _ in range(m + 1 )] for i in range(m + 1 ): __UpperCAmelCase : Optional[int] = 1 for n in range(...
157
1
def a__ ( __SCREAMING_SNAKE_CASE = 5_0 ) -> int: __lowerCAmelCase: List[str] = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ways_number[row_length] +...
357
"""simple docstring""" def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: return int((input_a, input_a).count(0 ) == 0 ) def a__ ( ) -> None: assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0...
108
0
"""simple docstring""" from math import pi, sqrt def __UpperCAmelCase ( __lowerCamelCase ) -> float: if num <= 0: raise ValueError('''math domain error''' ) if num > 1_7_1.5: raise OverflowError('''math range error''' ) elif num - int(__lowerCamel...
16
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase ) -> str: if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(__lowerCamelC...
16
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : Tuple ={ "configuration_git": ["GIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GitConfig", "GitVisionConfig"], "processing_git": ["GitProcessor"], } try: if not is_torch...
350
def lowerCAmelCase__ ( lowerCamelCase_ : int ,lowerCamelCase_ : int): '''simple docstring''' while b: lowerCAmelCase__ , lowerCAmelCase__ : Optional[Any] = b, a % b return a def lowerCAmelCase__ ( lowerCamelCase_ : int ,lowerCamelCase...
94
0
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include ...
110
import numpy # List of input, output pairs UpperCAmelCase : str = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) UpperCAmelCase : Optional[int] = (((515, 22, 13), 555), ((61, 35, 49), 150)) UpperCAmelCase ...
95
0
'''simple docstring''' 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 snake_case__ = logging.get_logger(__name__) snak...
4
'''simple docstring''' class UpperCamelCase_ : """simple docstring""" def __init__( self : Optional[Any] , _lowerCamelCase : Union[str, Any] ): """simple docstring""" A_ : Union[st...
4
1
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proce...
9
"""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_...
221
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor UpperCAmelCase: Optional[int] = logging.get_logger(__name__) class UpperCamelCase ( snake_case ): """simple docstring""" ...
336
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase: Tuple = logging.get_logger(__name__) UpperCAmelCase: List[Any] = { """CarlCochet/trajectory-transformer-halfcheetah-medium-v2""": ( """h...
336
1
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, ) __lowerCamelCase : Optional[int]...
52
"""simple docstring""" import qiskit def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> qiskit.result.counts.Counts: A__ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register A__ = qiskit.QuantumCircuit(lower...
247
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_retribert import RetriBertTokenizer __A : Tuple = ...
89
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A : List[str] = ...
89
1
from __future__ import annotations from typing import Any class __A : """simple docstring""" def __init__( self , lowerCamelCase__ ): """simple docstring""" __UpperCamelCase : Optional[Any] =num_...
71
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import...
17
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformer...
33
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING A : List[Any] = logging.get_logger(__name__) A : ...
33
1
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) UpperCAmelCase : Tuple ...
128
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ...
128
1
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, )...
275
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : int ): """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): __magic_name__ : int = f'Input value of [number={number}] must be an integer' raise TypeError(lowerCAmelCase ) if nu...
275
1
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class __lowerCAmelCase : pass
205
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bnb...
146
0
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class A_ : def __init__( self : Union[str, Any] , snake_case_ : str=2 , snake_case_ : L...
356
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int = 100_0000 ) -> int: '''simple docstring''' _UpperCAmelCase = limit + 1 _UpperCAmelCase = [0] * limit for first_term in range(1 , __lowercase ): for...
156
0
"""simple docstring""" # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from...
102
"""simple docstring""" import numpy as np def lowercase ( _snake_case : int , _snake_case : Optional[Any] , _snake_case : Optional[int] , _snake_case : int , _snake_case : Union[str, Any] ) ->Dict: """simple docstrin...
102
1
"""simple docstring""" def A (__A : List[str] , __A : List[Any] , __A : Dict , __A : List[str] ) -> Tuple: """simple docstring""" global f # a global dp table for knapsack if f[i][j] <...
359
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstring...
7
0
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging SCREAMING_SNAKE_CASE_:List[Any] = logging.get_logger(__name__) ...
116
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqCon...
166
0
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('''ignore''', category=UserWarning, module='''torch.optim.lr_scheduler''') class __a : def __init__( ...
366
def lowerCAmelCase__ ( a__: int ) -> None: '''simple docstring''' _UpperCAmelCase = generate_pascal_triangle(a__ ) for row_idx in range(a__ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ' ) ...
185
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) __lowerCamelCase : str = { """roberta-b...
52
'''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 AutoProcessor, BertTo...
22
0
'''simple docstring''' import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' _lowercase : Optional[Any] ...
229
'''simple docstring''' from ...configuration_utils import PretrainedConfig class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' _lowercase : Tuple = '''bert-generation''' def __init__( self , _lowercase=50_358 , _low...
229
1
"""simple docstring""" from typing import List import numpy as np def UpperCAmelCase__ ( lowerCAmelCase__ :dict ) -> int: '''simple docstring''' lowercase = {key: len(lowerCAmelCase__ ) for key, value in gen_kwargs.items() if isinstance(lowerCAmel...
197
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex __lowerCAmelCase : int =logging.getLogger(__name__) class _A : ...
197
1
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessin...
367
'''simple docstring''' from __future__ import annotations import math from collections.abc import Callable def _snake_case ( A , A , A , A = 100 , ) -> float: lowerCAmelCase__ = x_start lowerCAmelCase__ = fnc(A ) ...
228
0
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 A__ : List[str] = 0b10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_...
103
import math def A ( _lowercase ): return math.sqrt(_lowercase ) * math.sqrt(_lowercase ) == num def A ( _lowercase ): SCREAMING_SNAKE_CASE : Dict = 0 SCREAMING_SNAKE_CASE : Tuple = n while left <= right: ...
182
0
'''simple docstring''' import copy import re class lowercase : """simple docstring""" UpperCAmelCase = """hp""" UpperCAmelCase = {} UpperCAmelCase = None @classmethod def _snake_case ( cls ,a_ ,a_ ) -> int: _UpperCAmelC...
351
'''simple docstring''' def snake_case_ ( lowerCAmelCase_ )-> int: '''simple docstring''' if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): raise TypeError("""only integers accepted as input""" ) else: _UpperCAmelCase : Dict ...
349
0
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation ...
48
'''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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils i...
265
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_convbert import ConvBertTokenizer _lowerCAmelCase :Any = logging.get_logger(__name__...
356
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase :int = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'xlm-mlm-...
68
0
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
307
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def a_ ...
307
1
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): if not arr: return None, No...
134
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 _snake_case : int = logging.get_logger(__name__) _snake_case : int = { "micro...
134
1
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def lowercase ( _snake_case : int="ro" , _snake_case : Dict="en" , _snake_case : int="wmt16" , _snake_case : List[str]=None ) ->None: """simple docst...
102
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected" , [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10, "max_num_jobs": 1}, [range...
22
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : str = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of tha...
160
'''simple docstring''' from ...processing_utils import ProcessorMixin class __UpperCAmelCase ( _lowerCamelCase ): __lowercase = """SpeechT5FeatureExtractor""" __lowercase = """SpeechT5Tokenizer""" def __init__( self , lowerCAmelCase_ , lowerCAmelC...
160
1
"""simple docstring""" from heapq import heappop, heappush import numpy as np def __lowercase ( _a , _a , _a , _a , ): snake_case_ : Dict = grid.shape snake_case_ : str = [-1, 1, 0, 0] snake_case_ : Union[str, Any] = [0, 0, -1, 1] if allow_diagonal: ...
264
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_ava...
226
0
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavLM...
350
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _UpperCAmelCase = '\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n author={Wang, Alex and Pr...
328
0
from collections.abc import Sequence def _UpperCAmelCase ( snake_case , snake_case ): """simple docstring""" return sum(c * (x**i) for i, c in enumerate(snake_case ) ) def _UpperCAmelCase ( snake_case , snake_case ): """simple docstring""" _l...
82
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 __lowerCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): @register_to_config def...
82
1
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ran...
20
from __future__ import annotations def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if (direction == 1 and array[ind...
20
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 __a ...
66
import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Model...
24
0
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_property from ...test_tokeniz...
360
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ : Any = TypeVar("KEY") SCREAMING_SNAKE_CASE__ : Dict = TypeVar("VAL") @dataclass(frozen=__lowercase , slots=__lowercase )...
339
0
'''simple docstring''' def __lowerCamelCase ( _lowercase , _lowercase ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def __lowerCamelCase ( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate...
265
'''simple docstring''' from PIL import Image def __lowerCamelCase ( _lowercase , _lowercase ) -> Image: def brightness(_lowercase ) -> float: return 1_2_8 + level + (c - 1_2_8) if not -255.0 <= level <= 255.0: raise ValueError("""level must b...
265
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, XCLIPVisionConfig, ) ...
362
import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_property from ......
342
0
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_obj...
196
'''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 __A ( lowerCamelCase_ ): "...
323
0
'''simple docstring''' import operator as op a_ : List[str] = """scaler.pt""" a_ : Union[str, Any] = """pytorch_model""" a_ : int = """random_states""" a_ : str = """optimizer""" a_ : Tuple = """scheduler""" a_ : Dict = """py...
352
'''simple docstring''' from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def a_ ( ) -> Tuple: """simple docstring""" lowerCamelCase_ ={ '''repo_name''': ['''t...
6
0
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ...
255
'''simple docstring''' import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
89
0
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version SCREAMING_SNAKE_CASE_ = { '<': operator.lt, '<=': operator.le, '==': operator.eq, '!=': operator.ne, '>=': operator.ge, '>': operator.gt, } def __SCREA...
189
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPoo...
189
1
from math import sqrt def snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' lowercase__ : List[str] = 0 for i in range(1 , int(sqrt(SCREAMING_SNAKE_CASE_ ) + 1 ) ): if n % i == 0 and i != sqrt(SCREAMING_SNAKE_CASE_ ): ...
214
def snake_case__ ( SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) lowercase__ : Optional[int] = sorted(string.lower() ) return ...
214
1
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig ...
350
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 __UpperCAmelCase ...
28
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { """junnyu/roformer_chinese_smal...
59
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, ) __lowerCamelCase = {"""configuration_xglm""": ["""...
59
1
"""simple docstring""" from manim import * class snake_case__ ( snake_case_ ): def a__ ( self ): __a = Rectangle(height=0.5 , width=0.5 ) __a = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) __a = Rectangle(heigh...
268
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller SCREAMING_SNAKE_CASE__:List[str] = 3 def _lowerCamelCase( a ): print("Generating primitive root of p" ) while True: __a = ...
268
1
'''simple docstring''' def lowercase__( __UpperCamelCase: list ,__UpperCamelCase: int = 0 ): """simple docstring""" SCREAMING_SNAKE_CASE : int = length or len(SCREAMING_SNAKE_CASE__ ) SCREAMING_SNAKE_CASE : str = False for i in range(le...
251
'''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 UpperCAmelCase_ = logging....
346
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__:Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__:Tuple = { 'facebook/dpr-ctx_encoder-single-nq-base': ( 'https://huggingface.co/facebook/dpr-ctx_encoder-single-...
366
"""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__:Tu...
268
0
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_available...
285
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = {"""vocab_file""": """vocab.txt"""} __snake_case ...
176
0
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTest...
44
from sklearn.metrics import mean_squared_error import datasets A__ = '''\ @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. and Grisel, O. and Blondel, M. and Prettenho...
44
1
A__ = """Input must be a string of 8 numbers plus letter""" A__ = """TRWAGMYFPDXBNJZSQVHLCKE""" def _UpperCAmelCase ( snake_case ): """simple docstring""" if not isinstance(snake_case , snake_case ): _lowerCAmelCase = F'Expected string a...
82
"""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, ...
217
0
"""simple docstring""" from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, i...
312
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_...
312
1
import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECORDS_FILENAM...
110
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, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, ...
284
0
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py lowerCAmelCase : List[str] = """src/diffusers""" # Matches is_xxx_available() lower...
356
"""simple docstring""" import math import random def a__ ( snake_case__ , snake_case__ = False ) -> float: if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowerCAmelCase : Dict = 0.0_2 def a__ ( ...
168
0
"""simple docstring""" import random def _snake_case ( UpperCAmelCase_ : int ): A__ = num - 1 A__ = 0 while s % 2 == 0: A__ = s // 2 t += 1 for _ in range(5 ): A__ = random.ra...
335
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int = 10 ): if not isinstance(UpperCAmelCase_ , UpperCAmelCase_ ) or n < 0: raise ValueError("""Invalid input""" ) A__ = 10**n A__ = 2_8433 * (pow(2 , 783_0457 , ...
335
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor...
360
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def snake_case_ ( __SCREAMING_SNAKE_CASE : str , __SCREAMING_SNAKE_CASE : str , __SCREAMING_SNAKE_CASE : Optional[str] = None ...
264
0
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets UpperCAmelCase : Any = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and...
280
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( a ) -> int: if not nums: return 0 __A : Optional[int] = nums[0] __A : str = 0 for num in nums[1:]: __A , __A : Tuple = ( max_...
280
1
def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> int: return 1 if input_a == input_a else 0 def lowerCAmelCase_ ( ) -> None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate...
328
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqLM, AutoTokeniz...
328
1