code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main...
357
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class a__ ( ...
357
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __snake_case : Union[str, Any] = ...
701
"""simple docstring""" from ..utils import DummyObject, requires_backends class A__ ( metaclass=__SCREAMING_SNAKE_CASE ): '''simple docstring''' SCREAMING_SNAKE_CASE = ['torch', 'scipy'] def __init__( self: Tuple , *_SCREAMING_SNAKE_C...
615
0
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, ...
118
"""simple docstring""" import os import jsonlines import numpy as np from tqdm import tqdm _lowercase = 2_048 _lowercase = 4_096 _lowercase = 42 _lowercase = os.environ.pop('''PROCESS_TRAIN''', '''false''') _lowercase = {'''null''': 0, '''short''...
118
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "https://huggingface.co/goo...
228
"""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 _A = logging.get_logger(__...
228
1
"""simple docstring""" # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union SCREAMING_SNAKE_CASE_ = re.compile(R'^(?P<major>\d+)' R'\.(?P<minor>\d+)' R'\.(?P<patch>\d+)$') @total_ordering @data...
34
"""simple docstring""" import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_C...
34
1
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar __lowerCamelCase : List[str] = TypeVar("T") class __magic_name__ ( Generic[T] ): def __init__( self : Union[str, Any] , UpperCamelCase_...
457
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 __magic_name__ ( A__, unittest.Test...
457
1
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def _UpperCAmelCase ( _lowerCamelCase : Optional[int] ) ...
384
'''simple docstring''' from collections.abc import Sequence def _UpperCAmelCase ( _lowerCamelCase : Sequence[float] , _lowerCamelCase : float ) -> float: return sum(c * (x**i) for i, c in enumerate(_lowerCamelCase ) ) def _UpperCAmelCase ( _lowerCamelCase : ...
384
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, ra...
298
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
298
1
'''simple docstring''' import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig a__ : int = { 'facebook/maskformer-swi...
51
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version UpperCAmelCase ...
84
0
'''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, ...
720
'''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.o...
61
0
'''simple docstring''' import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput de...
261
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_tens...
312
0
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transformers import...
718
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __snake_case ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE (...
15
0
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class _UpperCAmelCase : def __init__( self : Dict , lowercase_ : ...
123
"""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 BaseTransformersCLIComman...
673
0
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _a ( yaml.SafeLoader): """simple docstring""" def lowercase__ ( self : List[str] , __UpperCamelCase : Any )->List[Any]:...
95
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase ...
95
1
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCamelCase = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight', 'time_embedding.linear_1.weight'),...
269
UpperCamelCase = 8.3_144_598 def __lowerCamelCase ( __lowerCAmelCase : float , __lowerCAmelCase : float ) -> float: if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <= 0: r...
269
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, ...
396
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class _lowerCAmelCase ( nn.Module ): __lowerCAmelCase : int __lowerCAmelCase ...
396
1
def _lowerCAmelCase ( __lowerCAmelCase = 1000000 ) -> int: """simple docstring""" snake_case__ : str = set(range(3 , __lowerCAmelCase , 2 ) ) primes.add(2 ) for p in range(3 , __lowerCAmelCase , 2 ): if p not in primes: ...
252
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def _lowerCAmelCase ( lowercase , lowercase , lowercase , lowercase , lowercase ) -> Optional[int]: # load base model ...
689
0
class a__ ( __SCREAMING_SNAKE_CASE ): pass class a__ ( __SCREAMING_SNAKE_CASE ): pass class a__ : def __init__( self : int ) -> Tuple: """simple docstring""" lowerCamelCase_: Any = ...
713
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class a__ ( __SCREAMING_SNAKE_CASE ...
584
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase__ = ...
41
'''simple docstring''' import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to...
41
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A : Optional[int] =logging.get_logger(__name__) _A : Optional[int] ={ '''bert-base-uncased''': '''ht...
719
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _lowercase ...
4
0
import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() __a : Union[str, Any] = logging.get_logger(__name__) d...
637
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE ( snake_case ): '''simple docstring''' __UpperCamelCase = "M-CLIP" def __init__( self , SCREAMING_SNAKE_CASE__=...
329
0
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration a_ = 50_00_00 a_ , a_ = os.path.split(__file__) a_ = os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace("""...
708
"""simple docstring""" def UpperCAmelCase_ ( __a : Dict , __a : Optional[Any] ): '''simple docstring''' _lowerCamelCase : Any = '' for i in table: res += inp[i - 1] return res def UpperCAmelCase_ ( __a : List[Any]...
349
0
'''simple docstring''' def __UpperCamelCase ( a : list ) ->list: if len(a ) < 2: return collection def circle_sort_util(a : list , a : int , a : int ) -> bool: snake_case = False if low == high: return swapped...
342
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class _lowercase ( unittest.TestCase ...
342
1
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCAmelCase: Optional[int] = TypeVar('KEY') lowerCAmelCase: Tuple = TypeVar('VAL') @dataclass(frozen=lowerCamelCase__ , slots=lowerCamelCase...
717
'''simple docstring''' def lowerCamelCase__ ( _A = 6008_5147_5143 ): try: a : Optional[int] = int(_A ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater ...
195
0
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteSch...
343
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Flax...
343
1
'''simple docstring''' import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForCondit...
136
'''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 : int = get_tests_dir("""fixtures/test_sentencepiec...
136
1
def _UpperCAmelCase ( UpperCamelCase: Dict , UpperCamelCase: Tuple ): """simple docstring""" __lowerCAmelCase = [1] for i in range(2 , __UpperCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds" __lowerCAmelCase = ...
611
"""simple docstring""" def __lowerCamelCase ( __UpperCamelCase ) -> tuple[int, int]: """simple docstring""" try: lowerCAmelCase_ : Tuple = float(__UpperCamelCase ) except ValueError: raise ValueError("Please enter a valid number" ) lowerCAmelCa...
610
0
import os import pytest from transformers.dynamic_module_utils import get_imports UpperCAmelCase = ''' import os ''' UpperCAmelCase = ''' def foo(): import os return False ''' UpperCAmelCase = ''' def foo(): def bar(): if True: import os return Fals...
565
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): if "model" in orig_key: lowercase = orig_key.replace('model.' , '' ) if "norm1" in orig_key: lowercase = orig_key.repla...
565
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A__ : Any = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""",...
13
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 __lowerCAmelCase : Dict = logging.getLogger(__name__) ...
529
0
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ :Union[str, Any] = logging.get_logger(__name__) lowercase__ :Dict = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", "xlnet-large-c...
633
import argparse from collections import defaultdict import yaml lowercase__ :Optional[int] = "docs/source/en/_toctree.yml" def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = defaultdict(lowerCAmelCase__ ) for doc in model_doc: counts[...
633
1
'''simple docstring''' from math import sqrt def _lowerCAmelCase ( lowerCamelCase_ : Dict ): assert isinstance(__lowercase , __lowercase ) and ( number >= 0 ), "'number' must been an int and positive" __lowercase = True # 0 a...
502
"""simple docstring""" def _A ( __lowercase = 200_0000 ): """simple docstring""" lowerCamelCase__ = [0 for i in range(n + 1 )] lowerCamelCase__ = 1 lowerCamelCase__ = 1 for i in range(2 , int(n**0.5 ) ...
129
0
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_sqlalchemy def A_ ( A__ , A__ ) ...
392
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torc...
392
1
def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' _UpperCamelCase = int(a__ ) if decimal in (0, 1): # Exit cases for the recursion return str(a__ ) _UpperCamelCase = divmod(a__ , 2 ) return binary_recursive(a__ ) + str(a__ ) def lowerC...
547
def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number or not...''') __lowercase ...
167
0
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"): A_ = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL.Image.Resampling.BILINEAR...
704
'''simple docstring''' 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 imp...
465
0
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): ...
385
'''simple docstring''' import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import ...
158
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configura...
712
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "camembert-base": "https://huggingface.co/camembert-base/r...
390
0
from typing import TYPE_CHECKING from ...utils import _LazyModule __lowercase = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __lowercase ...
203
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
292
0
from __future__ import annotations def lowerCAmelCase ( lowerCAmelCase_ , lowerCAmelCase_ = None )-> list[list[str]]: lowerCAmelCase_ : Optional[Any] = word_bank or [] # create a table lowerCAmelCase_ : int = len(a_ ) + 1 lowerCAmelCase_ : list[list[list[s...
713
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 _UpperCAmelCase : Tuple =logging.get_logger(__name__) class snake_case__( UpperCAmelCase__ ): ...
619
0
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CASE :float = 1 / sqrt(2 ) ) -> IIRFilter: __lowe...
504
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _UpperCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class snake_case_ ( __lowercase...
504
1
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def _snake_case ( lowerCamelCase__ : Optional[in...
244
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase__ ...
244
1
'''simple docstring''' import fire from utils import calculate_rouge, save_json def A_ ( _lowerCAmelCase : List[str] , _lowerCAmelCase : int , _lowerCAmelCase : Dict=None , **_lowerCAmelCase : Any ): """simple docstring""" _low...
44
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRobert...
36
0
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureEx...
137
"""simple docstring""" import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) ...
137
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERende...
76
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __magic_name__ = { "text_branch": "text_model", "audio_branch": "audio_model.audio_encoder", "attn": "attention.self", "s...
232
0
"""simple docstring""" from functools import reduce __lowerCAmelCase : Optional[Any] = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511'''...
21
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : int ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) snake_case_ ...
21
1
"""simple docstring""" class UpperCamelCase__ : """simple docstring""" def __init__( self : Optional[Any] ): '''simple docstring''' __magic_name__ = 0 __magic_name__ = 0 __mag...
545
"""simple docstring""" def A ( __snake_case: int = 1_0_0_0_0_0_0 ) -> int: """simple docstring""" __magic_name__ = limit + 1 __magic_name__ = [0] * limit for first_term in range(1 , __snake_case ): ...
545
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils ...
48
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Dict , SCREAMING_SNAKE_CASE__ : Optional[int] ): """simple docstring""" ...
48
1
'''simple docstring''' import csv import tweepy # Twitter API credentials lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = """""" def _A ( _lowerCAmelCase ): """simple docstring""" ...
474
'''simple docstring''' from collections.abc import Sequence def _A ( _lowerCAmelCase = None ): """simple docstring""" if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) __lowercase =nums[0] for i ...
474
1
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _lowerCamelCase : Union[str, Any] = argparse.ArgumentParser( description=( '''Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM ...
157
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _lowerCamelCase : List[Any] = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu...
157
1
import argparse import collections import json import os import re import string import sys import numpy as np _snake_case : Union[str, Any] = re.compile(R'\b(a|an|the)\b', re.UNICODE) _snake_case : Dict = None def a_ ( ): __lowerCAmelCase = ...
53
from copy import deepcopy class snake_case__ : """simple docstring""" def __init__( self : Union[str, Any], _snake_case : list[int] | None = None, _snake_case : int | None = None ) ->None: if arr is None and size is not None: s...
478
0
'''simple docstring''' import fcntl import os import socket import torch import torch.distributed as dist def _lowerCamelCase( *UpperCamelCase__ : Dict ) -> List[Any]: with open(UpperCamelCase__ , '''r''' ) as fh: fcntl.flock(UpperCamelCase__ , ...
707
'''simple docstring''' # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def _lowerCamelCase( UpperCamelCase__ : List[Any] , UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : List[Any] ) -> List[Any]: A : Any = { ...
537
0
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from ...
324
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterMix...
324
1
"""simple docstring""" from math import ceil def lowercase_ ( _lowercase : Optional[Any] , _lowercase : List[Any] ): '''simple docstring''' UpperCAmelCase : Optional[int] = list(range(0 , snake_case_ ) ) ...
710
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configura...
292
0
'''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_pi...
69
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Tuple = { '''huggingface/autoformer-tourism-monthly''': '''https:...
69
1
import argparse from ...utils.dataclasses import ( ComputeEnvironment, DistributedType, DynamoBackend, PrecisionType, SageMakerDistributedType, ) from ..menu import BulletMenu _UpperCAmelCase = [ "EAGER", "AOT_EAGER", "INDUCTOR", "NVFUSER", "AOT_NVFUSER", "...
707
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowerCAmelCase_ ( UpperCamelCase_ ) -> Optional[int]: return x + 2 class _UpperCamelCase ( unittest.TestCase ): def lowercase (...
371
0
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow...
91
"""simple docstring""" import random class lowerCamelCase__ : '''simple docstring''' @staticmethod def UpperCamelCase__ ( lowerCamelCase_ ) -> tuple[list[int], list[int]]: A = [ord(lowerCamelCase_ ) for i in text] A = []...
617
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=_lowerCAmelCase ) class __UpperCamelCase ( _lowerCAmelCase ): # `task` is not a ClassVar since we want it to be part o...
714
from __future__ import annotations def snake_case ( lowerCamelCase ): '''simple docstring''' if not nums: return 0 __lowercase = nums[0] __lowercase = 0 for num in nums[1:]: __lowercase , __lowercase = ( max_excluding +...
53
0
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = {"""vocab_file""": """vocab.json"""} lowerCAmelCase ...
174
'''simple docstring''' lowerCAmelCase : List[str] = 2_5_6 # Modulus to hash a string lowerCAmelCase : Tuple = 1_0_0_0_0_0_3 def _A ( A ,A ) -> bool: lowercase : List[Any] = len(A ) lowercase : List[Any] = len(A ) ...
372
0
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to includ...
32
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Any = logging.get_logger(__name__) A_ : Optional[int] = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/ma...
32
1
from __future__ import annotations import unittest from transformers import LEDConfig, 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 ...test_pipeline_mixin im...
148
import argparse import struct import unittest class _lowerCAmelCase : def __init__( self , _UpperCamelCase ) -> None: lowerCAmelCase_ = data # Initialize hash values lowerCAmelCase_ = [ 0x6_A_0_9_E_6_6_7, 0xB...
290
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from tra...
127
def _lowercase ( UpperCAmelCase_): """simple docstring""" if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""") for cell_n in range(1 , len(grid[0])): grid[0][cell_n] += grid[0][cell_n - 1] snake_case__ : L...
127
1
"""simple docstring""" def _lowerCAmelCase ( lowerCamelCase__ : Tuple, lowerCamelCase__ : Tuple, lowerCamelCase__ : Union[str, Any] ) -> Dict: if exponent == 1: return base if exponent % 2 == 0: _SCREAMING_SNAKE_CASE : Dict = _modexpt(a__, ex...
572
'''simple docstring''' from math import isqrt def a__ ( a__ ): """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(a__ ) + 1 ) ) def a__ ( a__ = 10**6 ): """simple docstring""" __SCREAMING_SNAKE_CASE = 0 ...
627
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _UpperCAmelCase ( ...
302
"""simple docstring""" import requests lowerCamelCase_ : Any = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def UpperCAmelCase__ ( _UpperCAmelCase ): """simple docstring""" A_ : Any = requests.get(_NEWS_API + bbc_news_api_ke...
302
1
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
625
'''simple docstring''' import re from filelock import FileLock try: import nltk UpperCAmelCase__ = True except (ImportError, ModuleNotFoundError): UpperCAmelCase__ = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=Tru...
186
0
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np lowercase__ : Tuple = re.compile(r'''\b(a|an|the)\b''', re.UNICODE) lowercase__ : Optional[Any] = None def __lowercase ( ...
485
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
485
1
# using dfs for finding eulerian path traversal def snake_case (UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__=None ) -> Dict: UpperCamelCase_: str = (path or []) + [u] for v in graph[u]: if visited_e...
57
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __snake_case = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokenization_mvp""": ["""Mv...
472
0
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_...
702
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, T...
367
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import Paddin...
69
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def A ( snake_case__ ): '''simple docstring''' def decorator(snake_case__ ): SCREAMING_SNAKE_CASE__ = getattr(snake_case__ , """handle_key""" , ...
196
0
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 __lowerCamelCase ( enum.Enum ): """simple docstring""" snake_case__ = ...
125
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask UpperCamelCase = logging.getLogger(__name__) class __lowerCamelCase ( UpperCamelCase__ ): """simple...
125
1
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): fr...
340
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __snake_case =...
69
0
'''simple docstring''' import os from datetime import datetime as dt from github import Github UpperCamelCase__ = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', ...
719
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_comman...
312
0
'''simple docstring''' import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() snake_case : str = logging...
566
'''simple docstring''' from __future__ import annotations def A__ ( A_ ) -> list[int]: # This function is recursive _lowercase = len(A_ ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if array_length <= 1: ret...
497
0
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowerCAmelCase_ : Union[str, Any] = '2.13.1' import platform import pyarrow from packaging import version if version.parse(platform.p...
716
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( lowercase : str , lowercase : i...
521
0
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __snake_case ( UpperCAmelCase_ : str , UpperCAmelCase_ : str , UpperCAmelCase_ : Optional[str] = None ): if version.pa...
675
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home lowercase : Any = HUGGINGFACE_HUB_CACHE lowercase : Any = "config.json" lowercase : Any = "diffusion_pytorch_model.bin" lowercase : Optional[Any] = "diffusion_flax_...
327
0
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig UpperCAmelCase_ = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pytorch''': '''https://h...
519
from __future__ import annotations from collections.abc import Callable UpperCAmelCase_ = list[list[float | int]] def UpperCAmelCase ( A__ , A__ ) -> Matrix: _snake_case : int = len(A__ ) _snake_case : Matrix = [[0 for _ in ra...
519
1
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : Tuple ): # noqa: E741 '''simple docstring''' _lowerCAmelCase = len(_SCREAMING_SNAKE_CASE ) _lowerCAmelCase = 0 _lowerCAmelCase = [0] * n _lowerCAmelCase = [...
18
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_atte...
27
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerToke...
186
def _lowerCamelCase ( __A : int ) -> bool: if not isinstance(__A , __A ): _UpperCAmelCase : Tuple = f'''Input value of [number={number}] must be an integer''' raise TypeError(__A ) if number < 0: return False _UpperCAme...
186
1
lowercase__ : Union[str, Any] = "Alexander Joslin" import operator as op from .stack import Stack def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} s...
376
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__ ( _A , _A , _A ): '''simple docstr...
376
1
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, CharacterTokenizer, JumanppToke...
720
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor f...
671
0
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __lowercase ( ): """simple docstring""" with offline(OfflineSimulationMode.CONNECTION_T...
0
from typing import TYPE_CHECKING from ...utils import _LazyModule a : int = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys a : int = _...
556
0
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 VaeImageProcessor from diffusers.pipe...
706
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _snake_case : List[Any] = "\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n author={Wan...
203
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from...
36
"""simple docstring""" from __future__ import annotations from math import gcd def A_ ( snake_case_ : int ,snake_case_ : int = 2 ,snake_case_ : int = 1 ,snake_case_ : int = 3 ,): '''simple docstring''' # A value less than 2 can cause an infin...
499
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class SCRE...
717
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor,...
666
0
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin ...
617
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase ={ "configuration_informer": [ "INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "...
617
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def A ( __UpperCamelCase ) -> int: A__ = ...
52
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoToke...
52
1
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def snake_case_ ( lowercase__ , lowercase__ , lowercase__ ): if not arr: return None, None, 0 if low ...
199
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
199
1
a_ : Any = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '....
148
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.generation import ( FlaxForc...
148
1
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ...
110
import os def UpperCAmelCase ( ) -> Any: """simple docstring""" __A = os.path.dirname(os.path.realpath(a_ ) ) __A = os.path.join(a_ , "triangle.txt" ) with open(a_ ) as f: __A = f.readlines() __A = [] f...
55
0
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_avai...
25
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() __lowerCamelCase : int = logging.get_logger(__name__) __lowerCamelCase : int = { """post_extract_proj"...
25
1
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenizer ...
398
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : Tuple = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'f...
640
0
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ) -> tuple[int | None, int | None, float]: """sim...
706
from cva import destroyAllWindows, imread, imshow, waitKey def __lowerCamelCase ( snake_case__ ) -> str: """simple docstring""" _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = img.shape[0], img.shape[1] # converting each pixel's c...
569
0
# flake8: noqa # Lint as: python3 lowerCamelCase : Any = [ "VerificationMode", "Version", "disable_progress_bar", "enable_progress_bar", "is_progress_bar_enabled", "experimental", ] from .info_utils import VerificationMode from .logging import disabl...
70
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __UpperCAmelCase = ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def lowercase__ ( lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : str...
642
0
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 import PatchingSpec from ...t...
638
def __magic_name__( __UpperCAmelCase , __UpperCAmelCase ) -> str: '''simple docstring''' _lowerCamelCase = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def __magic_name__...
638
1
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowerCamelCase ( lowerCamelCase : List[str]): if "model" in orig_key: A_ : List[str] = orig_key.replace("""model.""" , """""") if "norm1" in ori...
665
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
665
1
"""simple docstring""" import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accelera...
366
"""simple docstring""" import math def lowercase_ ( _lowerCamelCase: 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: # Negatives, 0,...
366
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class __SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self , UpperCamelCase__ ): """simple docstring""" a_ = value a_ ...
536
'''simple docstring''' import math import qiskit def __UpperCamelCase ( lowercase_ : int = 1 , lowercase_ : int = 1 , lowercase_ : int = 1 ): """simple docstring""" if ( isinstance(lowercase_ , lowercase_ ) ...
536
1
'''simple docstring''' def a_ ( _A , _A ) -> str: """simple docstring""" if number < 0 or shift_amount < 0: raise ValueError('both inputs must be positive integers' ) snake_case__ = str(bin(_A ) ) binary_number +=...
716
from __future__ import annotations from collections.abc import Iterator from typing import Any class __SCREAMING_SNAKE_CASE: def __init__( self: int , UpperCamelCase: Any ) -> List[Any]: snake_case__ = data snake_case__ ...
372
0
"""simple docstring""" from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer UpperCAmelCase_ : int ...
255
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A_ ( __a ): _A :Optional[Any] = ['''image_processor''', '''tokenizer'''] _A :List[str] = '''ViTImageProcessor''' _A :Optional[Any] = ('''C...
428
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', 'PoolFormerOnnxConfig', ...
701
import numpy as np def SCREAMING_SNAKE_CASE__ ( lowercase ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
684
0
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" if index == r: for j in range(_lowerCAmelCase ): print(data[j] , end=" " ) ...
333
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel @r...
333
1
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data...
248
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = len(UpperCamelCase_ ) for i in range(UpperCamelCase_ ): for j in range(i + 1 , UpperCamelCase_ ): if numbers[j] < numbers[i]: __SCREAMING_SNAKE_CASE ...
248
1