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
import os from datetime import datetime as dt from github import Github UpperCAmelCase_ : Dict = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def UpperCamelCase ( )-> str:...
491
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info()...
77
0
'''simple docstring''' 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 Tenso...
123
'''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_tokenizers from ...test_toke...
123
1
def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' return abs(__UpperCamelCase ) if a == 0 else greatest_common_divisor(b % a , __UpperCamelCase ) def A ( _lowerCamelCase , _lowerCamelCase ): ...
500
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 :Dict = {'configuration_xglm': ['XGLM_PRETRAIN...
86
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _UpperCamelCase : Tuple = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP",...
721
'''simple docstring''' from manim import * class _snake_case ( a_ ): def _SCREAMING_SNAKE_CASE ( self ): '''simple docstring''' lowerCAmelCase = Rectangle(height=0.5 , width=0.5 ) lowerCAmelCase = Rectangle(height=0.46 , widt...
514
0
import math import unittest def UpperCamelCase (lowercase_: int ) -> bool: assert isinstance(lowercase_ , lowercase_ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == ...
456
A_ : Union[str, Any] = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggingface/tra...
456
1
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, ...
720
"""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 di...
158
0
'''simple docstring''' import argparse import logging import pickle from collections import Counter logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) UpperCAmelCase_ : Union[str, Any] = logging.getLogge...
24
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ : List[str] = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'...
24
1
from __future__ import annotations def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE ) -> Tuple: """simple docstring""" _UpperCAmelCase : str = [True] * limit _UpperCAmelCase : int = False _UpperCAmelCase : List[str] ...
705
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor __lowerCamelCase = logging.get_logger(__name__) class _UpperCamelCase( SCREAMING_SNAKE_CASE ): def __init__( self : Any , *_lowerCamelCase : Any , **_lowerCamelCas...
328
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase_ = { 'configuration_efficientnet': [ 'EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EfficientNetC...
132
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
199
0
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM, ...
704
import os import re import shutil import sys import tempfile import unittest import black __lowerCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_copies # noqa: E402 # This is the referenc...
478
0
_A = ''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.git ''...
258
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[Any] = logging.get_logger(__name__) a : List[Any] = { '''microsoft/unispeech-sat-base-100h-libri-ft''': (...
633
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models at https://h...
720
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase_ = { '''configuration_clip''': [ ...
336
0
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_vision_available ...
16
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @s...
16
1
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_...
701
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """t5-small""": """https://huggingface.co/t5-small/resolve/m...
152
0
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, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is...
12
"""simple docstring""" import string def _UpperCamelCase ( A ): UpperCamelCase_ ="" for i in sequence: UpperCamelCase_ =ord(A ) if 65 <= extract <= 90: output += chr(155 - extract ) elif 97 <= extract <= 122: output += chr(...
391
0
import json from typing import 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 logging from .tokenization_roberta import RobertaToken...
704
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 AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKE...
446
0
import os import sys import unittest a__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_bac...
14
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC lowerCamelCase : Dict =parse(importlib.metadata.version('''torch''')) def SCREAMING_SNAKE_CASE ( __lowerCAmelCase...
228
0
'''simple docstring''' from __future__ import annotations def __lowercase ( _A ) -> Optional[int]: return len(set(lowercase__ ) ) == len(lowercase__ ) if __name__ == "__main__": import doctest doctest.testmod()
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ : str = {"""processing_layoutxlm""": ["""LayoutXL...
446
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 fr...
302
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class SCREAMING_SNAKE_CASE_ (a__ ): ...
278
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'Jukeb...
257
'''simple docstring''' from __future__ import annotations import bisect def __UpperCAmelCase ( a_: list[int], a_: int, a_: int = 0, a_: int = -1 ): if hi < 0: _UpperCAmelCase : int = len(a_ ) while lo < hi: _UpperCAmelCase :...
257
1
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _UpperCamelCase : int = logging.get_logger(__name__) def __UpperCAmelCase ( A : Union[tf.Tensor, np.ndarray] ) -> List[int]: if isinst...
541
'''simple docstring''' import argparse import os import re import packaging.version _UpperCamelCase : Union[str, Any] = 'examples/' _UpperCamelCase : List[str] = { 'examples': (re.compile(R'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\...
541
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'facebook/x...
713
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin SCREAMING_SNAKE_CASE = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot ap...
186
0
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import gl...
565
from __future__ import annotations def _lowerCAmelCase ( lowerCAmelCase_ :int , lowerCAmelCase_ :int )->list[str]: '''simple docstring''' if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes...
283
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verb...
283
"""simple docstring""" from __future__ import annotations class _lowerCamelCase : def __init__( self : Any , lowerCamelCase_ : list[list[int]] ): """simple docstring""" _lowercase : Tuple = TypeError( 'Matrices must be formed ...
283
1
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home lowerCamelCase_ : Any = HUGGINGFACE_HUB_CACHE lowerCamelCase_ : int = """config.json""" lowerCamelCase_ : Dict = """diffusion_pytorch_model.bin""" lowerCamelCase_ ...
559
from math import pow, sqrt def lowerCAmelCase( *__lowerCamelCase ): __a = len(__lowerCamelCase ) > 0 and all(value > 0.0 for value in values ) return result def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): return ( round(sqrt(molar_mass_a / mo...
559
1
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __magic_name__( _A ): '''simple...
265
'''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_modeling_common import M...
265
1
import argparse import json from tqdm import tqdm def __snake_case ( ): """simple docstring""" A_ = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" ,type=__UpperCamelCase ,default="biencoder-nq-dev.j...
86
from ..utils import DummyObject, requires_backends class _a ( metaclass=snake_case_ ): """simple docstring""" _lowerCamelCase : Optional[Any] = ['torch', 'transformers', 'onnx'] def __init__( self : str , *UpperCAmelCase ...
86
1
'''simple docstring''' import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) def _snake_case ( lowercase , lowercase )...
719
'''simple docstring''' __SCREAMING_SNAKE_CASE : int = 9.80_665 def _snake_case ( lowercase , lowercase , lowercase = g ) -> float: if fluid_density <= 0: raise ValueError("""Impossible fluid density""" ) if volume < 0: raise V...
697
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class A ( A_ ): def __init__(self , lowerCAmelCase , lowerCAmelCase ): __lowercase= params __lowercase= np.array(lowerCAmelCase ) __lowercase= ...
230
from math import ceil def _lowerCamelCase( lowercase__ = 1_0_0_1 ) -> int: '''simple docstring''' __lowercase= 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): __lowercase= 2 * i + 1 __lowercase= 2 * i __lowercase= total + 4 * odd**...
230
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
405
class __magic_name__ ( _a): pass class __magic_name__ ( _a): pass class __magic_name__ : def __init__( self : Optional[int] ): UpperCAmelCase = [ [], [], [], ] def _UpperCAmelCase ( self : Tuple ,__S...
405
1
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets UpperCAmelCase = '''\ @inproceedings{kakwani2020indicnlpsuite, title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Languag...
119
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase = { '''configuration_owlvit''': [ ...
119
1
"""simple docstring""" import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test...
255
"""simple docstring""" 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() UpperCAmelCase =logging.get_logger(__name__) U...
255
1
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowerCAmelCase: List[Any] =...
526
"""simple docstring""" # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def lowercase ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : Union[str, Any] , _SCREAMING_SNAKE_CASE : Tuple ): '''simple docs...
602
0
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowercase__ ( lowercase_ ,lowercase_=7 ) -> Tuple: """simple docstring""" _UpperCamelCase : Optional[int] = Non...
51
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCamelCase__ = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCamelCase__ = [ord(letter) for letter in string.asci...
51
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): i...
383
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): impor...
383
1
__a = """Alexander Joslin""" import operator as op from .stack import Stack def UpperCamelCase_ ( a_ ) ->int: A ={"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} A =Stack() A =Stack() for i in equation: if i.isdigit(): # RULE 1 operand_stack.push(int(a...
689
def UpperCamelCase_ ( a_ = 6008_5147_5143 ) ->int: try: A =int(a_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be greater than or equal to one." ) A =2 A =0 if n == 2: r...
689
1
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( Au...
455
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, ...
455
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ : Optional[int] = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2Con...
32
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Optional[int] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''...
32
1
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu UpperCamelCase = get_tests_dir(...
45
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def _UpperCamelCase ( lowerCAmelCase_ ) ->Optional[Any]: # This defines a "chinese character" as anything in the CJK Unicode block: # https://e...
377
0
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def __a ( __lowerCamelCase : Tuple ,...
461
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xope...
461
1
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import n...
373
"""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...
581
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case__( UpperCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : int = (EulerDiscr...
619
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import...
619
1
'''simple docstring''' import re import string import numpy as np import datasets _a : str = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ _a : List[Any] ...
689
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): impor...
689
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ViltForMaskedLM, Vilt...
720
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCamelCase : Optional[int] = logging.get_logger(__name__) __lowerCamelCase : Tuple = { '''shi-lab...
501
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_chann...
104
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_...
193
0
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class _UpperCAmelCase : """simple docstring""" a_ = 42 # [batch_size x 3] a_ = 42 # [batch_size x 3] a_ = 42 # [batch_size x 3] a_ = ...
421
def a_ ( lowerCAmelCase_ : str, lowerCAmelCase_ : str ): if not (isinstance(lowerCAmelCase_, lowerCAmelCase_ ) and isinstance(lowerCAmelCase_, lowerCAmelCase_ )): raise ValueError('longest_common_substring() takes two strings for inputs' ) __lowerCAmelCase ...
421
1
import datasets from .evaluate import evaluate _a : str = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016}...
479
import math import flax.linen as nn import jax.numpy as jnp def UpperCamelCase__ ( _A: jnp.ndarray , _A: int , _A: float = 1 , _A: float = 1 , _A: float = 1.0e4 , _A: bool = False , _A: float = 1.0 , ): '''sim...
479
1
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __A = logging.getLogger(__name__) def lowerCamelCase_ ( ) -> Any: """simple docstring""" __lowerCamelCase = argparse.Ar...
167
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuratio...
167
1
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class A__ : @property def UpperCamelCase__ ( self ): return self.ge...
681
'''simple docstring''' def lowerCamelCase ( lowerCamelCase : int = 10**9): A_ : Optional[int] = 1 A_ : int = 2 A_ : List[Any] = 0 A_ : Optional[Any] = 0 A_ : str = 0 while perimeter <= max_perimet...
665
0
'''simple docstring''' def lowerCamelCase__ ( UpperCamelCase__ : Any = 1_000 ) -> int: '''simple docstring''' _snake_case = 2**power _snake_case = 0 while n: _snake_case , _snake_case = r + n % 10, n ...
703
def lowerCamelCase__ ( UpperCamelCase__ : List[Any] , UpperCamelCase__ : Dict , UpperCamelCase__ : str , UpperCamelCase__ : int , UpperCamelCase__ : List[str] , UpperCamelCase__ : str ) -> List[Any]: ...
541
0
from manim import * class lowercase ( snake_case__): """simple docstring""" def _SCREAMING_SNAKE_CASE ( self : List[Any] ) -> Union[str, Any]: UpperCAmelCase_= Rectangle(height=0.5 , width=0.5 ) UpperCAmelCase_= Rectangle(height=0.25 , w...
593
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
593
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch,...
718
from __future__ import annotations A : List[Any] = 1_0 def __lowerCamelCase ( __a :list[int] ) -> list[int]: """simple docstring""" A__ = 1 A__ = max(__a ) while placement <= max_digit: #...
247
0
"""simple docstring""" import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F...
480
"""simple docstring""" from math import factorial def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : int = 2_0 ): """simple docstring""" snake_case_ : int = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,......
480
1
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :Dict = (CMStochasticIterativeScheduler,) UpperCAmelCase_...
256
"""simple docstring""" __UpperCAmelCase = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def _snake_case ( lowercase__ : int ) -> int: '''simple docstring''' lowerCAmelCase_ :str = 0 while number: ...
256
1
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_ = logging.get_logger(__name__) lowerCAmelCase_ = { '...
60
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device __UpperCAmelCase =False class lowerCAmelCase__ ( unittest.TestC...
337
0
'''simple docstring''' from __future__ import annotations from fractions import Fraction def snake_case_ (_a : int , _a : int ): return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def snake_case_ (...
358
'''simple docstring''' def snake_case_ (_a : list[list[int]] , _a : int , _a : int , _a : list[int] ): # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False ...
358
1
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, TFAutoModelForSeque...
66
'''simple docstring''' import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_...
664
0
'''simple docstring''' import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock fro...
703
'''simple docstring''' import random from typing import Any def A_ ( _lowerCAmelCase : list ): """simple docstring""" for _ in range(len(_lowerCAmelCase ) ): _lowerCamelCase : Any = random.randint(0 , len(_lowerCAmelCase ...
11
0
def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: __a = mf_knapsack(i - 1 , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) el...
99
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class a__ ( unittest.TestCase ): def ...
507
0
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : Optional[Any] ) -> Optional[Any]: """simple docstring""" lowerCAmelCase_ : Any = [0] * len(lowerCAmelCase__ ) lowerCAmelCase_ : Dict = [] lowerCAmelCas...
317
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] , lowerCAmelCase__ : int ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertic...
317
1
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ : Optional[int] = logging...
64
def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : int | float | str ) -> tuple[int, int]: try: SCREAMING_SNAKE_CASE_ : int =float(UpperCAmelCase_ ) except ValueError: raise ValueError('''Please enter a valid number''' ) SCREAMI...
443
0
import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets __A : Tuple = '\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n and Saurav Kadavath\n and Akul Arora\n ...
75
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _SCREAMING_SNAKE_CASE ( unittest.TestCase): ...
75
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Any = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class _lowerCamelCase( _a ): lowercase_ ...
89
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(_SCREAMING_SNAKE_CASE ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod ...
93
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer __A ={"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"} __A ={ ...
702
def a ( _UpperCAmelCase : list[int] , _UpperCAmelCase : list[int] ): '''simple docstring''' __UpperCAmelCase : Dict = len(_UpperCAmelCase ) print('''The following activities are selected:''' ) # The first activity is always...
241
0
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ :Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ :Any = ...
355
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowercase_ ...
562
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> str: if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeEr...
719
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 from utils import ROUGE_KE...
311
0
"""simple docstring""" import argparse import struct import unittest class __magic_name__ : def __init__( self : List[Any] , snake_case_ : bytes ): __snake_case = data # Initialize hash values __snake_case = ...
163
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision,...
163
1
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def _snake_case ( __snake_case , __snake_case , __snake_case , __snake_case=5 ) -> List[Any]: '''simple docstring''' assert masked_input.count("<mask>" ) == 1 U...
455
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json''', } class snake_cas...
455
1
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = 3 , SCREAMING_SNAKE_CASE__ = 7 , SCREAMING_SNAKE_CASE__ = 100_0000 ) -> int: '''simple docstring''' snake_case : str = 0 snake_case : Tuple = 1 for curr...
638
'''simple docstring''' import os from collections.abc import Iterator def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = "." ) -> Iterator[str]: '''simple docstring''' for dir_path, dir_names, filenames in os.walk(SCREAMING_SNAKE_CASE__ ): snake_case : Optiona...
638
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: if not is_torch_available...
711
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __SCREAMING_SNAKE_CASE : snake_case : int snake_case : Node | None = None ...
548
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) SCREAMING_SNAKE_CASE : List[Any] = { "configuration_trocr": ["TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrOCR...
89
'''simple docstring''' import flax.linen as nn import jax import jax.numpy as jnp class a__ ( nn.Module ): _SCREAMING_SNAKE_CASE : int _SCREAMING_SNAKE_CASE : jnp.dtype = jnp.floataa def _lowerCamelCase ( self ): """simple docstring""" _lo...
245
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeechConfig''']} t...
711
import sys _A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452445231617318564030987111217223...
294
0
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class snake_case__ (A__ ): """simple docstring""" ...
136
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils impor...
93
0
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def lowerCAmelCase_( lowercase_ : Any="ro" , lowercase_ : Optional[int]="en" , lowercase_ : int="wmt16" , lowercase_ : int=None ) -> None: try: ...
623
"""simple docstring""" import warnings from .generation import TFGenerationMixin class lowerCamelCase_( A__ ): '''simple docstring''' warnings.warn( 'Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ' 'be removed i...
623
1
"""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...
103
"""simple docstring""" def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> int: return 1 if input_a == input_a else 0 def snake_case ( ) -> None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , ...
103
1
def snake_case__ ( __lowercase = 5_0 ) -> int: """simple docstring""" A__ : Any = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_le...
182
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
182
1
def __A ( _lowercase ): '''simple docstring''' _A = [0] * len(_lowercase ) _A = [] _A = [1] * len(_lowercase ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(_lower...
484
from typing import Union import fire import torch from tqdm import tqdm def __A ( _lowercase , _lowercase = "cpu" , _lowercase = None ): '''simple docstring''' _A = torch.load(_lowercase , map_location=_lowercase ) for k, v in t...
484
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available ...
705
from __future__ import annotations from typing import Any def __lowercase( __snake_case : list ) -> int: if not postfix_notation: return 0 __snake_case = {'+', '-', '*', '/'} __snake_case = [] for token in postfix_notation: ...
345
0
"""simple docstring""" def snake_case_ ( A_ : int = 1_00_00_00 ): '''simple docstring''' _lowerCamelCase : str = set(range(3, A_, 2 ) ) primes.add(2 ) for p in range(3, A_, 2 ): if p not in primes:...
83
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
98
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 : Optional[int] = [ 'Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phon...
353
def A_ ( a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = 0 while num > 0: digit_sum += num % 1_0 num //= 1_0 return digit_sum def A_ ( a = 1_0_0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ ...
353
1
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _lowerC...
678
from manim import * class _lowerCAmelCase ( _lowercase ): def __magic_name__( self ): lowerCAmelCase__ : Tuple = Rectangle(height=0.5 , width=0.5 ) lowerCAmelCase__ : Dict = Rectangle(height=0.25 , width=0.25 ) lowerCAmelC...
678
1
'''simple docstring''' def UpperCamelCase__ ( _lowercase : list ) -> float: __UpperCAmelCase: Union[str, Any] = 0 while len(_lowercase ) > 1: __UpperCAmelCase: Dict = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): __UpperC...
466
'''simple docstring''' def UpperCamelCase__ ( _lowercase : list[int] , _lowercase : list[int] ) -> None: __UpperCAmelCase: Dict = len(_lowercase ) print("""The following activities are selected:""" ) # The first activity is always selected __UpperCAmelCase...
466
1
UpperCamelCase = range(2, 20 + 1) UpperCamelCase = [10**k for k in range(ks[-1] + 1)] UpperCamelCase = {} def A ( lowercase__ : List[Any] , lowercase__ : Tuple , lowercase__ : str , lowercase__ : Optional[Any] ) -> Any: UpperCamelCase__ :List[Any] = ...
45
from __future__ import annotations def A ( lowercase__ : int ) -> list[int]: UpperCamelCase__ :Union[str, Any] = [True] * limit UpperCamelCase__ :int = False UpperCamelCase__ :Optional[Any] = False UpperCamelCase__ :str = True for i in range(3 , int...
45
1
"""simple docstring""" def a__ ( __lowercase , __lowercase , __lowercase , __lowercase ) -> str: # Return True if there is node that has not iterated. _A = [False] * len(__lowercase ) _A = [] queue.append(__lowercase ) _A = True...
621
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from ...
621
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is the refer...
109
def __magic_name__ ( SCREAMING_SNAKE_CASE = 50 ) -> int: _lowercase : Optional[int] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in...
66
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class a ( __SCREAMING_SNAKE_CASE ): """simple docstring...
716
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class a ( __SCREAMING_SNAKE_CASE ): """simple docstring""" def UpperCAmelCase_ ( self : List[str] , lowerCamelCase__ : float ...
362
0
from __future__ import annotations import requests def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> dict: a = f'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty''' return requests.get(__UpperCamelCase).json() def SCREAMING_SNAKE_CASE ( __UpperCamelCa...
515
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : int = logging.get_logger(__name__) lowercase__ : Any = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/m...
515
1
_lowercase : List[Any] ={ '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''': '''flax>=0.4.1''', ...
661
import math def A__ ( lowercase: int ) -> list: A : Optional[Any] =[True] * n A : Tuple =False A : List[Any] =False A : Dict =True for i in range(3, int(n**0.5 + 1 ), 2 ): ...
661
1
def __lowerCAmelCase ( _UpperCamelCase ) -> int: '''simple docstring''' lowerCamelCase__: Optional[Any] = hex_num.strip() if not hex_num: raise ValueError("""No value was passed to the function""" ) lowerCamelCase__: Lis...
306
_lowercase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _lowercase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list[int]: '''simple docstring''' ...
306
1
__UpperCamelCase : List[str] = 0 # The first color of the flag. __UpperCamelCase : Any = 1 # The second color of the flag. __UpperCamelCase : Union[str, Any] = 2 # The third color of the flag. __UpperCamelCase : Union[str, Any] = ...
718
import math import qiskit def snake_case_ ( __lowercase = 1 , __lowercase = 1 , __lowercase = 1 ): if ( isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , _...
641
0
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 ...
108
'''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, get_resize_output_image_size, normalize, rescale, resize, to_chan...
314
0
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class lowerCamelCase__ ( UpperCAmelCase ,unittest.TestCase ): UpperCamelCase__ =DownBlockaD # noqa ...
713
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from .....
225
0
'''simple docstring''' from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase ( ) ->tuple[list[int], int]: _SCREAMING_SNAKE_CASE = [randint(-1000 , 1000 ) for i in range(10 )] _SCRE...
314
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowercase_ = logging.get_logger(__name__) class a_ ( snake_case_ ): '''simple docstring''' def __init__( self , *A , **A ) ...
314
1
import re def _snake_case ( __snake_case ): _UpperCamelCase = re.compile(R'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' ) if match := re.search(__snake_case , __snake_case ): return match.string == phone return False if __name__ == "__main__": print(indian_phone_valida...
702
from __future__ import annotations import math class lowerCAmelCase_ : def __init__( self : int , _A : int ): _UpperCamelCase = size # approximate the overall size of segment tree with given value _UpperCamelCase = [0 for i in r...
71
0
from __future__ import annotations _UpperCAmelCase : Union[str, Any] = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _Upper...
295
# 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 b...
295
1
'''simple docstring''' def _UpperCamelCase ( _a : list , _a : list , _a : int ): """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 ...
287
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a= { '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowerConfig''', '''BridgeTow...
287
1
"""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 ...
602
"""simple docstring""" __A : Optional[int] = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio fro...
602
1
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case = None ,__snake_case = None ,__snake_case = None ,) -> Tup...
29
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _a = logging.get_logger(__name__) class __A ( lowerCAmelCase ): '''simple docstring''' def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ...
29
1
from math import factorial, pi def UpperCamelCase_ ( __a , __a = 30 ) -> float: if not isinstance(__a , (int, float) ): raise ValueError("maclaurin_sin() requires either an int or float for theta" ) if not isinstance(__a , __a ) or accuracy <= 0...
37
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
469
0
def __snake_case ( _UpperCAmelCase ): """simple docstring""" if num < 0: return False lowercase = num lowercase = 0 while num > 0: lowercase = rev_num * 10 + (num % 10) num //= 10 retu...
720
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() __magic_name__ ...
314
0