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 os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not...
237
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_S...
237
1
from __future__ import annotations from typing import Any class lowerCAmelCase__: '''simple docstring''' def __init__( self , __lowerCamelCase ) -> Tuple: _SCREAMING_SNAKE_CASE : Tuple = num_of_nodes _SCREAMING_SN...
704
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ={ 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json' ), # See a...
381
0
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def _A ( SCREAMING_SNAKE_CASE = "" ): UpperCAmelCase__: Optional[Any] = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" UpperCAmelCase__: str = BeautifulSoup(requests.get(__lowerCAme...
113
import numpy as np def __lowercase ( __lowerCAmelCase : np.ndarray , __lowerCAmelCase : float ): return np.where(vector > 0 , __lowerCAmelCase , (alpha * (np.exp(__lowerCAmelCase ) - 1)) ) if __name__ == "__main__": import doctest doct...
335
0
class __UpperCamelCase : """simple docstring""" def __init__( self : Optional[Any] , _A : Dict , _A : Optional[int] ): """simple docstring""" __SCREAMING_SNAKE_CASE : str = name __SCREAMING_SNAKE_CAS...
131
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging lowercase_ = logging.get_logger(__name__) def a__ ( snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : Opt...
131
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def __UpperCAmelCase ( __...
14
"""simple docstring""" import itertools import math def lowerCamelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
139
0
from __future__ import annotations def UpperCamelCase__( UpperCamelCase__ : list[list[int]] )->int: # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column ...
212
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
212
1
import math __A : List[str] = 10 __A : Any = 7 __A : str = BALLS_PER_COLOUR * NUM_COLOURS def __lowerCAmelCase( _SCREAMING_SNAKE_CASE = 20 ) -> str: """simple docstring""" _A = math.c...
27
UpperCamelCase = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] UpperCamelCase ...
520
0
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_...
713
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
94
0
'''simple docstring''' from math import asin, atan, cos, radians, sin, sqrt, tan lowerCAmelCase_ : List[str] = 6378137.0 lowerCAmelCase_ : Dict = 6356752.314245 lowerCAmelCase_ : List[Any] = 6378137 def _lowerCamelCase (__lowerCamelCase : List[str] , ...
489
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils i...
530
0
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _...
574
'''simple docstring''' from pathlib import Path import fire def __UpperCAmelCase ( UpperCamelCase__ :str , UpperCamelCase__ :str , UpperCamelCase__ :int ) -> List[Any]: snake_case__ : int = Path(UpperCamelCase__ ) snake_...
574
1
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments UpperCAmelCase__ = logging.getLogger(__name__) @dataclass class a ( lowerCAmelCase_ ): _snake_ca...
277
"""simple docstring""" from collections.abc import Generator def __UpperCAmelCase ( ): """simple docstring""" _UpperCAmelCase , _UpperCAmelCase = 0, 1 while True: _UpperCAmelCase , _UpperCAmelCase = b, a + b yield b def __UpperCAmelCase...
277
1
'''simple docstring''' import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = {'vocab_file': 'vocab.json'} __SCREAMING_SNAKE_CASE = { ...
713
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) ...
340
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MA...
45
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __snake_case ): """simple docstring""" __lowerCAmelCase = (UnCLIPScheduler,) def snake_case__ ( self , **lowerCAmelCase_ ): __lower...
321
0
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common imp...
713
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class __snake_case ( __SCREAMING_SNAKE_CASE ): ...
419
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemak...
24
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDi...
325
0
'''simple docstring''' from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = 10**-10 ): _UpperCAmelCase : List[str] ...
40
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
1
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, ren...
685
'''simple docstring''' import math def __UpperCAmelCase (lowercase__ ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, ...
685
1
'''simple docstring''' import inspect import unittest class _a ( unittest.TestCase ): '''simple docstring''' def UpperCamelCase_ ( self ): '''simple docstring''' t...
508
'''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_sentencepi...
508
1
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class SCREAMING_...
169
"""simple docstring""" import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowercase ...
169
1
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "vocab_file": "vocab.json", "merges_file": "merges.txt", } lowercase...
711
import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...test_config...
390
0
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_avai...
555
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> List[str]: '''simple docstring''' _enforce_args(UpperCamelCase_ , UpperCamelCase_ ) if n == 0: return 0 UpperCamelCase = float("""-inf""" ) for i in range(1 , n + 1 ): UpperCamelCase ...
537
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( lowerCAmelCase__ :float , lowerCAmelCase__ :float , lowerCAmelCase__ :float , ) -> tuple: '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 )...
197
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :str , lowerCAmelCase__ :int ) -> list: '''simple docstring''' lowercase = word.split() def justify(lowerCAmelCase__ :list , lowerCAmelCase__ :int , lowerCAmelCase__ ...
197
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = ["""image_processor""", """tokenizer"""] lowercase_ = """ViT...
59
'''simple docstring''' from __future__ import annotations def a_ ( __UpperCAmelCase ) -> list[int]: """simple docstring""" snake_case: Tuple =[True] * limit snake_case: Optional[int] =False snake_case: U...
350
0
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class SCREAMING_SNAKE_CASE ( snake_c...
62
import flax.linen as nn import jax import jax.numpy as jnp class SCREAMING_SNAKE_CASE ( nn.Module ): """simple docstring""" A_ = 42 A_ = jnp.floataa def __A ( self: Tuple ) -> Tuple: _A = nn.Conv( ...
62
1
'''simple docstring''' import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def a__ ( _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : int=False ) -> List[str]: """simple docstring""...
71
'''simple docstring''' import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient __lowerCamelCase : str = WebClient(token=os.environ["""CI_SLACK_BOT_TOKEN"""]) def ...
501
0
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCAmelCase = logging.getLogger(__name__) class __A ( a ): """simple d...
717
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __A ( a ): """simple docstring""" A_ = '' A_ ...
318
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, re...
680
"""simple docstring""" from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , ) -> list[float]: SCREAMING_S...
680
1
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassific...
713
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import C...
647
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 # sin...
568
import comet # From: unbabel-comet import torch import datasets lowercase : List[Any] = datasets.logging.get_logger(__name__) lowercase : List[str] = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
568
1
import math def lowercase__ ( __A: float ,__A: float ): '''simple docstring''' if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensity if angle < 0 or angle ...
501
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opt...
501
1
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets UpperCAmelCase_ : List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. Fo...
44
def __UpperCamelCase (lowerCAmelCase : list[int] ) -> int: if not numbers: return 0 if not isinstance(lowerCAmelCase, (list, tuple) ) or not all( isinstance(lowerCAmelCase, lowerCAmelCase ) for number in numbers ): raise ValueError('numbers m...
699
0
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , __lowercase) -> Tuple: __UpperCamelCase :List[Any] = TypeError( '''Matrices must be formed from a list of zero or more lists containing at ''' ...
720
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __lowercase = datasets.load_iris() __lowercase = np.array(data['''data''']) __lowercase = np.array(data['''target''']) __lowercase ...
452
0
from typing import Any def A ( snake_case__ : list , snake_case__ : list , snake_case__ : dict , snake_case__ : dict , snake_case__ : dict , ) -> list: '''simple docstring''' _validation( snake_case__ , snake_case__ , sna...
313
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 UpperCAmelCase__ : List[Any] = 4 UpperCAmelCase__ : Optional[Any] = ...
313
1
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class lowercase_ ( a__ ): __UpperCAmelCase ...
706
'''simple docstring''' def _UpperCamelCase ( __A ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(__A , __A ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def _...
223
0
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __A ( a ): """simple docstring""" def __init__( self , _lowerCamelCase , _lowerCamelCase )-> List[Any]: lowerc...
161
'''simple docstring''' from __future__ import annotations import csv import requests from bsa import BeautifulSoup def SCREAMING_SNAKE_CASE ( a_ : str = "" ): __a = url or 'https://www.imdb.com/chart/top/?ref_=nv_mv_250' __a = Beautiful...
539
0
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCAmelCase( unittest.TestCase ): """simple docstring""" def __a ( self ...
709
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __a : str = argparse.ArgumentParser() parser.add_argument('''--dump_path''', default=N...
298
0
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> List[str]: """simple docstring""" if height >= 1: move_tower(height - 1 , lowercase_ , lowercase_ , lowercase_ ) m...
87
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : ...
87
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_xlm_roberta''': [ ...
144
def _a ( lowerCamelCase__ ) -> int: lowerCamelCase_ : List[Any] = [] lowerCamelCase_ : int = set({'(', '[', '{'} ) lowerCamelCase_ : Optional[Any] = set({')', ']', '}'} ) lowerCamelCase_ : Dict = ...
144
1
"""simple docstring""" from collections.abc import Sequence def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ = False ) -> float: if not arr: return 0 a_ : Dict = 0 if allow_empty_subarrays else float("-inf" ) a_ : Dict = 0.0 for...
237
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokenization_ctrl...
237
1
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedD...
263
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : List[Any] = { '''vocab_file''': '''vocab.json''...
263
1
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..models.au...
468
"""simple docstring""" import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging A = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE ( lowerCamelC...
449
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( _a): lowerCamelCase__ : Optional[int] = "Speech2TextFeatureExtractor" lowerCamelCase__ : Any = "Speech2TextT...
645
"""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.0...
645
1
'''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, TruncationStrategy fr...
72
from math import sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number are in format o...
402
0
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( C...
706
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(fairseq.__vers...
688
0
"""simple docstring""" import unittest from transformers import LiltConfig, 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 ...tes...
76
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils impor...
336
0
import os import numpy import onnx def _snake_case (_snake_case : Optional[Any] , _snake_case : Optional[int]) -> Tuple: _lowercase =a.name _lowercase =b.name _lowercase ='' _lowercase ='' _lowercase =a =...
557
import os def _snake_case (_snake_case : Optional[Any]) -> int: _lowercase =len(grid[0]) _lowercase =len(_snake_case) _lowercase =0 _lowercase =0 _lowercase =0 # Check vertically, horizontally, diagonally at the same ti...
557
1
import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig if TYPE_CHECKING: from ... im...
45
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCAmelCase : Tuple = r""" [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig...
444
0
"""simple docstring""" import os def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_ = "input.txt" ): with open(os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE_ ), SCREAMING_SNAKE_CASE_ ) ) as input_file: SCREAMING_SNAKE_CASE = [ [int(SCREAMING_S...
704
"""simple docstring""" import os import sys import unittest snake_case = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get...
406
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[str] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pa...
628
from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase_ : """simple docstring""" def __init__( self ) -> List[str]: __UpperCamelCase = {} def __lowercase( self , _SCREAMING_SNAKE_CASE ) ->...
383
0
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE_ = loggi...
370
"""simple docstring""" import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transform...
370
1
"""simple docstring""" import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING __magic_name__ = logging...
129
"""simple docstring""" 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 ImageProcessingSav...
281
0
import os A__ : List[str] = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 1_00, 'D': 5_00, 'M': 10_00} def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = 0 lowercase__ = 0 while index < len(lowerCamelCase_ ) - 1: ...
708
class _UpperCAmelCase : """simple docstring""" def __init__( self : Optional[int], lowerCamelCase : Union[str, Any] ): '''simple docstring''' # we need a list not a string, so do something to change the type lowercase__ = arr.split('''...
671
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> str: '''simple docstring''' snake_case : Tuple = [0 for i in range(r + 1 )] # nc0 = 1 snake_case : Optional[int] = 1 for i in r...
638
'''simple docstring''' from __future__ import annotations import queue class snake_case__ : """simple docstring""" def __init__( self : int , UpperCamelCase__ : Optional[int] ) -> Dict: """simple docstring""" ...
638
1
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _A ( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__=1024 ): lowercase__ , lowercase__ = [], [] lowercas...
611
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_numpy, slow, ...
611
1
import os def UpperCamelCase_( ): """simple docstring""" _lowerCAmelCase :str = os.path.join(os.path.dirname(__magic_name__ ) , 'num.txt' ) with open(__magic_name__ ) as file_hand: return str(sum(int(__magic_name__ ...
687
from __future__ import annotations from collections.abc import MutableSequence class UpperCAmelCase_ : """simple docstring""" def __init__( self: List[Any] , _UpperCAmelCase: int , _UpperCAmelCase: MutableSequence[float] ): if len(_UpperCAmelCase ) != degree...
687
1
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase__ ( _A ): """simple docstring""" _UpperCamelCase : Any = 'EncodecFeatureExtractor' _UpperCamelCase : ...
717
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
185
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_clap': [ 'CLAP_PRETRAINED_MODEL_ARCHIVE_LIST', 'ClapAudioConfig', 'ClapConfig', 'ClapTextConfig', ], 'processing_clap': ['...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: if not is_torch_available(): ...
147
0
from __future__ import annotations from random import random from typing import Generic, TypeVar A__: Optional[int] = TypeVar('''KT''') A__: Dict = TypeVar('''VT''') class _a ( Generic[KT, VT]): """simple docstring""" def __init__( ...
221
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _a ( unittest.TestCase): """simple docstring""" def UpperCAmelCase_ ( self: Tuple ): '''simple docstring''' UpperCamelCase__: Unio...
221
1
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCAmelCase ( lowerCAmelCa...
577
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case: Dict = { "configuration_informer": [ "INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
577
1
def a__ ( snake_case , snake_case ): """simple docstring""" return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def a__ ( snake_case , snake_case=0 ): """simple docstring""" return sorted(snake_case , key=lambda snake_case ...
131
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def a__ ( snake_case , snake_case , snake_case , snake_case , snake_case ): """simple docstring""" # load base model __SCREAMING_SNAKE_CASE : str ...
131
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature f...
27
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase__ : Optional[int] = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [...
65
0
"""simple docstring""" import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class _lowerCame...
507
"""simple docstring""" import inspect import re 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 _A = """src/transformers""" # This is to ma...
507
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _a ( UpperCAmelCase__ ): """simple docstring""" def _UpperCAmelCase ( self , _UpperCAmelCase ) -> Dict: with open(_UpperC...
23
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.ut...
618
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffus...
700
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffus...
377
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """goog...
122
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py _a: int = """src/diffusers""" # Matches is_xxx_available() _a: Tuple = re.compile(r"""is\_([a-z_]*)_available\(...
162
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import ...
717
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutpu...
59
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageP...
24
def lowerCAmelCase_ (lowerCAmelCase__: Union[str, Any] , lowerCAmelCase__: Optional[int] ): """simple docstring""" UpperCAmelCase_: List[str] = 0 UpperCAmelCase_: Tuple = len(lowerCAmelCase__ ) - 1 while left <= right: # avoid d...
556
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENER...
710
"""simple docstring""" import numpy as np def _snake_case ( lowercase__ : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def _snake_case ( lowercase__ : np.ndarray ) -> np.ndarray...
256
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config ...
49
from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase : Union[str, Any] = logging.get_logger(__name__) lowercase : Optional[int] = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/bl...
327
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _lowercase = argparse.ArgumentParser( description=( "Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned" " Distillation" ) ...
526
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowercase = { "configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MobileViTConfig", "MobileViTOnnxC...
526
1
'''simple docstring''' import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_...
502
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeli...
502
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random...
640
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _UpperCamelCase ): """simple docstring""" lowercase_ : Any = False while is_sorted is False: # Until all the indices are traversed keep looping lowercase_ : List[str] = True for i in ran...
640
1
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def _snake_case ( ): """simple docstring""" print("""Making key files...""" ) make_key_f...
577
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate...
577
1
from typing import TYPE_CHECKING from ...utils import _LazyModule _A : str = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys _A : str = ...
189
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects imp...
189
1
import argparse import copy def _UpperCamelCase ( lowercase__ ): __SCREAMING_SNAKE_CASE : Tuple = {} with open(lowercase__ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __SCREAMING_SNAKE_CASE : Optional...
696
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( lowerCamelCase ): # A local function to see if a dot lands in the circle. def is_in_circle(lowerCamelCase , lowerCamelCase ) -> bool:...
21
0
"""simple docstring""" import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 100 * 2**20, 900 *...
702
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def UpperCamelCase ( _lowerCAmelCase : str , _lowerCAmelCase : str , _lowerCAmelCase : Optional[str] = None ...
173
0
"""simple docstring""" import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCH...
77
from __future__ import annotations import queue class _a : '''simple docstring''' def __init__( self , __UpperCAmelCase ): """simple docstring""" a__ : Union[str, Any] = data a__ : Tuple = None ...
191
0
lowerCamelCase_ = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from ....
161
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT MSN models ...
161
1
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" while b: UpperCAmelCase , UpperCAmelCase = b, a % b return a def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" r...
333
from abc import ABC, abstractmethod from argparse import ArgumentParser class __magic_name__ ( _a): @staticmethod @abstractmethod def _UpperCAmelCase ( __SCREAMING_SNAKE_CASE : ArgumentParser ): raise NotImplementedError() @abstractmethod def _UpperCAmelCase ( self ...
333
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ : int = logging.get_logger(__name__) lo...
156
'''simple docstring''' 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, ...
156
1
'''simple docstring''' from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def _UpperCamelCase ( UpperCamelCase__ ): if not is_accelerate_available(): return method UpperCAmelC...
407
'''simple docstring''' import re from filelock import FileLock try: import nltk __A =True except (ImportError, ModuleNotFoundError): __A =False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def _UpperCamelC...
407
1
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): # Initialise PyTor...
530
from math import factorial def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase = 100 ): return sum(int(__lowerCAmelCase ) for x in str(factorial(__lowerCAmelCase ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
530
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__ : Optional[Any] = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig']} try: ...
153
"""simple docstring""" import math def lowercase ( __UpperCamelCase = 100 ) -> int: __magic_name__ = sum(i * i for i in range(1 , n + 1 ) ) __magic_name__ = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squares if __name__ == "_...
490
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : List[Any] = { "configuration_deberta": ["DEBERTA_PR...
720
"""simple docstring""" import qiskit def SCREAMING_SNAKE_CASE ( snake_case, snake_case): __snake_case = qiskit.Aer.get_backend('''aer_simulator''') # Create a Quantum Circuit acting on the q register __snake_case = qiskit.QuantumCircuit(snake_cas...
93
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forwar...
32
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 __UpperCamelCase ( A__ ): __A : Dict ...
32
1
'''simple docstring''' import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _snake_case (__SCREAMING_SNAKE_CASE , unittest.TestCase): __A : Dict ...
323
'''simple docstring''' import csv import tweepy # Twitter API credentials _lowerCamelCase = """""" _lowerCamelCase = """""" _lowerCamelCase = """""" _lowerCamelCase = """""" def a__ ( _SCREAMING_SNAKE_CASE : str ) -> None: ""...
323
1
def a__ (__lowercase :int ) -> bool: if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True _A : Any = 4 _A : List[Any] = (1 << p) - 1 for _ in range(p - 2 ): _A : Optional[Any] ...
206
def a__ (__lowercase :str , __lowercase :str ) -> float: def get_matched_characters(__lowercase :str , __lowercase :str ) -> str: _A : Union[str, Any] = [] _A : Dict = min(len(_stra ) , len(_stra ) ) // 2 ...
206
1
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def _lowerCAmelCase ( s...
702
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ...
66
0
'''simple docstring''' import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Union[st...
421
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxConfig...
586
0
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_...
36
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def __magic_name__ ( lowercase ): if "cls_token" in name: SCREAMING_SNAKE_CASE_: Optional[int] ...
36
1
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
58
'''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
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: int ): """simple docstring""" if num < 0: return False _lowerCAmelCase = num _lowerCAmelCase = 0 while num > 0: _lowerCAmelCase = r...
491
"""simple docstring""" import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _snake_case = logging.get...
491
1
'''simple docstring''' from __future__ import annotations from math import pow, sqrt def snake_case_ ( __snake_case : float , __snake_case : float , __snake_case : float) -> dict[str, float]: if (resistance, reactance, impedance).count(0) != 1: raise V...
274
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCAmelCase_ ( ) -> Optional[Any]: '''simple docstring''' A_ = HfArgumentParser(_UpperCAmelCase ) A_ = parser.parse_args_into_dataclasses()[0] A...
188
0
class lowercase : def __init__( self , A_ ) -> List[str]: """simple docstring""" # we need a list not a string, so do something to change the type UpperCamelCase = arr.split(',' ) def __UpperCamelCase ( self ) -> int: """simple docstring"...
3
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_camembert impor...
3
1
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, ...
136
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before toke...
136
1
"""simple docstring""" import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGE...
509
"""simple docstring""" # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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 #...
509
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
115
"""simple docstring""" import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_c...
115
1
'''simple docstring''' import requests def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase ) -> None: '''simple docstring''' snake_case_ = {'''Content-Type''': '''application/json'''} snake_case_ = requests.post(SCREAMING_SNAKE_CASE_, json={'''text'''...
700
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from...
593
0
from __future__ import annotations def a_ ( lowerCAmelCase_ : list[float] ): if len(lowerCAmelCase_ ) < 2: raise ValueError('Monogons and Digons are not polygons in the Euclidean space' ) if any(i <= 0 for i in nums ): raise ValueError('All values must be g...
53
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] = { 'Salesforce/blip-vqa-base': 'https://huggingfa...
311
0
from queue import PriorityQueue from typing import Any import numpy as np def snake_case_ (__A : dict , __A : str , __A : set , __A : set , __A : dict , __A : dict , __A : PriorityQueue , __A : dict , __A : ...
218
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...
218
1