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
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __snake_case = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def _A ( _lowercase = "mumbai" ) -> Generator[tuple[str, s...
310
import math def _A ( _lowercase ) -> int: """simple docstring""" if not isinstance(_lowercase , _lowercase ): __UpperCamelCase = f'''Input value of [number={number}] must be an integer''' raise TypeError(_lowercase ...
310
1
"""simple docstring""" from __future__ import annotations from math import pi def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if inductance < ...
368
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase )...
257
0
def lowerCamelCase_ ( UpperCamelCase__ : int = 1000 ) -> int: """simple docstring""" __lowerCamelCase = -1 __lowerCamelCase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and...
90
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency __A = { "E": 1_2.7_0, "T": 9.0_6, "A": 8.1_7, "O": 7.5_1, "I": 6.9_7, "N": 6.7_5, "S": 6.3_3, "H": 6.0_9, "R": 5.9_9, "D": 4.2_5, "L": 4.0_3, "C": 2.7_8...
90
1
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`""")
352
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a ={ """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", """BigBirdPegasusOnnxConfig""", ...
113
0
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_t...
75
'''simple docstring''' import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, Ada...
75
1
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils i...
239
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _SCREAMING_SNAKE_CASE( unitt...
239
1
def __lowerCamelCase ( __a :List[str] ) -> int: """simple docstring""" A__ = [] A__ = [] A__ = { """^""": 3, """*""": 2, """/""": 2, """%""": 2, """+""": 1, """-""": 1, } # Priority of ea...
274
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def __lowerCamelCase ( ...
274
1
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeli...
305
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
305
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def a ( snake_case__: Any , snake_case__: Union[str, Any] , snake_case__: Optional[Any] ): '''simple docstring''' lowercase_ ...
30
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): lowercase__ = (CMStochasticIterativeScheduler,) lowercase__ ...
136
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Dict = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } ...
264
'''simple docstring''' from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def snake_case_ ( __SCREAMING_SNAKE_CASE : int ): """simple docstring""" lowercase_ : Tuple = prime_factors(__SCREAMING_S...
264
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig _a = { 'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/config.json', 'albert-large-v1': 'https://h...
61
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase : List[str] = 5_0000 _lowerCamelCase : Optional[int] = 5000 _lowerCamelCase ,_lowerCamelCase : int = os.pa...
28
0
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin...
357
def UpperCAmelCase_ ( __UpperCAmelCase : Optional[Any] , __UpperCAmelCase : Union[str, Any] ) -> List[str]: SCREAMING_SNAKE_CASE_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 ...
210
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
226
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def a ( _UpperCAmelCase : Any , _UpperCAmelCase : Any=None ): '''simple docstring''' ...
226
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging lowercase__ : List[Any] = loggin...
363
'''simple docstring''' import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTes...
287
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : Union[str, Any] = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructB...
91
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) class lowerCAmelCase__ ( UpperCAmelCase__ ): '''simple docstring''' def __ini...
91
1
def UpperCAmelCase ( ) -> Union[str, Any]: """simple docstring""" for n in range(1 , 1_0_0_0_0_0_0 ): yield n * (n + 1) // 2 def UpperCAmelCase ( a_ ) -> Tuple: """simple docstring""" __A ...
369
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE :Any = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_rag': ['RagTokenizer'], } try: ...
124
0
"""simple docstring""" from __future__ import annotations def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->list[tuple[int, int]]: a__ , a__: Union[str, Any] = position a__: int = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), ...
290
"""simple docstring""" from math import pow, sqrt def __a ( *_SCREAMING_SNAKE_CASE ) ->bool: a__: Union[str, Any] = len(_SCREAMING_SNAKE_CASE ) > 0 and all(value > 0.0 for value in values ) return result def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
290
1
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfo...
98
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
98
1
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from...
104
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, Stabl...
174
0
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) UpperCAmelCase : Any = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/co...
331
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def a__ ( a__ ): """simple docstring""" __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = analyze_text(a__ ) ...
331
1
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def lowercase__ (...
29
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
0
from decimal import Decimal, getcontext from math import ceil, factorial def lowerCAmelCase( __lowerCamelCase ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise TypeError('Undefined for non-integers' ) elif precision < 1: raise ValueEr...
197
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : Optional[int] = {"""configuration_xlnet""": ["""XLNET_PRETRA...
197
1
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard @...
21
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformer...
317
0
from queue import PriorityQueue from typing import Any import numpy as np def UpperCamelCase__( UpperCamelCase__ : dict , UpperCamelCase__ : str , UpperCamelCase__ : set , UpperCamelCase__ : set , UpperCamelCase__ : dict , UpperCamelCase__...
39
from __future__ import annotations import time import numpy as np a__: Optional[Any] = [8, 5, 9, 7] a__: Dict = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a__: List[Any] = [ [3, 2, 1, 4], [0, 2, 5, 2], ...
39
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_P...
144
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test...
144
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''BAAI/AltCLIP''': '''https://huggingface.co/BAAI/AltC...
101
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ = 1_00 ) -> int: A_ = n * (n + 1) * (2 * n + 1) / 6 A_ = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(f"""{solution() = }""")
101
1
import math class _snake_case : '''simple docstring''' def __init__( self: Tuple ,lowerCamelCase_: Tuple=0 ) -> Dict: # a graph with Node 0,1,...,N-1 UpperCAmelCase_ : Union[str, Any] = n UpperCAmelCase_ : int = [ [mat...
345
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_availabl...
345
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __snake_case : Tuple ={ 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeTowerConfig', 'BridgeTowerTextConf...
94
__snake_case : Any ='\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' __snake_case : Tuple =[{'type':...
94
1
from __future__ import annotations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): if partitions <= 0: raise ValueError('partitions must be a positive number!' ) if partitions > number_of_bytes: raise ValueError('...
62
"""simple docstring""" import numpy as np from PIL import Image def lowercase_ ( _lowerCamelCase: np.ndarray , _lowerCamelCase: int , _lowerCamelCase: int ) -> np.ndarray: '''simple docstring''' __lowerCamelCase : Dict = np.array...
135
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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, ...
356
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_...
31
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { '''facebook/dpr-ctx_encoder-single-nq-base''': ( '''https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/c...
188
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ra...
188
1
"""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 ...
324
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmu...
324
1
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common impor...
38
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging logging.set_...
188
0
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : List[str] = { '''facebook/encodec_2...
309
"""simple docstring""" 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 : Union[str, Any] = logging.get_logger(__name__) __...
309
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0,...
319
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a : Optional[int] = logging.get_logger(__name__) __a : Tuple = { """facebook/data2vec-text-base""": """https://...
210
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging a__ : Tuple ...
195
"""simple docstring""" a__ : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def UpperCAmelCase__ (): '''simple docstring''' __SCREAMING_SNAKE_CASE = input("Enter message: " ) __SCREAMING_SNAKE_CASE = input("Enter key...
195
1
from collections import Counter from timeit import timeit def __A ( __lowerCAmelCase = "" , )-> bool: """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def __A ( __lowerCAmelCase = "" )...
39
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowerCamelCase ( snake_case__): ...
39
1
def lowerCAmelCase__ ( _a : int , _a : Tuple ): while second != 0: snake_case_ : Union[str, Any] = first & second first ^= second snake_case_ : List[Any] = c << 1 return first if __name__ == "__main__": import doctest doctes...
362
def lowerCAmelCase__ ( _a : int = 50 ): snake_case_ : Union[str, Any] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_length ): ...
36
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
101
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
101
1
"""simple docstring""" _lowerCAmelCase : Optional[Any] = [ '''DownloadConfig''', '''DownloadManager''', '''DownloadMode''', '''StreamingDownloadManager''', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_downl...
340
"""simple docstring""" # 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...
340
1
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accelerat...
24
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from...
174
0
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": _UpperCamelCase : Optional[Any] = '%20'.join(argv[1:]) if len(argv) > 1 else q...
186
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _UpperCamelCase : List[str] = logging.get...
186
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrained...
291
'''simple docstring''' import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_s...
31
0
"""simple docstring""" def _lowerCAmelCase ( lowercase_ , lowercase_ ): while b: UpperCAmelCase , UpperCAmelCase = b, a % b return a def _lowerCAmelCase ( lowercase_ , lowercase_ ): return a if b ...
359
"""simple docstring""" from collections import deque class A_ : """simple docstring""" def __init__( self :Any , lowercase_ :str , lowercase_ :int , lowercase_ :int ) -> None: UpperCAmelCase = pr...
181
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase__ ( a): '''simple docstring''' __SCREAMING_SNAKE_CASE = "ClapFeatureExtractor" __SCREAMING_SNAKE_CASE = ("RobertaTokenizer", "RobertaTokenizerFast")...
11
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowerCamelCase__ ( ctypes.Structure ): """simple docstring""" __a = ...
115
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nice mi...
361
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNetaDCondi...
165
0
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { """facebook/encodec_24khz""": """https://huggingface.co/facebook/en...
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
import os def snake_case_ (): '''simple docstring''' _a = os.path.dirname(os.path.realpath(UpperCamelCase ) ) _a = os.path.join(UpperCamelCase , '''triangle.txt''' ) with open(UpperCamelCase ) as f: ...
360
'''simple docstring''' from ..utils import DummyObject, requires_backends class A ( metaclass=_a ): lowercase_ = ['torch', 'scipy'] def __init__( self : Tuple , *lowerCAmelCase_ : str , **lowerCAmelCase_ : Any ) -> ...
179
0
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ......
237
"""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, flip_channel_order, get_resize_output_image_size, res...
202
0
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor lowerCamelCase_ = logging.get_logger(__name__) class __A( __lowerCamelCase ): """simple docstring""" def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_...
359
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __magic_name__ ( __a : Dict , __a ...
178
0
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
56
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast from...
36
0
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import torch ...
293
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class __snake_...
293
1
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @sl...
313
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType a__ : Any = logging....
313
1
'''simple docstring''' import fire from utils import calculate_rouge, save_json def lowerCamelCase__ ( __lowerCamelCase : Dict , __lowerCamelCase : Dict , __lowerCamelCase : Optional[int]=None , **__lowerCamelCase : Tuple ): '''simple docstring''' ...
370
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
242
0
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) Upper...
186
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available(): ...
186
1
def snake_case (__lowercase , __lowercase ) -> int: '''simple docstring''' return 1 if input_a == input_a else 0 def snake_case () -> None: '''simple docstring''' assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 asser...
350
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowercase_ : _lowerCamelCase = 42 _lowerCamelCase = 42 class lowercase_ : def __init__( self , ...
284
0
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase_( snake_case : Tuple ): '''simple docstring''' snake_case_ = FileLock(str(tmpdir / "foo.lock" ) ) snake_cas...
85
'''simple docstring''' 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 AutoProc...
181
0
"""simple docstring""" def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case ) -> int: """simple docstring""" def count_of_possible_combinations(__snake_case ) -> int: if target < 0: return 0 if targe...
100
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""...
100
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCAmelCase__ = {'''tokenization_bertweet''': ['''BertweetTokenizer''']} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys lowerCAmelCase__ = _LazyModul...
104
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbosity...
231
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 imp...
352
def A__ ( __lowerCamelCase = 10_00 ): return sum(2 * a * ((a - 1) // 2) for a in range(3, n + 1 ) ) if __name__ == "__main__": print(solution())
257
0
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask ...
96
import math def A_ ( snake_case : int ) -> bool: '''simple docstring''' return math.sqrt(snake_case ) * math.sqrt(snake_case ) == num def A_ ( snake_case : int ) -> bool: '''simple docstring''' ...
328
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor _lowercase: Optional[int] = logging.get_logger(__name__) class _lowercase ( A_ ): """simple docstring""" def __init__(self , *low...
360
def a( ) -> str: """simple docstring""" a = 0 for i in range(1 , 1001 ): total += i**i return str(A )[-10:] if __name__ == "__main__": print(solution())
71
0
"""simple docstring""" import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def lowerCamelCase_ (UpperCamelCase__ : str ): _UpperCAmelCase : List[str] = [ '''encoder.version''', ...
263
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device _lowerCAmelCase :Optional[Any] = False class _UpperCA...
263
1
'''simple docstring''' from math import pi, sqrt def a__ ( lowerCAmelCase__ ) -> float: if num <= 0: raise ValueError('''math domain error''' ) if num > 1_7_1.5: raise OverflowError('''math range error''' ) elif num - int(lowerCAmelCase__ ) n...
299
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def a__ ( lowerCAmelCase__ ) -> None: UpperCAmelCase__ , UpperCAmelCase__ : Optional[Any] = analyze_text(lowerCA...
299
1
"""simple docstring""" import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met ...
293
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusion...
293
1
from __future__ import annotations def lowercase( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> tuple[float, list[float]]: '''simple docstring''' UpperCamelCase = list(range(len(UpperCamelCase_ ) ) ) UpperCamelCase = [v / w for v, w in zip(...
165
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowercase( UpperCamelCase_ = True , *UpperCamelCase_ , **UpperCamelCase_ ) -> int: '''simple docstring''' if not is_tqdm_available(): ...
165
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : Dict = logging.get_logger(__name__) _UpperCamelCase : List[Any] = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class snak...
304
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __A : Tuple = collections.namedtuple('''_Datasets''', ['''train''', '...
138
0
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 a__ = logging.get_lo...
15
from math import ceil def __UpperCAmelCase ( __a : int = 1_001 ) -> int: """simple docstring""" _a : Dict = 1 for i in range(1 ,int(ceil(n / 2.0 ) ) ): _a : int = 2 * i + 1 _a : ...
15
1
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint S...
296
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.im...
296
1
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeat...
348
import requests __A = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def lowerCamelCase_ ( UpperCamelCase__ : str ) -> None: """simple docstring""" __lowerCamelCase = requests.get(_NEWS_API + bbc_news_api_key ).jso...
348
1
from collections import defaultdict class __lowerCAmelCase : def __init__( self , __UpperCAmelCase , __UpperCAmelCase ): '''simple docstring''' __lowerCamelCase = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are s...
330
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration a_ = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """weight"""), ...
330
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __SCREAMING_SNAKE_CASE : Union[str, Any] = { 'configuration_canine': ['CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CanineConfig...
368
"""simple docstring""" import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.u...
233
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Optional[int] = { "bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolv...
125
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int = 100 ) -> int: UpperCAmelCase_ : Tuple = n * (n + 1) * (2 * n + 1) / 6 UpperCAmelCase_ : Optional[int] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_...
125
1
"""simple docstring""" import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConf...
366
class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Union[str, Any] , UpperCAmelCase_ : list ): SCREAMING_SNAKE_CASE : Union[str, Any] = set_counts SCREAMING_SNAKE_CASE : Any = max(UpperCAmelCase_ ) SCREAMING_SNAKE_CASE ...
319
0
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_al...
8
A_ :str = '''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 .data_loader import s...
71
0
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.uti...
57
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : str = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available(): raise Option...
57
1
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...t...
299
def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = [] SCREAMING_SNAKE_CASE_ = [] SCREAMING_SNAKE_CASE_ = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, '''-''': 1, } # Priority of each operator SCREAMING_SNAKE_CASE_ ...
299
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class A ( unittest.TestCase , lowerCa...
356
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowerCAmelCase = {'''UserAgent''': UserAgent().random} def _lowerCamelCase( lowercase__ ) -> dict: '''simple docstring''' __lowercase= scr...
304
0
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers,...
217
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from tra...
217
1
'''simple docstring''' from math import factorial def UpperCAmelCase_ ( __lowercase : int = 100 ) -> int: '''simple docstring''' return sum(map(__lowercase , str(factorial(__lowercase ) ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Numb...
156
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int , __lowercase : Optional[int] , __lowercase : List[Any] , __lowercase : int ) -> Tuple: '''simple docstring''' _UpperCAmelCase = [False] * l...
156
1
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 SCREAMING_SNAKE_CASE :int =...
15
# Copyright 2021 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 app...
15
1
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class...
363
"""simple docstring""" from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE_ ( snake_case : int = 1_500_000 )-> int: _lowerCamelCase = defaultdict(snake_case ) _lowerCamelCase = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: ...
80
0
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common ...
90
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowercase : Optional[int] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # ...
232
0
def _a ( UpperCAmelCase , UpperCAmelCase ) -> list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(UpperCAmelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
265
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging _A : List[str] = lo...
265
1
import gc import unittest from transformers import CTRLConfig, 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 ModelTester...
186
'''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
0
"""simple docstring""" from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig a : str = logging.get_logger(__name__) a : Union[str, Any] = """T5Config""" ...
150
"""simple docstring""" from scipy.stats import spearmanr import datasets a : Dict = """ The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 impl...
150
1
from collections import defaultdict from math import gcd def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE = 150_0000 ): lowercase = defaultdict(__SCREAMING_SNAKE_CASE ) lowercase = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + ...
195
from manim import * class A_ ( __lowerCamelCase ): '''simple docstring''' def SCREAMING_SNAKE_CASE__ ( self ): lowercase = Rectangle(height=0.5 , width=0.5 ) lowercase = Rectangle(height=0.25 , width=0.25 ) lowercase = R...
195
1
from __future__ import annotations def lowerCAmelCase_ (lowerCAmelCase__: list[int | float] , lowerCAmelCase__: int , lowerCAmelCase__: int ): """simple docstring""" if len(lowerCAmelCase__ ) == 0: raise ValueError("""fin...
82
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available...
82
1
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
57
"""simple docstring""" 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...
57
1
from __future__ import annotations def UpperCamelCase( lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> Tuple: # noqa: E741 '''simple docstring''' while r - l > 1: snake_case_ = (l + r) // 2 if v[m] >= key: snake_case_ = m ...
34
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 lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''facebook/levit-1...
34
1
UpperCAmelCase : str = 0 # The first color of the flag. UpperCAmelCase : Any = 1 # The second color of the flag. UpperCAmelCase : int = 2 # The third color of the flag. UpperCAmelCase : List[Any] = (red, white, blue) def _A ( SCREAMING_SNAKE...
95
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokeni...
304
0
"""simple docstring""" import operator def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ = False , UpperCamelCase__ = None ): """simple docstring""" A__ = operator.lt if reverse else operator.gt A__ ...
154
"""simple docstring""" 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, ...
154
1
"""simple docstring""" from numpy import exp, pi, sqrt def UpperCAmelCase__ ( lowerCAmelCase__ :List[str] , lowerCAmelCase__ :float = 0.0 , lowerCAmelCase__ :float = 1.0 ) -> int: '''simple docstring''' return 1 / sqrt(2 * pi * sigma**2 ) * exp(...
197
"""simple docstring""" from __future__ import annotations from collections.abc import Callable __lowerCAmelCase : str =list[list[float | int]] def UpperCAmelCase__ ( lowerCAmelCase__ :Matrix , lowerCAmelCase__ :Matrix ) -> Matrix: '''simple d...
197
1
'''simple docstring''' import os from collections.abc import Iterator def lowercase (_A = "." ): """simple docstring""" for dir_path, dir_names, filenames in os.walk(UpperCAmelCase__ ): _lowerCAmelCase : ...
371
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowerCAmelCase : List[str] = [ """kernels/rwkv/wkv_cuda.cu""", """kernels/rwkv/wkv_op.cpp""", """kernels/deformable_detr/ms_deform_att...
25
0
"""simple docstring""" from maths.prime_factors import prime_factors def a_ ( _lowerCAmelCase : int ): '''simple docstring''' if not isinstance(_lowerCAmelCase , _lowerCAmelCase ): lowercase__ : Union[str, Any] = f"""Input value of [number={nu...
77
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np a__ : Optional[int] = re.compile(R'\b(a|an|the)\b', re.UNICODE) a__ : int = None def _UpperCamelCase ( ) -> Dict...
80
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 : Optional[int] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def a_ ( __lowercase : list[float] ) -> ...
130
from __future__ import annotations import requests _lowerCamelCase : List[str] = set( '''approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categories...
130
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_...
206
'''simple docstring''' import re def a ( lowerCamelCase__ ): '''simple docstring''' return [char.split() for char in re.split(r"""[^ a-z A-Z 0-9 \s]""" , str_ )] def a ( lowerCamelCase__ ): '''simple docstring''' A_ : Optional[int] = split_input(str_...
206
1
"""simple docstring""" def _lowerCamelCase(__UpperCamelCase , __UpperCamelCase ) -> 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(1 , 0 ) == 1 assert or_gat...
341
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def _lowerCamelCase(__UpperCamelCase , __UpperCamelCase=1 ) -> Tuple: if n_shave_prefix_segments >= 0: return ".".join(path.split(""".""" )[n_shave...
341
1
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 a ="""src/diffusers""...
73
'''simple docstring''' 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(): fr...
162
0
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration lowerCAmelCase_ : Optional[int] = 5_0_0_0_0 lowerCAmelCase_ : str = 5_0_0_0 lowerCAmelCase_ , lowerCAmelCase_ : Optional[i...
248
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionMod...
248
1