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''' SCREAMING_SNAKE_CASE_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ ): # Make sure the supplied data is a bytes-like object if not isinstance(SCREAMING_SNAKE_CASE__ ...
597
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils i...
597
1
"""simple docstring""" import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenizat...
213
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { 'facebook/dpr-ctx_encoder-single-nq-base': ( 'https://huggingface.co/facebook/dpr...
213
1
'''simple docstring''' UpperCamelCase__ : Dict = 65_521 def __UpperCamelCase( _A : str ): '''simple docstring''' UpperCAmelCase__ : List[Any] = 1 UpperCAmelCase__ : Tuple = 0 for plain_chr in plain_text: UpperCAmelCase__ : str = ...
614
'''simple docstring''' import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging...
614
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case__ ( UpperCamelCase): a_ = ["image_processor", "tokenizer"] a_ = "CLIPImageProcessor" a_ = ...
713
'''simple docstring''' def __UpperCAmelCase ( A : List[str] , A : Tuple , A : Union[str, Any]=False ) -> Tuple: if isinstance(A , A ) and isinstance(A , A ): UpperCAmelCase_ : Any = len(set_a.intersection(A ) ) if alternative...
216
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Optional[Any] = logging.get_logger(__name__) A_ : Optional[int] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert ...
196
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowercase_ : Any = { '''linear''': PIL.Image.Resampling.BILINEAR, ...
588
0
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin ...
98
'''simple docstring''' def _snake_case ( A ) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def _snake_case ( A ) -> bool: lowerCAmelCase__ = 0 lowerCAmelCase__ = number while duplicate > 0: ...
98
1
"""simple docstring""" import math def SCREAMING_SNAKE_CASE__ ( ) -> None: lowercase__: Union[str, Any] = input('''Enter message: ''' ) lowercase__: List[Any] = int(input(F"""Enter key [2-{len(__A ) - 1}]: """ ) ) lowercase__: int = input('''Encryption/Decryption [e...
586
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_av...
94
0
from __future__ import annotations def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> dict[str, float]: if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: ...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
class _UpperCAmelCase : """simple docstring""" def __init__( self : List[str] , lowerCAmelCase_ : int ) -> None: __lowerCAmelCase = size __lowerCAmelCase = [0] * size __lowerCAmelCase = [0] * size ...
53
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def a_ ( lowerCAmelCase_ : Optional[Any], lowerCAmelCase_ : List[Any], lowerCAmelCase_ : str ...
53
1
"""simple docstring""" import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase_ (a__ , unittest.TestCase ): """simpl...
545
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowercase_ ( _snake_case ,_snake_case=7 ): SCREAMING_SNAKE_CASE__ : Dict = None if token is not None: SC...
545
1
"""simple docstring""" import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyaz...
690
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is...
690
1
"""simple docstring""" from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class __UpperCAmelCase( SCREAMING_SNAK...
703
"""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, DISTI...
85
0
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE ...
94
def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ ): lowerCamelCase_ : Union[str, Any] = [] lowerCamelCase_ : Tuple = [] lowerCamelCase_ : Dict = { '^': 3, '*': 2, '/': 2, '%': 2, '+': 1, '-': 1, } # Pr...
364
0
'''simple docstring''' from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, r...
465
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets A_ = datasets.logging.get_logger(__name__) A_ = "\\n@InProceedings{moosavi...
465
1
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( _UpperCAmelCase : list[int] , _UpperCAmelCase : int ) -> int: """simple docstring""" if len(_UpperCAmelCase ) < k or k < 0: raise ValueError("Invali...
244
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging __SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) class lowerCamelCase_ (sna...
244
1
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def snake_case_ ( _lowerCAmelCase : str , _lowerCAmelCase : str = "cpu" , _lowerCAmelCase : Union[str, None] = None ) -> None: UpperCAm...
528
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sq...
528
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, re...
100
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
1
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, DistilBertForMa...
129
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 __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = "▁" __...
129
1
"""simple docstring""" 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_backbon...
227
'''simple docstring''' import random from typing import Any def __A ( a_ : list ): for _ in range(len(a_ ) ): lowerCAmelCase : List[Any] = random.randint(0 ,len(a_ ) - 1 ) lowerCAmelCase : Tuple = random.randint(0 ,len...
525
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wav...
721
import pytest import datasets # Import fixture modules as plugins _lowerCamelCase = ['tests.fixtures.files', 'tests.fixtures.hub', 'tests.fixtures.fsspec'] def __UpperCAmelCase( lowercase_ , lowercase_ ): # Mark tests as "unit" by default if not marked as "integration" ...
613
0
'''simple docstring''' from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE (a__ ): pass class SCREAMING_SNAKE_CASE : def __init__( self , _UpperCAmelCase): '''simple docstring''' ...
8
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Tuple = logging.get_logger(__name__) _a : Optional[int] = { 'xlm-mlm-en-204...
213
0
from math import factorial def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> float: if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or successes < 0: raise ValueE...
69
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_remb...
69
1
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger UpperCAmelCase = get_logger(__name__) class A_ ( enum.Enum ): '''simple docstring''' _UpperCamelCase : Tuple = """all_checks""" _UpperCamelC...
84
'''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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDi...
489
0
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWi...
659
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _snake_case = { "configuration_blenderbot":...
659
1
'''simple docstring''' from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_V...
229
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class UpperCAmelCase__ ( lowercase__ ): """simple docstring""" def __init__( self : s...
229
1
'''simple docstring''' import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pi...
707
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase = logging.g...
666
0
"""simple docstring""" from __future__ import annotations def lowercase (snake_case__ : str ) -> List[str]: '''simple docstring''' if not nums: return 0 lowerCAmelCase = nums[0] lowerCAmelCase = 0 for num in nums[1:]: lowerCAm...
169
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def _snake_case (__lowercase , __lowercase , __lowercase): # Initialise PyTorch model Upp...
23
0
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_...
721
class lowerCAmelCase : def __init__( self : Union[str, Any] , UpperCAmelCase : list ) -> None: lowerCamelCase__ : int = set_counts lowerCamelCase__ : List[str] = max(UpperCAmelCase ) lowerCamelCase__ : Dict = len(...
188
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class snake_case__(unittest.TestCase ): """simple d...
496
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def __snake_case ( _UpperCamelCase ) -> Optional[Any]: _a = [ '''encoder.version''', '''decoder.version''', '''model.encoder.version''', ...
487
0
"""simple docstring""" import qiskit def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> qiskit.result.counts.Counts: lowerCAmelCase__ : List[str] = qiskit.Aer.get_backend("""aer_simulator""" ) lowerCAmelCase__ : List[str] = qiskit.Qu...
507
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
507
1
"""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(): fr...
77
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase , UpperCamelCase ) -> int: """simple docstring""" __UpperCAmelCase : Dict = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): __UpperCAmelC...
77
1
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel _lowerCAmelCase ...
348
"""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_pipeline...
348
1
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. _lowerCAmelCase = 10 def _lowerCAmelCase ( _lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ): '...
569
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokeniz...
567
0
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers lowerCamelCase : Dict = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def A__ ( ): '''simple docstring''' _SCREAMING_SNAKE_CASE = os.path.dirn...
701
"""simple docstring""" def A__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' if exponent == 1: return base if exponent % 2 == 0: _SCREAMING_SNAKE_CASE = _modexpt(UpperCamelCase__ , ...
168
0
"""simple docstring""" import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=5 ) -> List[str]: # Adapted from https://github.com/pytorch/fair...
103
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
511
0
from __future__ import annotations def lowercase_ (A : list , A : int | None = None , A : int | None = None ): if start is None: snake_case__ : str = 0 if end is None: snake_case__ : List[str] = len(A ...
243
# 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 ...
243
1
'''simple docstring''' import math import tensorflow as tf from packaging import version def __A ( lowerCAmelCase_ ): _UpperCAmelCase : Any = tf.convert_to_tensor(lowerCamelCase_ ) _UpperCAmelCase : Any = 0.5 * (1.0 + tf.math.erf(x / tf....
414
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version fr...
47
0
"""simple docstring""" from sklearn.metrics import fa_score import datasets lowerCamelCase__ : List[Any] = "\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" lowerCamelCase__ : ...
18
"""simple docstring""" import math class lowercase__: '''simple docstring''' def __init__( self :Union[str, Any] , lowerCamelCase_ :List[str]=0 ) -> List[Any]: # a graph with Node 0,1,...,N-1 '''simple docstring''' SCREAMING_SNAKE_CASE : Tuple = n...
18
1
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 _SCREAMING_SNAKE_CASE ( __a ): a_ : str ...
132
"""simple docstring""" from ...processing_utils import ProcessorMixin class _UpperCAmelCase ( __a): __a : Optional[Any] = """SpeechT5FeatureExtractor""" __a : Dict = """SpeechT5Tokenizer""" def __init__( self , _A , ...
238
0
'''simple docstring''' 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, DistilBertFor...
461
'''simple docstring''' import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __a ( __lowerCamelCase : List[Any] ) -> Tuple: '''simple docstring''' ...
461
1
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_d...
54
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 __lowercase : List[Any] =WebClient(token=os.environ["""CI_SLACK_BOT_TOKEN"""]) def a__ ( ...
54
1
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowercase_ ( a__ ): __UpperCAmelCase = 'Speech2TextFeatureExtractor' __UpperCAmelCase = 'Speech2TextTokenizer' def __init__( self...
223
'''simple docstring''' import os def _UpperCamelCase ( ) -> Optional[int]: '''simple docstring''' with open(os.path.dirname(__A ) + "/p022_names.txt" ) as file: UpperCamelCase__ = str(file.readlines()[0] ) UpperCamelCase__ ...
223
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor __A = logging.get_logger(__name__) class snake_case ( __snake_case ): def __init__( self : str , *UpperCamelCase__ :...
346
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels __A = object() # For specifying empty leaf dict `{}` __A = object() def ...
346
1
import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def __lowerCamelCase ( ) -> None: print("Making key files..." ) make_key_files("rsa" , 1_024 ) print("Key files generation successful....
594
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class _a : """simple docstring""" __SCREAMING_SNAKE_CASE = None def __lowerCAmelCase ( self ): _lowercase =self.feature_extraction_class(**self.feat_extract_dic...
594
1
"""simple docstring""" from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand __UpperCamelCase : Any = logging.get_logger(__name__) # pylint: disable=inva...
4
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class UpperCAmelCase_ : """simple docstring""" def __init__( self : Tuple , snake_...
374
0
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig 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_configuration_common i...
572
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( snake_case_ ): if n_term == "": return [] _lowercase = [] for temp in range(int(snake_case_ ) ): series.append(F"""1/{temp + 1}""" if series else """1""" ) return series if __name__ == "__main__": _lowerCamelCase = in...
572
1
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class lowercase__ : __UpperCAmelCase = 42 __UpperCAmelCase = None __UpperCAmelCase = None def _snake_case ...
88
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black SCREAMING_SNAKE_CASE : List[str] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) i...
294
0
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase = 10 , _lowerCamelCase = 22 ) -> int: '''simple docstring''' _lowerCamelCase : Tuple = range(1 , _lowerCamelCase ) _lowerCamelCase : Tuple = range(1 , _lowerCamelCase )...
386
"""simple docstring""" import argparse import json from tqdm import tqdm def lowerCamelCase_( ) -> Any: '''simple docstring''' _lowerCamelCase : Dict = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=_l...
386
1
'''simple docstring''' class __A : """simple docstring""" def __init__( self )-> int: lowercase__ = {} def snake_case_( self )-> None: print(self.vertex ) for i in self.vertex: print...
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
from torch import nn def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f"""Unsupported activation func...
716
# 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 snake_case = TypeVar("T") class __A ( Generic[T] ): '''simple docstring''' def __init__( ...
587
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Union[str, Any] = { "config...
564
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformer...
564
1
def A ( a_ ,a_ ) -> int: __UpperCamelCase : Optional[Any] =0 __UpperCamelCase : str =len(a_ ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: ...
721
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def A ( a_ = "" ) -> dict[str, float]: __UpperCamelCase : Tuple =url or 'https://www.imdb.com/chart/top/?ref_=nv_mv_250' __UpperCamelCase : Optional[int...
154
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchF...
196
"""simple docstring""" import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, ...
196
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class _lowerCAmelCase ( Upp...
712
'''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_dynamic...
411
0
"""simple docstring""" from __future__ import annotations import requests def UpperCAmelCase__ ( lowerCAmelCase__ :str ) -> dict: '''simple docstring''' lowercase = f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' ...
359
"""simple docstring""" from math import pow, sqrt def UpperCAmelCase__ ( *lowerCAmelCase__ :float ) -> bool: '''simple docstring''' lowercase = len(lowerCAmelCase__ ) > 0 and all(value > 0.0 for value in values ) return result ...
359
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __magic_name__( __UpperCAmelCase ) -> Any: '''simple docstring''' monkeypatch.setattr('''datasets.utils.deprecation_utils._emitted_deprecation_warnings''' , set() ) @pytest....
709
def __magic_name__( __UpperCAmelCase , __UpperCAmelCase ) -> bool: '''simple docstring''' _lowerCamelCase = len(__UpperCAmelCase ) _lowerCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of z...
638
0
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu...
18
'''simple docstring''' import re import string import numpy as np import datasets _SCREAMING_SNAKE_CASE = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" _SCREAMING_SNAKE_CASE = ...
18
1
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClass...
713
import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from accelerat...
242
0
"""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 UpperCamelCase = False ...
104
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowercase_ (SCREAMING_SNAKE_CASE__ ): lowerCAmelCase__ =(KDPMaDiscreteScheduler,) lowerCAmelCase__ =10 ...
360
0
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_v...
185
def UpperCamelCase_( _A :str )-> int: UpperCamelCase__ = hex_num.strip() if not hex_num: raise ValueError("No value was passed to the function" ) UpperCamelCase__ = hex_num[0] == "-" if is_negative: UpperCamelCase__ = hex_num[1:] try: Up...
185
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, norm...
633
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tens...
322
0
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : Any = "isbn/0140328726" ): UpperCamelCase_ : Optional[int] = olid.strip().strip("""/""" ) # Remove leading/trailing...
712
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 import night...
138
0
from __future__ import annotations def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> int | float: if len(_SCREAMING_SNAKE_CASE ) == 0: raise ValueError('find_max() arg is an empty sequence' ) if ( ...
235
import requests lowercase_ = """YOUR API KEY""" def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = giphy_api_key ) -> list: lowercase__ = '+'.join(query.split() ) lowercase__ = F"""https://api.giphy.co...
235
1
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( '''The `image_to_image.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionImg2ImgPipeline` instead.''' )
157
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : Union[str, Any] = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', ...
157
1
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generatio...
458
from string import ascii_uppercase UpperCAmelCase_ = {char: i for i, char in enumerate(ascii_uppercase)} UpperCAmelCase_ = dict(enumerate(ascii_uppercase)) def __magic_name__ ( lowercase , lowercase ) -> str: """simple docstring""" ...
458
1
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 __magic_name__ ( __lowerCAmelCase): ...
712
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # see ...
106
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( ...
42
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) _UpperCAmelCase = pytest.mark.integration @pytest.mark.parametrize('path' ,['...
558
0
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...tes...
509
"""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....
509
1
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.n...
455
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter SCREAMING_SNAKE_CASE = True exce...
579
0
'''simple docstring''' from __future__ import annotations def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> dict[str, float]: if (voltage, current, resistance).count(0 ) != 1: raise ValueError('One and only one argument must be 0' ) ...
384
'''simple docstring''' import argparse import os 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_task_guides.py A_ = "src/transformers" A_ = "docs/source/en/tasks" ...
384
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A : Tuple = { '''asapp/sew-d-tiny-100k''': '''h...
231
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : str = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer/r...
231
1
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCAmelCase_ ( __lowercase ): UpperCAmelCase = (...
71
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCAmelCase_ ( __lowercase ): UpperCAmelCase = (...
71
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ : List[str] = { '''configuration_luke''': ['''LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LukeConfig'''], '''tokenization...
673
"""simple docstring""" import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow lowerCAmelCase_ : List[str] = False class UpperCamelCase_ ( ...
673
1
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase ( ...
320
'''simple docstring''' UpperCamelCase_ = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} UpperCamelCase_ = ['''a''', '''b''', '''c''', '''d''', '''e'''] def lowerCamelCase ( UpperCAmelCase__ : Optional[Any] , UpperCAmelCase__...
320
1
from itertools import count def a__ ( A_ = 50 ): '''simple docstring''' __magic_name__ = [1] * min_block_length for n in count(lowercase__ ): fill_count_functions.append(1 ) for block_length in range(lowercase__, n + 1 ): for block_start ...
529
import os import sys import unittest lowerCAmelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_mapping, ...
230
0
"""simple docstring""" from __future__ import annotations import os from typing import Any import requests __lowerCAmelCase : Union[str, Any] = "https://api.github.com" # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user __lowerCAmelCase ...
674
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin...
674
1
'''simple docstring''' import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test...
546
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, p...
52
0
'''simple docstring''' import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _A = get_tests_dir("""fixtures/test_sentencepiece_with...
716
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _A: str = logging.get_logger(__name__) _A: Optional[Any] = { """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/huggi...
617
0
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): ...
28
import os import sys import unittest __a: Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_bac...
108
0
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 from diffusers...
715
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, ca...
33
0
"""simple docstring""" from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import t...
46
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer snake_case_ : Optional[int] = l...
138
0
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulator, ...
408
from torch import nn class _lowerCAmelCase ( nn.Module ): """simple docstring""" def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: """simple docstring""" super().__init__() snake_case__ ...
408
1
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_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_mod...
101
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_objec...
151
0
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, ...
718
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable(...
693
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __lowerCamelCase : str = """ @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, authors={...
297
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switch...
191
0
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class a_ : UpperCamelCase_ : int UpperCamelCase_ : Node | None = None UpperCamelCase_ : No...
674
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __lowerCAmelCase :...
674
1
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def a ( __snake_case : Any, __snake_case : ...
608
"""simple docstring""" import os import sys import unittest __lowerCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_d...
608
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class SCREAMING_SNAKE_CAS...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
1
'''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/LIC...
692
from copy import deepcopy class __A : def __init__(self , __magic_name__ = None , __magic_name__ = None ): if arr is None and size is not None: lowerCamelCase__ : int = size lowerCamelCase__ : Union[str, Any] = [0] * size ...
157
0
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __A = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attent...
560
"""simple docstring""" import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTeste...
560
1
'''simple docstring''' 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, Di...
525
'''simple docstring''' from __future__ import annotations lowerCAmelCase = [] def __A ( a_ : list[list[int]] ,a_ : int ,a_ : int ): for i in range(len(a_ ) ): if board[row][i] == 1: return False for i in range(len(a_ ) ): if bo...
525
1
def __SCREAMING_SNAKE_CASE ( lowercase_ = 1000000 ) -> int: '''simple docstring''' __UpperCAmelCase : List[Any] = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in r...
717
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/conf...
675
0
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def _UpperCamelCase ( snake_case__ ) -> Dict: __UpperCAmelCase : List[Any] = FileLock(str(tmpdir / "foo.lock" ) ) __UpperCAmelCase : List[str] = FileLoc...
382
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 _snake_case = logging.get_logger(__na...
382
1
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import logging lo...
711
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Acceler...
1
0
'''simple docstring''' from math import factorial def lowerCamelCase (_SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or success...
476
'''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 if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TF...
476
1
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
403
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowerCamelCase_ ( unittest.TestCase ): def __magic_name__ ( self ): a_ = 10 def __...
403
1
'''simple docstring''' from __future__ import annotations A : Dict = [] def _a ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): for i in range(len(snake_case__ ) ): if board[row][i] == 1: return False for i in range(len(snake_case__ ...
349
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class A( lowerCamelCase__ ): """simple docstring""" def __in...
355
0
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.util...
701
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def _a ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case : List[Any] = 0 if start < end: ...
47
0
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...tes...
81
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTe...
33
0
'''simple docstring''' import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoT...
305
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedCon...
305
1