code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : Union[s...
231
"""simple docstring""" import math import qiskit def lowercase ( __snake_case : int = 1 , __snake_case : int = 1 , __snake_case : int = 1 ): if ( isinstance(__snake_case , __snake_case ) or isinsta...
231
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/mic...
6
'''simple docstring''' from __future__ import annotations class __lowercase : def __init__( self : Union[str, Any] , UpperCAmelCase_ : list[list[int]]): UpperCamelCase__ : int = TypeError( 'Matrices must be formed fro...
6
1
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def A__ ( __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = FileLock(str(tmpdir / 'foo.lock' ) ) _lowerCAmelCase = File...
589
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'huggingface/time-series-transformer-tourism-monthly': ( 'https://hug...
406
0
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a__ : Any = logging.get_logger(__name__) a__ : List[Any] =...
713
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : int = logging.get_logger(__name__) class lowerCAmelCase__ ( UpperCAmelCa...
570
0
'''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 transformers.testing_...
566
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute...
328
0
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore __SCREAMING_SNAKE_CASE : Optional[Any] = namedtuple('covid_data', 'cases deaths recovered') def _a ( _SCREAMING_SNAKE_CASE = "https://www.worldometers.info/coronavirus/"...
2
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> int: if index == number_of_items: return 0 snake_case_ = 0 snake_case_ ...
2
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers....
112
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase ( __magic_name__ , unittest.TestCase ): UpperCamelCase_...
468
0
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union SCREAMING_SNAKE_CASE : List[Any] = re.compile(r"^(?P<major>\d+)" r"\.(?P<minor>\d+)" r"\.(?P<patch>\d+)$") @total_order...
441
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 LearnedClassifie...
441
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable(...
412
def UpperCAmelCase_ ( UpperCAmelCase__ = 1_0_0_0_0_0_0 ): lowercase_ = set(range(3 , UpperCAmelCase__ , 2 ) ) primes.add(2 ) for p in range(3 , UpperCAmelCase__ , 2 ): if p not in primes: continue primes.difference_update(...
412
1
from __future__ import annotations from collections import Counter from random import random class A : def __init__( self : Dict ) -> str: """simple docstring""" UpperCamelCase_ = {} def lowercase__ ( ...
700
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __a : Union[str, Any] = TypeVar("""KEY""") __a : Union[str, Any] = TypeVar("""VAL""") @dataclass(frozen=lowerCamelCase_ , slots=lowerCamelCase_ ...
559
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> None: _lowercase : str = len(lowerCamelCase_ ) print('The following activities are selected:' ) # The first activity is always selected _lowercase : Optional[int] = 0 prin...
89
'''simple docstring''' 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 __lower...
467
0
"""simple docstring""" def lowercase ( a__ : str , a__ : Dict , a__ : Tuple=False ) -> Optional[Any]: if isinstance(a__ , a__ ) and isinstance(a__ , a__ ): _UpperCamelCase = len(set_a.intersection(a__ ) ) if alternative_union: ...
342
"""simple docstring""" from timeit import timeit UpperCAmelCase = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a plan a canal panama" } # Ens...
342
1
import math import sys def lowerCAmelCase_ ( __a ) -> int: """simple docstring""" if number != int(_lowerCAmelCase ): raise ValueError("the value of input must be a natural number" ) if number < 0: raise ValueError("the value of input must not be a negativ...
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ...
718
'''simple docstring''' from __future__ import annotations import math def __a ( lowerCAmelCase__ : float , lowerCAmelCase__ : int ): a__ : List[str] = u for i in range(1 , lowerCAmelCase__ ): a__ : List[Any] = temp * (u - i) ...
340
0
def __lowerCAmelCase ( A_ : int ) -> int: __UpperCAmelCase = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __lowerCAmelCase ( A_ : int = 1_00 ) -> int: __UpperCAmelCase = 1 __UpperCAmelCase = ...
221
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedu...
221
1
'''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(): imp...
301
'''simple docstring''' from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __snake_case( _lowerCAmelCase = "" ) -> dict[str, float]: snake_case__ : Tuple = url or """https://www.imdb.com/chart/top/?ref_=nv_mv_250""" snak...
301
1
"""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 ..pip...
512
"""simple docstring""" # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from ...
512
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_available(): raise OptionalDependen...
112
"""simple docstring""" # 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 ...
112
1
from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=_A): """simple docstring""" a__ : Any = ["torch", "transformers", "onnx"] def __init__( self : Union[str, Any] , *__lowerCAmelCase : Union[str, Any] , **__lower...
2
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
0
import socket def UpperCAmelCase__ ( ) -> Union[str, Any]: __lowercase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) __lowercase = socket.gethostname() __lowercase = 12_312 sock.connect((host, port) ) sock....
703
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 UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "hustv...
634
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { """bert-bas...
80
def UpperCamelCase ( snake_case__ : list ): '''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][cell_n] +=...
455
0
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`")
710
import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing import ...
167
0
from numpy import exp, pi, sqrt def A__ ( SCREAMING_SNAKE_CASE_ : Any , SCREAMING_SNAKE_CASE_ : float = 0.0 , SCREAMING_SNAKE_CASE_ : float = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2...
32
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset from...
30
0
from typing import List from .keymap import KEYMAP, get_character def UpperCAmelCase ( lowerCAmelCase__ ): '''simple docstring''' def decorator(lowerCAmelCase__ ): __A = getattr(lowerCAmelCase__ , "handle_key" , [] ) handle += [key] setat...
706
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer...
205
0
'''simple docstring''' import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow fr...
274
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.u...
274
1
from __future__ import annotations def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: list , SCREAMING_SNAKE_CASE_: int | None = None , SCREAMING_SNAKE_CASE_: int | None = None ) -> None: '''simple docstring''' if start is None: A__ = ...
626
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel @require_tf...
626
1
'''simple docstring''' 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, ...
92
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase__ ( UpperCAmelCase_ ): '''simple docstring''' _lowerCamelCase =["image_processor", "tokenizer"] _lowerCame...
51
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass cl...
715
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[Any] = logging.get_logg...
233
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled...
314
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ = { '''configuration_nllb_moe''': [ '''NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NllbMoeConfig''', ] } try: if not is_tor...
314
1
"""simple docstring""" def _a ( UpperCAmelCase__ , UpperCAmelCase__ ) -> int: return x if y == 0 else greatest_common_divisor(UpperCAmelCase__ , x % y ) def _a ( UpperCAmelCase__ , UpperCAmelCase__ ) -> int: return (x * y) // greatest_common_d...
482
"""simple docstring""" def _a ( UpperCAmelCase__ = 10 ) -> str: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or n < 0: raise ValueError('''Invalid input''' ) __SCREAMING_SNAKE_CASE = 10**n __SCREAMING_SNAKE_CASE = 2_84_3...
482
1
from __future__ import annotations def lowerCamelCase_ ( UpperCAmelCase_ : list[int | float] , UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> Dict: '''simple docstring''' if len(UpperCamelCase__ ) == 0: raise ValueErro...
715
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = """▁""" lowerCAm...
648
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a :List[Any] = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'], } try: ...
86
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin __lowercase : str = get_test...
564
0
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow SCREAMING_SNAKE_CASE__ : Tuple = logging.getLogger() @unittest.skip...
509
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from fl...
509
1
def _SCREAMING_SNAKE_CASE ( lowercase : int = 50_00_00_00 ): '''simple docstring''' lowerCamelCase_ = set() lowerCamelCase_ = int((limit - 24) ** (1 / 2) ) lowerCamelCase_ = set(range(3 , prime_square_limit ...
70
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py a = """\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic Eva...
687
0
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteSche...
405
from collections import Counter from timeit import timeit def __UpperCamelCase ( _lowerCAmelCase = "" , ): """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def __UpperCamelCase ( _lowerCAmelCase = "" ): ...
405
1
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase_ (__A ): __magic_...
95
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCAmelCase ( a_ , a_ , a_ ) -> List[str]: """simple docstring""" __A = ("dense.weight", "attention.self.query", "attention.self....
55
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils impo...
470
from datetime import datetime import matplotlib.pyplot as plt import torch def __lowerCAmelCase ( UpperCamelCase ) -> str: for param in module.parameters(): lowerCAmelCase__ : int = False def __lowerCAmelCase ( ) -> Optional[Any]: lowerCAmelCase__ ...
470
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a__ ( _lowercase ): __magic_name__ : List[Any] = ["image_processor", "tokenizer"] __magic_name__ : Optional[Any] = "C...
507
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependen...
507
1
import requests from bsa import BeautifulSoup def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ = "AAPL" ): UpperCamelCase__ : Tuple = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' UpperCamelCase__ : str = BeautifulSoup(requests.get(UpperCamelCase__ ).te...
462
import doctest from collections import deque import numpy as np class _lowerCamelCase : """simple docstring""" def __init__( self ) -> None: """simple docstring""" UpperCamelCase__ : Tuple = [2, 1, 2, -1] UpperCamelCase__ ...
462
1
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts...
84
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_...
322
0
from collections.abc import Generator from math import sin def _a ( __SCREAMING_SNAKE_CASE : Union[str, Any] ): """simple docstring""" if len(_UpperCAmelCase ) != 32: raise ValueError('Input must be of length 32' ) _lowerCAmelCase = b'' for i in [3, 2, 1, ...
716
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
585
0
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput lowerCAmelCase__ = 'scheduler_config.json' class lowerCAmelCase__ ( a): ...
503
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQVAEConfig', ...
503
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _snake_case (__lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase): if (ksize % 2) == 0: ...
704
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 _a ...
618
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, SkipDataLoader, ...
658
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. __snake_case = 10 def _A ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , S...
658
1
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAMES, P...
360
def __UpperCamelCase ( a, a, a=False) ->Dict: if isinstance(a, a) and isinstance(a, a): lowerCamelCase__ = len(set_a.intersection(a)) if alternative_union: lowerCamelCase__ = len(a) + len(a) else: ...
360
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> List[Any]: '''simple docstring''' UpperCAmelCa...
130
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # noqa F40...
130
1
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case ( __UpperCAmelCase ): pass class snake_case : def __init__( self :List[Any] , _lowerCamelCase :Any ): __SCREAMING_SNAKE_CASE : Any ...
705
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case ( __UpperCAmelCase ): lowerCamelCase__ = '''SpeechT5FeatureExtractor''' lowerCamelCase__ = '''SpeechT5Tokenizer''' def __init__( self :List[Any] , _lo...
401
0
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
52
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __lowercase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = (DDPMScheduler,) ...
52
1
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from ut...
702
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaF...
14
0
'''simple docstring''' import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_ava...
350
'''simple docstring''' import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStru...
350
1
"""simple docstring""" import random def __A ( a_ :Union[str, Any] , a_ :List[Any] , a_ :List[Any]) -> Union[str, Any]: __a : str = a[left_index] __a : Optional[int] = left_index + 1 for j in range(left_...
101
"""simple docstring""" import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokeni...
101
1
'''simple docstring''' import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger __A ='<<<<<<< This should probably be modified because it mentions: ' __A ='===...
407
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __A =get_t...
407
1
from typing import Any import numpy as np def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :np.ndarray ) -> bool: return np.array_equal(SCREAMING_SNAKE_CASE , matrix.conjugate().T ) def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :np.ndarray , SCREAMING_SNAKE_...
240
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class snake_case_ ( pl.LightningModule ): def __init__( self : Union[str, Any] , _snake_case : List[str] )...
240
1
'''simple docstring''' from __future__ import annotations from typing import Any class __UpperCamelCase : def __init__( self :int ,_UpperCamelCase :int ): snake_case_ : str = num_of_nodes snake_case_ : list[list[int]] = [] ...
334
'''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...
334
1
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowercase = get_tests...
715
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { """vocab_file""": """vocab.json""", ...
150
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, loggin...
591
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) fr...
294
0
'''simple docstring''' from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.te...
713
'''simple docstring''' 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 imp...
344
0
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_d...
275
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __SCREAMIN...
220
0
"""simple docstring""" import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax ...
538
"""simple docstring""" import collections import os import re from pathlib import Path _A = 'src/transformers' # Matches is_xxx_available() _A = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} _A = re.compile(R'^_import_stru...
538
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging A : Tuple = logging.get_logger(__name__) A : Union[str, Any] = { '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config...
287
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Dict = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextConfig''', '''XCLIPVisionConfig''...
287
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, sl...
380
import unittest from knapsack import knapsack as k class __lowerCAmelCase ( unittest.TestCase ): def A__ ( self ) -> List[str]: '''simple docstring''' _lowercase =0 _lowercase =[0] _lowercase ...
380
1
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_visio...
542
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 disable_progress_b...
542
1
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class __lowercase( nn.Module ): ...
585
from math import isqrt def _a ( __SCREAMING_SNAKE_CASE : int ): """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(__SCREAMING_SNAKE_CASE ) + 1 ) ) def _a ( __SCREAMING_SNAKE_CASE : int = 10**6 ): ...
585
1
"""simple docstring""" from typing import Any import numpy as np def lowercase_ ( _lowercase : np.ndarray ): '''simple docstring''' return np.array_equal(_lowercase , matrix.conjugate().T ) def lowercase_ ( _lowercase : np.ndarray , ...
595
"""simple docstring""" 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 clas...
595
1
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int ) -> int: """simple docstring""" if not isinstance(__UpperCamelCase , __UpperCamelCase ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive"""...
711
from __future__ import annotations from collections.abc import Iterator from typing import Any class __snake_case : def __init__( self : Union[str, Any] , _lowercase : Any ): """simple docstring""" SCREAMING_SNAKE_CASE__ ...
379
0
"""simple docstring""" import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils impo...
426
"""simple docstring""" import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visio...
426
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case_ : Tuple = logging.get_logger(__name__) snake_case_ : Tuple ...
644
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int ) -> str: if number > 0: raise ValueError('''input must be a negative integer''' ) UpperCAmelCase_ : Union[str, Any] = len(bin(SCREAMING_SNAKE_CASE__ )[3:] ) ...
644
1
def lowerCAmelCase_ ( __a ) -> list: """simple docstring""" for i in range(len(__a ) - 1 , 0 , -1 ): lowerCamelCase__: List[Any] =False for j in range(__a , 0 , -1 ): if unsorted[j] < unsorted[j - 1]...
59
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common impo...
276
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 if is_flax_available...
368
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow ...
368
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = {} try: if not is_sentencepiece_available(): ...
645
"""simple docstring""" import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="session" ) def a__ ( ): ...
645
1
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixin ...
710
import string import numpy def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> int: return b if a == 0 else greatest_common_divisor(b % a , SCREAMING_SNAKE_CASE_ ) class snake_case_ : lowerCamelCase :Tuple = string.ascii_...
262
0
"""simple docstring""" from argparse import ArgumentParser from . import BaseTransformersCLICommand def a__ ( lowerCAmelCase ) -> Optional[int]: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class lowerCamelCase ( _sna...
182
__UpperCAmelCase = '0.18.2' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_lib...
406
0
def UpperCAmelCase ( A : int , A : int ): '''simple docstring''' return number | (1 << position) def UpperCAmelCase ( A : int , A : int ): '''simple docstring''' return number & ~(1 << position) def UpperCAmelCa...
719
"""simple docstring""" import os def UpperCAmelCase ( ): '''simple docstring''' _UpperCAmelCase = os.path.join(os.path.dirname(A ) , 'num.txt' ) with open(A ) as file_hand: return str(sum(int(A ) for line in file_hand ) ...
24
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers impo...
532
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer ...
477
0
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def UpperCamelCase_ ( A__ ): a_ = [ """decoder.version""", """decoder.output_projection.weight""", """_float_tensor""...
701
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common imp...
511
0
a__: dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_...
190
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_av...
190
1
import numpy as np def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> List[Any]: """simple docstring""" _SCREAMING_SNAKE_CASE = int(np.ceil((x_end - xa) / h...
719
'''simple docstring''' import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils...
0
0
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionCo...
218
'''simple docstring''' 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 __Upp...
546
0
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL A__: int = version.parse(version.parse(torch.__version__).base_version) < version.parse('''1.11''') def lowerCAmelCase_ ( ...
716
def lowerCAmelCase_ ( A_): UpperCamelCase__: Union[str, Any] = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def lowerCAmelCase_ ( A_): UpperCamelCase__...
221
0
'''simple docstring''' import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase__ : Union[str, Any...
347
"""simple docstring""" def UpperCAmelCase_ ( __a : int ): '''simple docstring''' _lowerCamelCase : Optional[Any] = int(__a ) if decimal in (0, 1): # Exit cases for the recursion return str(__a ) _lowerCamelCase , _lowerCame...
437
0
from copy import deepcopy class _UpperCAmelCase : '''simple docstring''' def __init__( self , a__ = None , a__ = None ): if arr is None and size is not None: A_ : Dict = size A_ : str = [0] * s...
711
from typing import List from .keymap import KEYMAP, get_character def _lowerCAmelCase ( _lowerCAmelCase ): '''simple docstring''' def decorator(_lowerCAmelCase ): A_ : List[Any] = getattr(_lowerCAmelCase ,"""handle_key""" ,[] ) handle += [key] setat...
481
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : Optional[int] = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Inform...
105
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class A_ ( __lowercase ): '''simple docstring''' def __init__( self , *_A ,...
485
0
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig lowerCAmelCase : List[str] = logging.getLogger(__name__) class UpperCAmelCase__ ( UpperCamelCase__ ): a : int = """masked_bert""" def __init__( self , ...
39
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __lowerCAmelCase ( lowerCamelCase : bytes , lowerCamelCase : int ): '''simple docstring''' __lowerCAmelCase = f''...
39
1
"""simple docstring""" from __future__ import annotations def A_ ( __lowercase , __lowercase ): UpperCamelCase_ : int =get_failure_array(_lowercase ) # 2) Step through text searching for pattern UpperCamelCase_ : int =0, 0 # index into text, pattern while i < len(_l...
357
"""simple docstring""" def lowercase_ ( _lowercase : int ): '''simple docstring''' if not isinstance(_lowercase , _lowercase ): raise TypeError("only integers accepted as input" ) else: UpperCAmelCase : Optional[int] = ...
595
0
from math import factorial def UpperCAmelCase ( lowercase__ : int = 20 ): '''simple docstring''' a__ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... a__ = n // 2 return int(factorial(lowercase__ ) / (fa...
412
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _lowerc...
412
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowercase ( __lowerCamelCase ): ...
65
"""simple docstring""" import requests def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' UpperCAmelCase__ : Tuple = {"""Content-Type""": """application/json"""} UpperCAmelCase__ : Optional[Any] = requ...
65
1
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ...
79
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva __UpperCAmelCase = """""" __UpperCAmelCase = """""" __UpperCAmelCase = """""" __UpperCAmelCase = 1 # (0 is vertical, 1 is horizontal) def __A ...
79
1
import math def lowercase ( __A : int ) -> List[str]: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are no...
36
'''simple docstring''' # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def SCREAMING_SNAKE_CASE ( a_ : str , a_ : Union[str, Any] , a_ : Dict ): __a = { 'en': 'Machine learning is grea...
539
0
'''simple docstring''' import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_dif...
706
'''simple docstring''' def _lowerCAmelCase ( __a , __a ) -> float: '''simple docstring''' def get_matched_characters(__a , __a ) -> str: _UpperCamelCase :Any =[] _UpperCamelCase :List[str] =min(len(_stra ) , len(_stra ...
512
0
'''simple docstring''' import math def _lowerCAmelCase ( __snake_case : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all e...
8
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", # See all ViT MSN models at https://hu...
332
0
'''simple docstring''' from __future__ import annotations from cmath import sqrt def _a ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" if a == 0: raise ValueError('''Coefficient \'a\' must not be zero.'''...
718
import logging import os import threading import time try: import warnings except ImportError: __UpperCamelCase : Any = None try: import msvcrt except ImportError: __UpperCamelCase : Optional[Any] = None try: import fcntl ex...
106
0
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : float ) -> float: """simple docstring""" if edge <= 0 or not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError("""Length must be a positive.""" ) return 3 *...
433
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_av...
433
1
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { "huggingface/time-series-transformer-tourism...
367
import pytest import datasets # Import fixture modules as plugins UpperCAmelCase_ : Union[str, Any] = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): # Mark tests as "unit" by defa...
367
1
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowercase__ : _UpperCAmelCase :int _UpperCAmelCase :int class lowercase__ : def __init...
153
"""simple docstring""" from pathlib import Path import fire def _snake_case ( lowerCamelCase__ : str , lowerCamelCase__ : str , lowerCamelCase__ : int ) -> int: lowerCamelCase_ : Any =Path(lowerCamelCase__ ) ...
153
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.default_...
313
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward fro...
313
1
'''simple docstring''' import requests def snake_case_ ( _lowerCAmelCase : Optional[int] , _lowerCAmelCase : List[Any] ) -> None: UpperCAmelCase : List[Any] = {'''Content-Type''': '''application/json'''} UpperCAmelCase : List[str] ...
127
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "uw-madison/mra-base-512-4": "https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json", } cl...
232
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_i...
707
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class A__ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' @staticmethod @abstractmethod def _SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CAS...
615
0
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline...
436
'''simple docstring''' from __future__ import annotations from typing import Any def _UpperCamelCase ( UpperCamelCase__ ): """simple docstring""" if not postfix_notation: return 0 __magic_name__ : Optional[Any] = ...
436
1
from __future__ import annotations from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self : int , UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : float = 0): '''simple docstring''' ...
99
from __future__ import annotations import time a__ = list[tuple[int, int]] a__ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], ...
99
1