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 torch from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer from .base import PipelineTool class A ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' A = "facebook/bart-large-mnli" A ...
298
"""simple docstring""" import math def lowercase__ ( _UpperCAmelCase = 1_00 ) -> int: '''simple docstring''' lowercase : List[str] = sum(i * i for i in range(1 , n + 1 ) ) lowercase : Dict = int(math.pow(sum(range(1 ...
255
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( __A : int = 10**12 ) -> int: _SCREAMING_SNAKE_CASE = 1 _SCREAMING_SNAKE_CASE = 0 _SCREAMING_SNAKE_CASE = 1 _SCREAMING_SNAKE_CASE = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * numerator ...
111
'''simple docstring''' import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase_ = { ...
111
1
from copy import deepcopy class _a : def __init__( self : List[str] , _SCREAMING_SNAKE_CASE : list[int] | None = None , _SCREAMING_SNAKE_CASE : int | None = None )-> None: if arr is None and size is not None: lowerCAmelCase__ : ...
131
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowerCamelCase = logging.get_logger(__name__) class _a ( _lowercase): def __init__( self : Optional[int] , *_SCREAMING_SNAKE_CASE : ...
131
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) # TODO: upload to AWS _lowerCamelCase : int = { 'yjernite/retribert-base-uncased': ( 'https://huggin...
337
'''simple docstring''' from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES _lowerCamelCase : List[str] = logging.get_logger(__name__) _lowerCame...
337
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapE...
139
"""simple docstring""" from __future__ import annotations import unittest from transformers import 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, rand...
221
0
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytess...
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
"""simple docstring""" def __lowerCAmelCase ( lowercase : int , lowercase : int ) -> int: """simple docstring""" snake_case : List[str] = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): snake_case ...
203
"""simple docstring""" def __lowerCAmelCase ( lowercase : list ) -> int: """simple docstring""" if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][c...
203
1
"""simple docstring""" 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_modelin...
365
import baseaa def SCREAMING_SNAKE_CASE ( __UpperCamelCase : str ) -> bytes: return baseaa.baaencode(string.encode('''utf-8''' ) ) def SCREAMING_SNAKE_CASE ( __UpperCamelCase : bytes ) -> str: return baseaa.baadecode(__UpperCam...
177
0
from __future__ import annotations def __A ( __lowerCamelCase , __lowerCamelCase ) -> list[tuple[int, int]]: a , a = position a = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y - 1, x - 2), (y + 2, x +...
228
def __A ( __lowerCamelCase ) -> int: a = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __A ( __lowerCamelCase = 100 ) -> int: a = 1 a = 2 for i in range(2 , max_n + 1 ...
228
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _SCREAMING_SNAKE_CASE = { "configuration_squeezebert": [ "SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
3
'''simple docstring''' class _lowerCAmelCase : """simple docstring""" def __init__( self : Optional[Any] , __snake_case : int , __snake_case : Optional[Any]=None , __snake_case : int=None )-> str: snake_case = data ...
3
1
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def a ( snake_case__: Any , snake_case__: List[str] , snake_case__: Any ): '''simple docstring''' lowercase_ = { "en": "Machine learning is great, isn'...
30
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar lowercase : Optional[Any] = TypeVar('T') class lowerCamelCase__ ( Generic[T]): '''simple docstring''' _A = 42 # Cache store ...
232
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import float...
355
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor,...
32
0
"""simple docstring""" def lowercase ( A_ , A_ )-> List[Any]: '''simple docstring''' a : Any = len(UpperCAmelCase_ ) a : Any = len(UpperCAmelCase_ ) a : List[str] = [[False for ...
40
'''simple docstring''' import math def __snake_case ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): return math.pow(UpperCAmelCase_ , 2 ) - a def __snake_case ( UpperCAmelCase_ : float ): return 2 * x d...
55
0
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 _lowerCamelCase : Tuple = collections.namedtuple('''_D...
191
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__": _lowerCamelCase : Union[str, Any] = '''%20'''.join(argv[1:]) if len(argv) > 1 else quote(str(i...
191
1
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowercase : Any = (7_2_0, 1_2_8_0) # Height, Width _lowercase : List[Any] = (0.4, 0.6) # if height or width ...
93
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configurat...
232
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : int = logging.get_logger(__name__) a_ : Optional[Any] = { """facebook/wav2vec2-base-960h""": """https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/...
364
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __UpperCamelCase ( lowerCamelCase__ ): lowercase : List[str] =['image_processor', 'tokenizer'] lowercase : Optional[int] ...
6
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataL...
30
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :Union[str, Any] =...
30
1
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def UpperCAmelCase_ ( _A = True , *_A , **_A ): '''simple docstring''' if not is_tqdm_available(): raise ImportError('''A...
352
import comet # From: unbabel-comet import torch import datasets _SCREAMING_SNAKE_CASE : List[str] = datasets.logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Any = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinh...
218
0
from math import sqrt def lowerCAmelCase_ ( __a = 1000000 ) -> int: """simple docstring""" lowerCamelCase__: int =0 lowerCamelCase__: int =0 lowerCamelCase__: int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in ...
10
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def lowerCAmelCase_ ( __a , __a , __a = 10**-10 ) -> float: """simple docstring""" lowerCamelCase__: str =a while True: lowerCamelCase...
10
1
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 accelerate import Accelerator...
122
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
122
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging snake_case_ = logging.get_logger(__name__) def _lowerCAmelCase ( lowercase_ ): if isinstance(lowercase_ , np.ndarray )...
78
'''simple docstring''' # Lint as: python3 import itertools import os import re a : Tuple = re.compile(R"([A-Z]+)([A-Z][a-z])") a : Union[str, Any] = re.compile(R"([a-z\d])([A-Z])") a : str = re.compile(R"(?<!_)_(?!_)") a : List[Any] = re.compile(R"(_{2,})") a : ...
311
0
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_case (...
350
def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" if n_term == "": return [] a :list = [] for temp in range(int(UpperCAmelCase_ ) ): series.append(F'''1/{temp + 1}''' if series else '''1''' ...
281
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 A_ = logging.get_logger(__name__) A_ = { ...
64
lowerCamelCase : Tuple = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} lowerCamelCase : int = ['''a''', '''b''', '''c''', '''d''', '''e'''] def snake_case_ ( lowerCAmelCase_ : Optional[int] , low...
233
0
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('3.8'): import importlib_metadata else: import importlib.metadata as importlib_metadata _Upper...
186
"""simple docstring""" def snake_case (A_ :int ): '''simple docstring''' if isinstance(A_ , A_ ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(A_ , A_ ): raise TypeError('\'str\' object cannot be interpreted...
186
1
'''simple docstring''' def _A ( A__ , A__ , A__ ): """simple docstring""" if len(A__ ) != len(A__ ): raise ValueError('''The length of profit and weight must be same.''' ) if max_weight <= 0: raise ValueError('''max_weight must greater than zero.''' ...
104
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__ = { '''distilbert-base-uncased''': '''https://huggingfa...
230
0
from __future__ import annotations def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase): print(F'''Vertex\tShortest Distance from vertex {src}''') for i, d in enumerate(_UpperCAmelCase): print(F'''{i}\t\t{d}''') def lowerCamelCase__ (_UpperCAmelCase , _Uppe...
327
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, ...
327
1
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _a ( _SCRE...
347
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __...
347
1
from __future__ import annotations def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> list[str]: if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes: r...
365
from functools import lru_cache def lowerCAmelCase_ ( UpperCamelCase_ ) -> set: UpperCamelCase_ = 2 UpperCamelCase_ = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
328
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging UpperCamelCase = logging.get_logger(__name__) def SCREAMING_SNAKE_CASE( __lowercase ) -> List[int]: if isinstance(__lowerca...
319
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if...
319
1
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , __lowerCamelCase : Collection[float] | None = None ): if components is None: UpperCamelC...
62
from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( __magic_name__ : tuple[int, int] , __magic_name__ : int ) -> list[tuple[int, int]]: """simple docstring""" UpperCamelCase , UpperCamelCase :Union[str, Any] = position UpperCamel...
62
1
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blenderbo...
68
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf _lowercase = logging.get_logg...
74
0
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : Optional[Any] ): """simple docstring""" _snake_case : Union[str, Any] = [] _snake_case : Dict = set({"""(""", """[""", """{"""} ) _snake_case : Union[str, Any] = set({""")""",...
132
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin A_ = get_tests_dir(''...
132
1
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __lowercase (unittest.TestCase ): @property de...
275
from ....configuration_utils import PretrainedConfig from ....utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": ( "https://huggingface.co/CarlCochet/trajectory-transformer-halfcheetah-medium-v2/reso...
275
1
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase ): # Checks if the entire collection has been sorted if len(lowercase__ ) <= 1 or n <= 1: return insert_next(lowercase__ , n - 1 ) rec_insertion_sort(lowercase__ , n - 1 ) def ...
362
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", } clas...
182
0
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Optional[int] ) -> T...
325
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Optional[Any] , SCREAMING_SNAKE_CASE : List[Any] ) -> List[str]: __lowercase = [0 for i in range(r + 1 )] # nc0 = 1 __lowercase = 1 for i in range(1 , n + 1 ): ...
325
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCAmelCase ( lowerCAmelCase): _a = ['''image_processor''', '''tokenizer'''] _a = '''ChineseCLIPImageProcessor''' _a = ('''BertTokenizer'...
158
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __lowerCAmelCase ( lowerCAmelCase): def __init__( self: Any , _lowerCAmelCase: int , _lowerCAmelCase: str , _lowerCAmelCase: U...
158
1
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow SCREAMING_SNAKE_CASE :List[str] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classif...
15
'''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, CLIPText...
208
0
"""simple docstring""" import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_form...
234
"""simple docstring""" from __future__ import annotations def _a ( _snake_case , _snake_case , _snake_case ): """simple docstring""" if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0""" ...
234
1
'''simple docstring''' from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from tr...
34
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tests_...
36
0
"""simple docstring""" 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_che...
364
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock ...
85
0
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Any = logging.get_logger(__name__) lowerCamelCase : Tuple = { 'BridgeTower/bridgetower-base': 'https://hugging...
2
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __A( __lowerCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE__ = (CMStochasticIterativeScheduler,) SCREAMING_SNAKE_CASE__ = 10 def UpperCAmel...
244
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" A__ = sorted(numsa + numsa ) A__ , A__ = divmod(len(U...
154
"""simple docstring""" def UpperCAmelCase ( UpperCamelCase__ = 100 ): """simple docstring""" A__ = (n * (n + 1) // 2) ** 2 A__ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main_...
154
1
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example __lowercase = [ [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], ...
40
"""simple docstring""" __lowercase = { """Pillow""": """Pillow<10.0.0""", """accelerate""": """accelerate>=0.20.3""", """av""": """av==9.2.0""", """beautifulsoup4""": """beautifulsoup4""", """black""": """black~=23.1""", """codecarbon""": """codecarbon==1....
40
1
from __future__ import annotations from collections.abc import Generator def snake_case_ (): '''simple docstring''' _a = {} _a = 2 while True: _a = factor_map.pop(lowerCamelCase_ , lowerCamelCase_ ...
358
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _snake_case : int = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig...
179
0
"""simple docstring""" import mpmath # for roots of unity import numpy as np class lowercase: '''simple docstring''' def __init__( self: Union[str, Any], a_: Dict=None, a_: str=None ): '''simple docstring''' _snake_cas...
64
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCAmelCase : Dict =argparse.ArgumentParser() parser.add_argument("""--dump_path""", default=None...
128
0
from scipy.stats import spearmanr import datasets lowerCamelCase_ : 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 implying no correlation. Positive correlat...
197
from __future__ import annotations import numpy as np def lowerCAmelCase( __lowerCamelCase ): return np.maximum(0 , __lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
197
1
'''simple docstring''' 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.util...
161
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent a__ : Optional[Any] = {"UserAgent": UserAgent().random} def snake_case ( UpperCAmelCase )-> dict:...
161
1
def snake_case (__lowercase , __lowercase ) -> Any: '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def snake_case () -> List[str]: '''simple docstring''' assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ...
366
def snake_case (__lowercase ) -> bool: '''simple docstring''' _snake_case : Dict = 0 for ch in input_str: _snake_case : int = ord(__lowercase ) _snake_case : List[Any] = pow(2 , __lowercase ) #...
284
0
"""simple docstring""" import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') a_ = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) a_ = requests.get(...
249
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
1
"""simple docstring""" import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( _UpperCamelCase ): '''simple docstring''' SCREAMING_SNAKE_CASE__ :Dict = (DDPMParallelScheduler,) d...
310
"""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__": lowerCamelCase__ = "%20".join(argv[1:]) if len(argv) > 1 else quote(str(input("Search...
310
1
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, ...
223
"""simple docstring""" def __lowerCAmelCase ( lowercase : list[int] ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) snake_case : List[str] = sum(lowercase ) / len(lowerca...
203
0
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowerCamelCase = [ 'Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone ...
368
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClass...
177
0
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
51
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for...
46
0
"""simple docstring""" from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType cla...
362
"""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 ...
291
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 accele...
58
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : List[Any] = { "configuration_tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig"], "tokenization_tapas...
238
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase__ = logging.get_logger(__name__) lowercase__ = { """google/bit-50""": """...
161
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def __lowerCamelCase ( __UpperCamelCase ) -> Any: """simple docstring""" if not is_accelerate_available(): return method ...
161
1
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def __SCREAMING_SNAKE...
8
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor __a = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( A__ ): def __init__( self , *SCREAMING_SNAKE_CASE__ , **SCREAMING_SNAKE_CASE__ ): ...
337
0
import requests from bsa import BeautifulSoup def _a ( UpperCAmelCase = "https://www.worldometers.info/coronavirus" ) -> List[Any]: """simple docstring""" lowerCamelCase__ : Dict = BeautifulSoup(requests.get(__lowerCamelCase ).text , '''html.pars...
360
import os from pathlib import Path def _a ( ) -> Tuple: """simple docstring""" from torch.utils.cpp_extension import load lowerCamelCase__ : List[Any] = Path(UpperCAmelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' low...
265
0
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 = collections.namedtuple('_Datasets', ['train', 'validation', 'test'...
62
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets SCREAMING_SNAKE_CASE__ : Union[str, Any] = "\\n@inproceedings{popovic-2015-chrf,\n title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",\n author = \"Popovi{\'c}, Maja\",\...
270
0
from __future__ import annotations def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> Optional[int]: """simple docstring""" _snake_case = [] _snake_case = [] _snake_case = 0 _snake_case = sum(lowerCamelCase__ ) create_stat...
350
__A = '''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def snake_case_(_UpperCamelCase ) -> bytes: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): _snake_case = F"""a bytes-like object is required, no...
278
0
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def a ( __a="ro" , __a="en" , __a="wmt16" , __a=None ) -> None: '''simple docstring''' try: import datasets except (ModuleNotFoundError, ImportError): raise Import...
97
'''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 lowercase ( A__ ): ""...
97
1
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, W...
4
'''simple docstring''' def snake_case__ ( lowerCamelCase__ : list ) -> list: if len(lowerCamelCase__ ) <= 1: return [tuple(lowerCamelCase__ )] A_ : List[str] = [] def generate(lowerCamelCase__ : int , lowerCame...
4
1
"""simple docstring""" import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowercase__ = datasets.uti...
241
"""simple docstring""" from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) # TODO Update this lowercase__ = { """facebook/esm-1b""": """https://...
241
1
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowercase (a_ , unittest.TestCase ): """simple docstring""" _snake_cas...
350
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedK...
176
0
"""simple docstring""" from collections.abc import Sequence def lowercase ( lowerCAmelCase__ : Sequence[int] | None = None ) -> int: if nums is None or not nums: raise ValueError('''Input sequence should not be empty''' ) __a = nums[0] for i in ra...
45
'''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 imp...
190
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase : int = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class lowercase__ ...
359
from typing import Union import fire import torch from tqdm import tqdm def A ( _lowercase , _lowercase = "cpu" , _lowercase = None ): SCREAMING_SNAKE_CASE : Optional[int] = torch.load(_lowercase , map_location=_lowercase ) for k, v in tqdm(state_dict...
258
0
def lowercase_ (A : int ): snake_case__ : Dict = [1] snake_case__ , snake_case__ , snake_case__ : Optional[Any] = 0, 0, 0 snake_case__ : int = ugly_nums[ia] * 2 snake_case__ : Any = ugly_nums[ia] * 3 snake_case__ :...
277
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_...
277
1
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
215
"""simple docstring""" from __future__ import annotations class __A : """simple docstring""" def __init__( self , __A = 0 ) -> Dict: a =key def SCREAMING_SNAKE_CASE ( self , __A , __A ) -> list[str...
215
1
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging A : Union[str, Any] = logging.get_logger(__name__) def __lowerCAmelCase ( a__ , a__ ) ...
6
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch ...
37
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=a__ ): '''simple docstring''' SCREAMING_SNAKE_CASE = ["torch", "transformers", "onnx"] def __init__( self , *__lowerCAmelCase , **__lowerC...
365
'''simple docstring''' import qiskit def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ): lowercase__ : Dict = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register lowercase__ : Any = qiskit.QuantumCircuit(UpperCAmelCase ...
214
0
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets __UpperCamelCase = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "Snover, Ma...
113
"""simple docstring""" __UpperCamelCase = 0 # The first color of the flag. __UpperCamelCase = 1 # The second color of the flag. __UpperCamelCase = 2 # The third color of the flag. __UpperCamelCase = (red, white, blue) def lowercase (SCREAMING_SNAKE...
113
1
"""simple docstring""" import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): ...
355
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention...
298
0
"""simple docstring""" from PIL import Image def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(lowerCamelCase ) -> int: return int(1_2_8 + factor * (c - 1_2_8) )...
98
"""simple docstring""" from ...configuration_utils import PretrainedConfig class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :str = "bert-generation" def __init__( self , __A=5_0358 , __A=1024 , __A=24 , __A=16 ...
84
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from...
359
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A ( _lowerCamelCase = "laptop" ): '''simple docstring''' _lowerCAmelCase : Union[str, Any] = F"https://www.amazon.in/laptop/s?k={product}" ...
300
0
"""simple docstring""" def lowerCamelCase__ ( __snake_case = 10_00 ) -> int: """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3, n + 1 ) ) if __name__ == "__main__": print(solution())
194
"""simple docstring""" def lowerCamelCase__ ( __snake_case = 10_00 ) -> int: """simple docstring""" _UpperCamelCase = 2**power _UpperCamelCase = str(__snake_case ) _UpperCamelCase = list(__snake_case ) _UpperCamelCase ...
194
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration lowercase_ = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """weigh...
224
from __future__ import annotations def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): return len(set(SCREAMING_SNAKE_CASE_ ) ) == len(SCREAMING_SNAKE_CASE_ ) if __name__ == "__main__": import doctest doctest.testmod()
224
1
"""simple docstring""" 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.util...
197
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : List[Any] =logging.get...
197
1
"""simple docstring""" # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''T''') class _lowerCamelCase ( Gen...
353
"""simple docstring""" import math def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase = 0 UpperCamelCase = 0 while num > 0: UpperCamelCase = num % 8 UpperCamelCase = octal + (remainder * math.floor(math.pow(10 , _SCREAMING_SNAKE_CAS...
244
0
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import loggin...
4
"""simple docstring""" def lowercase_ ( _snake_case ): if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_snake_case ,_snake_case ): raise TypeError("""Input value must be a 'int' type""" ) ...
25
0
def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int) -> bool: '''simple docstring''' __UpperCamelCase : List[Any] = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : ...
151
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging lowercase : Dict = logging.get_logge...
151
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize...
296
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class UpperCamelCase__ ( lowerCAmelCase_ ): '''simple docstring''' def __init__( self : Un...
296
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCAmelCase = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys UpperCAm...
367
"""simple docstring""" def lowerCamelCase (a_ :int) -> None: lowercase :Tuple = generate_pascal_triangle(a_) for row_idx in range(a_): # Print left spaces for _ in range(num_rows - row_idx - 1): print(end=''' ''') ...
172
0
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) def lowerCAmelCase_ ( __UpperCAmelCase: str , __UpperCAmelCase: List[Any] ) ...
201
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, PreTrainedTokenizer, ...
201
1
from sklearn.metrics import fa_score import datasets lowerCAmelCase__ :Any = "\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" lowerCAmelCase__ :Optional[Any] = "\...
371
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def lowerCAmelCase__ ( a__: NDArray[floataa] , a__: NDArray[floataa] , a__: list[int] , a__: int , ) -> list[float]: '''simple docstring''' _Up...
185
0
class __lowercase : """simple docstring""" def __init__( self : List[Any] , lowerCAmelCase__ : Optional[int] , lowerCAmelCase__ : List[Any]): SCREAMING_SNAKE_CASE_: List[str] = name SCREAMING_SNAKE_CASE_: Union[str, Any] = val ...
13
"""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
0
"""simple docstring""" import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import...
80
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : list )-> list: def merge(snake_case : list , snake_case : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0...
80
1
from __future__ import annotations from random import choice def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): return choice(SCREAMING_SNAKE_CASE ) def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): A_ : List[Any] = random_pivot(SCREAMING_S...
186
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTConfig""", "...
186
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
194
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {'configuration_mbart': ['MBART_PRETRAINED_CONFIG_ARCH...
194
1
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMSchedule...
173
'''simple docstring''' from datetime import datetime import requests def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase ='https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' __lowercase =requests.get(base_url + url ).json()...
166
0
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
353
import re import string import numpy as np import datasets snake_case_ = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' snake_case_ = '\nArgs:\n pred...
238
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, ...
278
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { '''nielsr/canine-s''': 2_048, } # Unicode defines 1,114,112 total “codepoints” _A = 1_114_112 # Below: Constan...
278
1
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 import logging logging.set...
277
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __A = logging.get_logger(__name__) __A = '''https://openaipublic.azureedge....
277
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A : List[Any] = { 'configuration_perceiver': ['PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PerceiverConfig', 'Perceiv...
6
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def __lowerCAmelCase ( a__ , a__ , a__ = 1 / sqrt(2 ) ) -> IIRFilter: __a = tau * frequency / samplerate __a = sin(a__ ) __a = cos(a__ ) __a ...
6
1
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCamelCase ( _a ) -> str: '''simple docstring''' if not isinstance(_a , _a ): raise TypeError('''Undefined for non-integers''' ) elif precisio...
252
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional ...
252
1
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...t...
59
'''simple docstring''' import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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 ...
141
0
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech...
354
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __snake_case = logging.get_logger(__name__) class __lowerCamelCase ( a__ ): '''simple docstring''' def __init__( self , *__UpperCAmelC...
153
0
'''simple docstring''' from __future__ import annotations import time a : Union[str, Any] = list[tuple[int, int]] a : List[str] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [...
311
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _lowerCAmelCase : str = { "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, "num_clas...
218
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 __SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_logger(__na...
233
"""simple docstring""" import math class __A : '''simple docstring''' def __init__( self : List[str] , UpperCAmelCase_ : Tuple=0 ) ->Optional[int]: # a graph with Node 0,1,...,N-1 """simple docstring""" snake_case_ ...
233
1
"""simple docstring""" def lowercase ( _snake_case : List[Any] ) ->str: """simple docstring""" __snake_case : int = 0 __snake_case : List[str] = len(_snake_case ) for i in range(n - 1 ): for j in range(i + 1 , _snake_case ): if ...
102
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer lowerCamelCase__ : Union[str, Any] = logging.get_logger(__na...
225
0
"""simple docstring""" import numpy as np import torch from ..models.clipseg import CLIPSegForImageSegmentation from ..utils import is_vision_available, requires_backends from .base import PipelineTool if is_vision_available(): from PIL import Image class _UpperCAmelCase( ...
357
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common i...
100
0