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''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { """BridgeTower/bridgetower-base""": """https://huggingfac...
92
'''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 Mod...
92
1
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __a : str = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pytorch'''...
298
import unittest from knapsack import knapsack as k class UpperCAmelCase( unittest.TestCase ): """simple docstring""" def __a ( self ) -> Union[str, Any]: """simple docstring""" lowercase__ : Optional[Any] ...
298
1
from __future__ import annotations def A(__a: dict , __a: str ): lowerCAmelCase_ = set(snake_case__ ), [start] while stack: lowerCAmelCase_ = stack.pop() explored.add(snake_case__ ) # Differences from BFS: # 1) pop last element instead of...
122
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerat...
261
0
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import ...
558
"""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 OptionalDepende...
558
1
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTes...
70
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available...
70
1
"""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_vision_...
709
"""simple docstring""" import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase : '''simple docstring''' def __init__( self: Any , snake_case: Dict=2 , snake_case: Uni...
310
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformer...
198
class UpperCamelCase_ : '''simple docstring''' def __init__( self , a ) -> Tuple: snake_case_ = n snake_case_ = [None] * self.n snake_case_ = 0 # index of the first element snake_case_ = 0 ...
198
1
'''simple docstring''' import math import tensorflow as tf from packaging import version def _UpperCAmelCase ( a : List[Any] ) -> Dict: """simple docstring""" lowercase_ : int = tf.convert_to_tensor(__UpperCamelCase ) lowercase_ : int ...
720
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __magic_name__ ( unittest.TestCase ): """simple docstring""" def lowerCamelCase__ ( self ) -> Optional[Any]: lowercase_ : ...
7
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase : Any ={ '''configuration_roberta''': ['''ROBERTA...
228
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase = None ) -> list[list[str]]: UpperCamelCase__ : Tuple = word_bank or [] # create a table UpperCamelCase__ : int ...
228
1
from typing import Union import fire import torch from tqdm import tqdm def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = "cpu" , SCREAMING_SNAKE_CASE_ = None ) -> None: lowerCamelCase : Dict =torch.load(SCREAMING_SNAKE_CASE_ , ...
262
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer/resolve/main/config.json''', } class snake_case_ ( ...
262
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_...
38
from __future__ import annotations from typing import Any class _a : """simple docstring""" def __init__( self: Optional[int] , __lowerCamelCase: int ): '''simple docstring''' UpperCamelCase__: Optional[Any] = num_of_nod...
380
0
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) __SCREAMING_SNAKE_CASE = str(...
13
'''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 if is_torch_available(): import...
13
1
"""simple docstring""" from math import factorial def UpperCAmelCase__ ( lowerCAmelCase__ :int = 1_0_0 ) -> int: '''simple docstring''' return sum(int(lowerCAmelCase__ ) for x in str(factorial(lowerCAmelCase__ ) ) ) if __name__ == ...
359
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCAmelCase : Tuple =logging.get_logger(__name__) __lowerCAmelCase : Dict ={ """ut/deta""": """https://huggingfa...
359
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Any = logging.get_logger(__name__) _a : Tuple = { 'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-...
84
import torch from diffusers import DiffusionPipeline class a_ ( a ): def __init__( self : Optional[Any] , UpperCAmelCase__ : Tuple , UpperCAmelCase__ : List[Any] ): """simple docstring""" super().__init__() se...
84
1
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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_a...
480
import os import jsonlines import numpy as np from tqdm import tqdm UpperCAmelCase_ : Dict = 2048 UpperCAmelCase_ : int = 4096 UpperCAmelCase_ : Any = 42 UpperCAmelCase_ : Optional[int] = os.environ.pop("PROCESS_TRAIN", "false") UpperCA...
21
0
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """google/umt5-small""": """https://huggingfa...
342
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=_lowercase): snake_case__ = ['''torch''', '''scipy'''] def __init__( self : List[Any] , *__UpperCamelCase : int , **__UpperCamelCase : Any ) -> Any: ...
342
1
"""simple docstring""" from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class lowercase__( SCR...
698
'''simple docstring''' _lowerCAmelCase = [0, 2, 4, 6, 8] _lowerCAmelCase = [1, 3, 5, 7, 9] def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" if remaining_length == 0: ...
565
0
"""simple docstring""" import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE = """ 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. """ SCREAMING_SNAKE_CASE ...
701
"""simple docstring""" def lowerCamelCase__ ( UpperCAmelCase_ )-> int: """simple docstring""" if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): ...
556
0
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor a__ : Dict = logging.get_logger(__name__) class UpperCAmelCase_ ( _UpperCamelCase ): def __init__( self ,*__snake_case ,**__snake_case ): """simple docstrin...
188
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify,...
266
0
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackbon...
718
import re import string import numpy as np import datasets lowercase_: Optional[Any] = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' lowercase_: Optional[int] = '\...
127
0
'''simple docstring''' from collections import defaultdict def __lowerCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ) -> bool: _a : List[str] = first_str.lower().strip() _a : Dict = second_str.lower().strip() # Remove whitespace _a : List[Any] = first_str.repl...
358
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar __lowerCAmelCase = TypeVar('''T''') class __magic_name__ ( Generic[T] ): ...
358
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase = { """configuration_roformer""": ["""ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Ro...
707
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput ...
150
0
import math def A__ ( __A : int ) ->bool: __A =math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(__A ) def A__ ( __A : float = 1 / 1_23_45 ) ->int: __A =0 __A =0 __A =3 whi...
184
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import...
157
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer A__ : Dict = logging.get_logger(__name__) A__ : Op...
701
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A__ : Any = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} try: ...
671
0
'''simple docstring''' import math UpperCamelCase_ = 10 UpperCamelCase_ = 7 UpperCamelCase_ = BALLS_PER_COLOUR * NUM_COLOURS def _lowerCAmelCase ( __magic_name__ : int = 20 ) -> str: lowercase : Any =math.comb(__magic_...
92
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Union[str, Any] = { """snap-research/efficientformer-l1-300""": ( """https://hug...
295
0
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since t...
171
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def __lowerCamelCase ( A__ : Union[dict, list, tuple, torch.Tensor] ) -> Lis...
171
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils im...
5
"""simple docstring""" 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.distribu...
91
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCAmelCase ( _UpperCAmel...
719
"""simple docstring""" import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def A_ ( ...
396
0
import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose, ) if is_flax_available...
464
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor lowerCamelCase = logging.get_logger(__name__) class A ( UpperCamelCase_ ): def __init__( self : Optional[Any] , *lowercase_ : str , **lowercase_ : List[Any] ) ...
464
1
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig if ...
86
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMaskedLM, DistilBer...
86
1
"""simple docstring""" import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py lowercase = '''.''' if __name__ == "__main__": lowercase = os.path.join(REPO_PATH, '''u...
573
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if...
573
1
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conve...
271
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conve...
271
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf...
72
'''simple docstring''' def UpperCamelCase ( lowercase_ : int , lowercase_ : int ) -> str: '''simple docstring''' return "\n".join( f'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplicati...
72
1
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets __snake_case : str ='\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wang, Alex and S...
707
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __snake_case : Optional[int] =(3, 9, -1_1, 0, 7, 5, 1, -1) __snake_case : str =(4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class lowerCamelCase__ : '''simpl...
90
0
"""simple docstring""" from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils i...
677
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrateg...
512
0
UpperCAmelCase_ = { "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M": "--", "N": "-.", "O": "---", "P": ".--.", "Q": "--.-", "R": ".-.", "S": "...", "T": "-", "U": "..-", "V": "...-", "...
664
def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : Optional[Any] )->Any: # noqa: E741 _lowerCAmelCase = len(_SCREAMING_SNAKE_CASE ) _lowerCAmelCase = 0 _lowerCAmelCase = [0] * n _lowerCAmelCase = [False] * n _lowerCAmelCase = [False] * n def d...
664
1
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(f...
441
"""simple docstring""" from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class __a : pass
552
0
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, Truncatio...
9
'''simple docstring''' from __future__ import annotations import math def A__ ( __lowerCAmelCase : int ): 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...
9
1
# 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_CHECKIN...
87
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __a: Optional[int] = logging.get_logger(__name__) __a: Any = { """t5-small""": """https://huggingface.co/t5-small/re...
152
0
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from...
524
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTok...
524
1
'''simple docstring''' import torch from ..models.speechta import SpeechTaForTextToSpeech, SpeechTaHifiGan, SpeechTaProcessor from ..utils import is_datasets_available from .base import PipelineTool if is_datasets_available(): from datasets import load_dataset class _sna...
436
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : Optional[Any] = logging.get_logger(__name__) UpperCamelCase_ : Any = { '''microsoft/unispeech-sat-base-100h-libri-ft'...
185
0
from scipy.stats import spearmanr import datasets UpperCAmelCase__ = "\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no correlation.\nPositive correlations imply ...
639
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transformers import Auto...
639
1
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME __UpperCAmelCase = ['''small''', '''medium''', '''large'''] __UpperCAmelCase = '''lm_head.decoder.weight''' __UpperCAmelCase = '''l...
90
"""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 class __lowe...
594
0
'''simple docstring''' from __future__ import annotations class a : """simple docstring""" def __init__( self , snake_case_ ): '''simple docstring''' __UpperCAmelCase: List[str] = TypeError( """Matrices must be formed from a list of zero or more lis...
466
'''simple docstring''' from __future__ import annotations import time import numpy as np SCREAMING_SNAKE_CASE_ = [8, 5, 9, 7] SCREAMING_SNAKE_CASE_ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] SCREAMING_SNAKE_CASE_ = [ [3, 2, 1, 4], [0, ...
466
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : Any = logging.get_logger(__name__) __a : Optional[Any] = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json'...
397
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings __a : Dict = ...
397
1
'''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()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
719
'''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_comm...
126
0
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def A__ ( __lowerCAmelCase : ...
50
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import...
431
0
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import AP...
392
from collections import namedtuple lowercase : List[str] = namedtuple("""from_to""", """from_ to""") lowercase : Tuple = { """cubicmeter""": from_to(1, 1), """litre""": from_to(0.001, 1_0_0_0), """kilolitre""": from_to(1, 1), """gallon""": from_to(0.00_454, 264.172), ...
392
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { 's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json', } class...
224
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _UpperCAmelCase ( __lowerCamelCase : str = "isbn/0140328726" ) -> dict: _snake_case = olid.strip().strip('''/''' ) # Remove leading/trailing white...
224
1
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> bool: UpperCAmelCase_ = 0 for ch in input_str: UpperCAmelCase_ = ord(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ = pow(2 , __SCREAMING_SNAKE_CASE ) # If we already turned on bit for current character's unicode i...
23
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel...
465
def _lowerCAmelCase ( __lowerCAmelCase = 200 ) -> int: """simple docstring""" snake_case__ : Optional[int] = [1, 2, 5, 10, 20, 50, 100, 200] snake_case__ : List[Any] = [0] * (pence + 1) snake_case__ : str = 1 # base case: 1 w...
252
0
from dataclasses import dataclass, field from typing import Optional @dataclass class lowercase : """simple docstring""" a__ = field( default="codeparrot/codeparrot" , metadata={"help": "Model name or path of model to be trained."} ) a__ = field( ...
648
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository ...
648
1
"""simple docstring""" # Copyright 2022 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...
83
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
561
0
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. UpperCamelCase_ = 10 def _UpperCAmelCase ( A , A , A , ...
716
def _UpperCAmelCase ( A , A ): '''simple docstring''' _validate_point(A ) _validate_point(A ) if len(A ) != len(A ): raise ValueError("Both points must be in the same n-dimensional space" ) return float(sum(abs(a - b ) for a...
510
0
"""simple docstring""" import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @datacla...
156
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _...
156
1
import argparse import json from tqdm import tqdm def _snake_case ( ) -> Any: '''simple docstring''' UpperCAmelCase_ : Tuple = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=lowerCamelCase...
715
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_roformer''': ['''ROFORMER_PRETRAINED_CONFIG_ARCHIVE_M...
455
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenize...
272
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BlipConfig'...
272
1
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GE...
711
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCAmelCase_ = logging.get_logger(__name__) def UpperCAmelCase ( A__ , A__ ...
519
0
"""simple docstring""" # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar SCREAMING_SNAKE_CASE_ = TypeVar('''T''') class _UpperCAmelCase ( Ge...
373
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ ( unittest.TestCas...
67
0
def UpperCamelCase ( _a , _a ) -> str: '''simple docstring''' lowercase_ :Optional[int] = len(lowerCamelCase__ ) lowercase_ :Optional[Any] = len(lowerCamelCase__ ) lowercase_ :List[Any] = ( ...
721
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_...
441
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list ...
674
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require...
674
1
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers...
518
"""simple docstring""" def __magic_name__ ( __snake_case : str ) -> list: lowercase : Optional[Any] = [0] * len(__snake_case ) for i in range(1 , len(__snake_case ) ): # use last results for better performance ...
518
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : List...
348
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 __magic_name__ ( nn.Module ): ...
348
1
'''simple docstring''' def __A ( lowerCAmelCase_ = 1000 ): _UpperCAmelCase : Any = 3 _UpperCAmelCase : Optional[int] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: r...
156
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase_ : List[Any] = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encode...
156
1
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_collato...
699
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, ) _UpperCAmelCase = {"configuration_xglm": ["XGLM_PRETRAINED_C...
699
1
'''simple docstring''' import requests __A : Union[str, Any] = """YOUR API KEY""" def UpperCamelCase_ ( A__ : int , A__ : Any = giphy_api_key ): '''simple docstring''' lowerCAmelCase_ : str ...
719
'''simple docstring''' import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __snake_case ( unittest.TestCase): """simple docstring...
398
0
'''simple docstring''' def __UpperCAmelCase ( __magic_name__ ,__magic_name__ )-> tuple[float, float]: """simple docstring""" if not len(SCREAMING_SNAKE_CASE_ ) == len(SCREAMING_SNAKE_CASE_ ) == 3: raise ValueError("Please enter a valid equati...
653
"""simple docstring""" from manim import * class lowerCAmelCase ( lowerCamelCase_ ): '''simple docstring''' def __A ( self ) -> Union[str, Any]: SCREAMING_SNAKE_CASE = Rectangle(height=0.5 , width=0.5 ) SCRE...
247
0
from __future__ import annotations def _A (UpperCamelCase : int | str ) ->bool: '''simple docstring''' lowerCamelCase__ : Tuple = str(UpperCamelCase ) return n == n[::-1] def _A (UpperCamelCase : int = 1000000 ) ->int: '''simple docstri...
706
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from tran...
96
0
import unittest from transformers import MPNetConfig, 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 ...test_pi...
136
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def lowerCAmelCase_ ( _lowercase : Dict) -> List[str]: """simple docstring""" a__ : Union[str, Any] = [ """encod...
136
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transp...
667
'''simple docstring''' __lowerCamelCase = range(2, 20 + 1) __lowerCamelCase = [10**k for k in range(ks[-1] + 1)] __lowerCamelCase = {} def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__ ) -> Tuple...
667
1
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_diffusion.pipeline_stable_diffusi...
302
def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): # Check if the input is valid if not len(__lowerCamelCase ) == len(__lowerCamelCase ) == 3: raise ValueError('Please enter a valid equation.' ) if equationa[0] == equationa[1] == equationa[0] == equationa[1] == ...
559
0
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class snake_case__ ( unittest.TestCase ...
124
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device A__ : Optional[int] = False class snake_c...
124
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, requi...
467
'''simple docstring''' 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 f...
467
1
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from tokeniz...
720
import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets a_ : Optional[int] = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Langua...
444
0
"""simple docstring""" from timeit import timeit def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> int: if number < 0: raise ValueError("""the value of input must not be negative""" ) _lowerCAmelCase : Dict = 0 while number: number &= number - 1 result +=...
213
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __A : def __init__( self , a__ , a__ , a__ ): if dst_width < 0 or dst_height < 0: raise ValueError("""Destination width/height should be > 0""" ) ...
213
1
"""simple docstring""" import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union A__ : Union[str, Any] = re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""") @total_ordering @dataclass c...
716
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def a__ ( lowerCAmelCase : List[str] ): '''simple docstring''' def wrapper(*lowerCAmelCase : Any , ...
660
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node snake_case__ = 4 snake_case__ = 3 class UpperCAmelCase ( __a ): ...
583
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_d...
342
0
'''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.or...
711
'''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, ) lowerCamelCase__ ...
411
0
# Lint as: python3 import itertools import os import re a_ : Optional[Any] = re.compile(R'([A-Z]+)([A-Z][a-z])') a_ : List[str] = re.compile(R'([a-z\d])([A-Z])') a_ : str = re.compile(R'(?<!_)_(?!_)') a_ : Dict = re.compile(R'(_{2,})') a_ :...
73
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __SCREAMING_SNAKE_CASE ( UpperCamelCase): ...
576
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface.co/facebook/s2t-w...
183
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class _UpperCAmelCase ( SCREAMING_SNAKE_CASE_ ): __SCREAMING_SNAKE_CASE : Union[str, Any] ...
183
1
"""simple docstring""" def _UpperCamelCase ( _A , _A ) -> float: """simple docstring""" if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 * mass * abs(_A ) * abs(_A ) if __name__ == "__main__": import doctest doctest....
555
"""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...
555
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : List[str] = { '''configuration_longformer''': [ '''LONGFORMER_PRETRAINED_CONFI...
19
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class a_ ( _UpperC...
19
1
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, ) UpperCAmelCase_ = {"""configuration_mbart""...
458
UpperCAmelCase_ = {"""a""": ["""c""", """b"""], """b""": ["""d""", """e"""], """c""": [], """d""": [], """e""": []} UpperCAmelCase_ = ["""a""", """b""", """c""", """d""", """e"""] def __magic_name__ ( lowercase , lowercase , lowercase ) -> Union[str...
458
1
'''simple docstring''' def __a ( __lowerCamelCase : list[int] , __lowerCamelCase : list[int] ) -> tuple[float, float]: '''simple docstring''' if not len(__lowerCamelCase ) == len(__lowerCamelCase ) == 3: raise ValueError("Please enter a valid equation." ) ...
720
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowerCAmelCase_ : Dict = TypeVar("T") class lowercase ( Generic[T]...
461
0
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionM...
208
'''simple docstring''' # Lint as: python3 import itertools import os import re UpperCamelCase =re.compile(R"([A-Z]+)([A-Z][a-z])") UpperCamelCase =re.compile(R"([a-z\d])([A-Z])") UpperCamelCase =re.compile(R"(?<!_)_(?!_)") UpperCamelCase =re.compile(R"(_{2,})") UpperC...
208
1
from ...configuration_utils import PretrainedConfig lowercase : List[str] = { 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co...
710
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.du...
607
0
'''simple docstring''' import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
11
'''simple docstring''' def UpperCamelCase ( lowercase_ : int ) -> int: '''simple docstring''' if n == 1 or not isinstance(lowercase_ , lowercase_ ): return 0 elif n == 2: return 1 else: lowercase =[0, 1] for i in range(2 , n + 1 ): sequenc...
72
0
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __lowerCamelCase ( __a :Any , __a :Union[s...
247
from ...configuration_utils import PretrainedConfig from ...utils import logging A : int = logging.get_logger(__name__) A : Optional[Any] = { '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''', '''uclanlp/...
247
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase ( A ): lowerCAmelCase_ = ["image_processor", "tokenizer"] lowerCAmelCase_ = "CLIPImageProcessor" lowerC...
119
'''simple docstring''' import string def __UpperCamelCase ( lowercase__ : str ): '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): __lowercase ='' for symbol in message: if symbol in string.ascii_uppercase: ...
119
1
'''simple docstring''' def UpperCAmelCase_ (__a : int , __a : int ): """simple docstring""" if not isinstance(__a , __a ): raise ValueError('iterations must be defined as integers' ) if not isinstance(__a , __a ) or not number >= 1: raise ...
319
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_con...
319
1
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE = 50 ): lowercase = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_length ): ways_number[row_length] += ways...
84
'''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 __...
697
0
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase (_UpperCAmelCase ): __A = (UnCLIPScheduler,) def _a ( self , **_lowerCAmelCase ) -> str: '''simple docst...
714
'''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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImage...
653
0
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig __lowercase : int = logging.getLogger(__name__) class _A ( _UpperCAmelCase ): """simple docstring""" UpperCamelCase_ : Tuple ...
564
"""simple docstring""" import argparse from collections import defaultdict def SCREAMING_SNAKE_CASE ( snake_case, snake_case, snake_case, snake_case, snake_case): __snake_case = f"{file}_{class_name}_{test_name}" done_test[_id] += 1 with open(snake_case, ''...
564
1
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaM...
707
'''simple docstring''' import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(".") def _lowerCamelCase (__lowerCamelCase : List[str] ) -> List[str]: ...
289
0
def snake_case__ ( UpperCAmelCase : float , UpperCAmelCase : float ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 ...
145
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _a : Tuple = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """w...
145
1
"""simple docstring""" from typing import Any class lowercase__ : def __init__( self : Tuple , snake_case__ : Any ): lowerCamelCase_ : List[Any] =data lowerCamelCase_ : Union[str, Any] =None def __repr__( self : ...
244
"""simple docstring""" from datetime import datetime as dt import os from github import Github A__ : int = [ 'good first issue', 'good second issue', 'good difficult issue', 'feature request', 'new model', 'wip', ] def _snake_case ( ) -> List[...
244
1
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance __UpperCamelCase : Optional[Any] = 6_378_137.0 __UpperCamelCase : Any = 6_356_752.314_245 __UpperCamelCase : Optional[int] = 6378137 def _UpperCAmelCase ( Up...
519
import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import Tokenize...
519
1
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def A ( ) -> List[Any]: __UpperCamelCase = ArgumentParser( description=( 'PyTorch TPU d...
293
"""simple docstring""" import string import numpy def A ( snake_case :int , snake_case :int ) -> int: return b if a == 0 else greatest_common_divisor(b % a , snake_case ) class __lowerCAmelCase : lowercase = string.ascii_uppercase + string.digits #...
293
1
import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() __a: int = logging.get_logger(__name__) def _...
108
"""simple docstring""" import collections import os import re from pathlib import Path lowerCamelCase__ = "src/transformers" # Matches is_xxx_available() lowerCamelCase__ = re.compile(R"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} lowerCamelCase__ = re.compile(R"^_i...
624
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.uti...
705
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar A__ : Any= TypeVar("""T""") class __lowerCamelCase ( Generic[T] ): def __init__( self , snake_case_ ) -> None: UpperCamelCase__ = data ...
20
0