code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import re def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = split_input(str_ ) return "".jo...
43
import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import rep...
43
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _A = { '''configuration_convbert''': ['''CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ConvBertConfig''', '''C...
706
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { '''andreasmadsen/efficient_mlm_m0.40''': ( '''https://hug...
325
0
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: List[Any] ): SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = set({"""(""", """[""", """{"""} ) SCREAMING_SNAKE_CASE__ = set({""")""", """]""", """}"""} ) SCREAMING_SNAKE_CASE__ = {"""{""": ...
6
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: lowerCAmelCase_ = None try: import msvcrt except ImportError: lowerCAmelCase_ = None try: import fcntl except ImportError: lowerCAmelCase_ = None # ...
173
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. UpperCAmelCase_ : Optional[int] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best ...
704
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : Tuple ...
424
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Dict = logging.get_logger(__name__) lowercase : Union[str, Any] = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main...
649
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose,...
649
1
"""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, fsspec_head, ft...
715
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files" , [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "dataset_in...
579
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils im...
32
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import...
63
0
'''simple docstring''' import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import Tokeni...
599
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { "configuration_convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE...
599
1
'''simple docstring''' def a_ ( _UpperCAmelCase : float ,_UpperCAmelCase : float ) -> float: if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bu...
286
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.k...
286
1
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class UpperCAmelCase_ : def __init__( self : Tuple , _lowercase : Optional[int]=2 , _lowercase : Dict=3 , _lowercase : Optional[Any]=6_4 , _low...
704
"""simple docstring""" 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 GradientAccumulat...
227
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config...
573
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig lowercase = logging.getLogger(__name__) class lowercase__ ( A ): '''simple docstring''' _UpperCAmelCase = '''maske...
573
1
'''simple docstring''' from __future__ import annotations import queue class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Tuple ) ->Dict: '''simple docstring''' _UpperCAmelCase : str = data ...
40
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
1
import math class SCREAMING_SNAKE_CASE : def SCREAMING_SNAKE_CASE_ ( self : Optional[Any] , a : list[list[float]] , a : list[int] )-> int: """simple docstring""" lowercase__ = 0.0 low...
235
"""simple docstring""" def _lowercase ( __snake_case ,__snake_case ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def _lowercase ( ) -> None: assert or_gate(0 ,0 ) == 0 assert or_gate(0 ,1 ) == 1 assert or...
293
0
"""simple docstring""" def a_ ( lowerCamelCase ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
'''simple docstring''' import cva import numpy as np class UpperCAmelCase_ : """simple docstring""" def __init__( self , lowerCamelCase , lowerCamelCase ) -> Optional[Any]: '''simple docstring''' if k in (0.04, 0.06): UpperCamelCase : Optional[in...
173
'''simple docstring''' import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
173
1
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCamelCase ( a__ ): lowercase = "SpeechT5FeatureExtractor" lowercase = "SpeechT5Tokenizer" def __init__( self ,__UpperCamelCase ,__UpperCamelCase ) -> Optional[Any]: ...
710
"""simple docstring""" __SCREAMING_SNAKE_CASE ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def lowercase__( __SCREAMING_SNAKE_CASE : bytes ): # Make sure the supplied data is a bytes-like object if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNA...
477
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> bool: '''simple docstring''' snake_case : Optional[int] = len(SCREAMING_SNAKE_CASE__ ) snake_case : Any = [[False] * (required_sum + ...
638
'''simple docstring''' import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger lowercase__ = get_logger(__name__) class snake_case__ ( enum.Enum ): """simple docstring...
638
1
_lowerCAmelCase = 9.8_0665 def a__ ( a , a , a = g ) -> float: if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) if volume < 0: raise ValueError('''Impossible Object volume''' ) if gravity...
236
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class __UpperCAmelCase( A__ ): """simple docstring""" def __init__( self ...
236
1
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_verb...
221
import math from datetime import datetime, timedelta def _UpperCAmelCase (UpperCamelCase_ : int ): '''simple docstring''' _lowerCAmelCase : Optional[Any] = year % 19 _lowerCAmelCase : Tuple = year % 4 _lowerCAmelCase : Dict ...
429
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } class ...
327
"""simple docstring""" from math import sqrt def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> int: SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(SCREAMING_SNAKE_CASE_ ) + 1 ) ): if n % i == 0 and i != sqrt(SCR...
327
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
597
'''simple docstring''' import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, B...
597
1
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int ) -> int: '''simple docstring''' assert ( isinstance(UpperCAmelCase_ , UpperCAmelCase_ ) and number_of_steps > 0 ), F"number_of_steps needs to be positive inte...
192
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common...
192
1
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import write_bas...
488
def __a ( __UpperCAmelCase : int = 100 ) -> int: """simple docstring""" lowerCamelCase_ : Any = set() lowerCamelCase_ : int = 0 lowerCamelCase_ : Tuple = n + 1 # maximum limit for a in rang...
488
1
"""simple docstring""" 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.''' ) ...
494
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class lowerCAmelCase : def __init__( self ): _UpperCAmelCase = {} def __A ( self , a__ , a__ , a__=1 ...
494
1
import math def A_ ( a , a ): """simple docstring""" return math.pow(a , 2 ) - a def A_ ( a ): """simple docstring""" return 2 * x def A_ ( a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = 2.0 while start ...
511
'''simple docstring''' import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, ...
111
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from .....
363
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { 'huggingface/time-series-transformer-tourism-m...
363
1
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble,...
183
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( A__ ): """simple docstring""" lowercase__ = (IPNDMScheduler,) lowercase__ = (("""num_inference_steps""", 50),) d...
183
1
'''simple docstring''' 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, EulerAncestralDiscreteSched...
27
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, ...
27
1
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 ...test_...
55
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __snake_case : List[Any] = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block...
660
0
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT...
611
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_...
611
1
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaV...
334
"""simple docstring""" from __future__ import annotations import requests def lowercase ( lowerCAmelCase__ : str ) -> dict: __a = f'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty''' return requests.get(lowerCAmelCase__ ).json() def...
695
0
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMix...
703
"""simple docstring""" import argparse import os import re import packaging.version __UpperCAmelCase = 'examples/' __UpperCAmelCase = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version...
194
0
"""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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_fe...
34
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def __snake_case ( _lowercase ,_lowercase ,_lowercase ): """simple docstring""" UpperCamelCase = 0 if start < end: UpperCamelCase ...
34
1
"""simple docstring""" from __future__ import annotations def A__ ( UpperCamelCase__ ): # This function is recursive '''simple docstring''' _SCREAMING_SNAKE_CASE = len(UpperCamelCase__ ) # If the array contains only one element, we return it (...
168
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class __snake_case( __A ): def __lt__( self , A_ ): '''simp...
168
1
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva A_ = "" A_ = "" A_ = "" A_ = 1 # (0 is vertical, 1 is horizontal) def _UpperCamelCase ( ) -> None: lowerCamelCase_ ,lowerCamelCase_ = get_dataset(__UpperCamelCase...
42
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_camembert imp...
332
0
"""simple docstring""" 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 RoFor...
713
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin UpperCamelCase_ : int = ''' Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a ...
482
0
"""simple docstring""" 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...
83
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, ...
638
0
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, requir...
707
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, r...
438
0
"""simple docstring""" import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configurat...
153
def lowerCamelCase__ ( snake_case_ : int = 1000 ) -> int: __snake_case = 2**power __snake_case = str(snake_case_ ) __snake_case = list(snake_case_ ) __snake_case = 0 for i in list_num: sum_of_num += int(snake_case_ ) ...
592
0
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipel...
491
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline _snake_case = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False) parse...
491
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment, ...
221
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_timm, ...
221
1
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { ...
635
"""simple docstring""" from __future__ import annotations def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , )-> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("""You cannot supply more o...
635
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
367
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 accelerate.test_util...
6
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType UpperCamelCase__ = ...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_ava...
634
0
'''simple docstring''' def UpperCamelCase_ ( A__ ): # 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 a_ = gray_code_sequence_string(A__ ) # # convert th...
263
'''simple docstring''' # 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...
263
1
"""simple docstring""" from collections.abc import Callable def _lowercase ( _SCREAMING_SNAKE_CASE : Tuple , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : Optional[Any] ) -> str: '''simpl...
710
"""simple docstring""" from __future__ import annotations lowerCamelCase : str =[ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _lowercase ( _SCREAMING_SNAKE_CASE : list[list[int]] , _SCREAMING_SNAKE_CASE...
237
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
84
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
46
0
import qiskit def snake_case_ ( __lowercase = 2 ): UpperCAmelCase_ : Union[str, Any] = qubits # Using Aer's simulator UpperCAmelCase_ : Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) # Creating a Quantum Circuit acting on the q r...
641
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 from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( ...
641
1
def UpperCamelCase_( _A :str )-> bool: UpperCamelCase__ = 0 for ch in input_str: UpperCamelCase__ = ord(_A ) UpperCamelCase__ = pow(2 , _A ) # If we already turned on bit for current character's unicode if bitmap >> ch_unicode & 1 ==...
551
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": __UpperCamelCase = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str,...
551
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : Optional[Any] = { '''ks...
290
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowerCamelCase : Tuple = '''\ @misc{wu2016googles, title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author=...
290
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepie...
6
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase = logging.getLogger(__name__) if __name__ == "__main__": _lowerCamelC...
6
1
"""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 UpperCAmelCa...
109
"""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 A = logging.get_logger(__name__) def lowerCAmelCase__ ( lowerCamelCase__=None , lowerCamelCase__=No...
109
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) ...
58
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_avai...
566
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Any = { "BAAI/AltCLIP": "https://hu...
712
"""simple docstring""" from math import factorial, pi def A_ ( UpperCAmelCase__ , UpperCAmelCase__ = 30 ) -> float: if not isinstance(UpperCAmelCase__ , (int, float) ): raise ValueError('maclaurin_sin() requires either an int or float for theta' ...
509
0
"""simple docstring""" 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 from lavis.models import load_model_and_preprocess from PIL import Image from transforme...
450
"""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(): fro...
450
1
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def UpperCamelCase_ ( lowerCAmelCase__ = 8 ): """simple docstring""" _lowerCAmelCase : int = ascii_letters + digits + punctuation return ""...
587
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_pil_image from ...image_utils ...
587
1
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class UpperCAmelCase_ ( unittest.TestCase ): def _lowerCamelCase ( self ) -> int: debug_...
76
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common...
273
0
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel from transf...
707
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaTokeniz...
522
0
from manim import * class SCREAMING_SNAKE_CASE_ ( _a ): """simple docstring""" def UpperCamelCase__ ( self :List[str]): """simple docstring""" _lowercase =Rectangle(height=0.5, width=0.5) _lowercase =Re...
181
import torch from transformers import AutoModel class SCREAMING_SNAKE_CASE_ ( torch.nn.Module ): """simple docstring""" def __init__( self :Dict, snake_case :str="sayef/fsner-bert-base-uncased"): """simple docstring""" super(snake_case, self...
181
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_...
468
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A_ ( snake_case_ ): UpperCAmelCase__ = (UnCLIPScheduler,) def _snake_case ( self : Any ...
468
1
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase = No...
42
'''simple docstring''' from math import isclose, sqrt def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> tuple[float, float, float]: lowerCamelCase_ = point_y / 4 / point_x lowerCamelCase_ = 2 * normal_gradient / (1 + normal_gradi...
42
1
"""simple docstring""" def _UpperCamelCase ( _A , _A ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def _UpperCamelCase ( ) -> None: """simple docstring""" assert nand_gate(0 , 0 ) == 1 asser...
19
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_de...
19
1
_lowerCamelCase = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' _lowerCamelCase = [{'...
6
'''simple docstring''' import random def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Tuple , SCREAMING_SNAKE_CASE_ : Union[str, Any] , SCREAMING_SNAKE_CASE_ : Union[str, Any] ) -> Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE_...
421
0
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( ...
708
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowercase__ = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_...
63
0
__a :str = { 'meter': 'm', 'kilometer': 'km', 'megametre': 'Mm', 'gigametre': 'Gm', 'terametre': 'Tm', 'petametre': 'Pm', 'exametre': 'Em', 'zettametre': 'Zm', 'yottametre': 'Ym', } # Exponent of the factor(meter) __a :List[str] = { 'm': 0, ...
86
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __a :Any = logging.getLogger(__name__) class _a ( snake_case_ ): """simple docstring""" ...
86
1
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split SCREAMING_SNAKE_CASE__ : str = datasets.load_iris() SCREAMING_SNAKE_CASE__ : Dict = np.array(data["data"]) SCREAMING_SNAKE_CAS...
509
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from fl...
509
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ : Optional[int] = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_...
115
"""simple docstring""" def A_ (__a ): '''simple docstring''' A_ = len(__a ) while cur > 1: # Find the maximum number in arr A_ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A_ = arr[mi::-1] + ar...
115
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "weiweishi/roc-bert-base-zh": "https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json", } class _lowerCAmelCase ( __a ): _lowercase ='''r...
279
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger _A = get_logger(__name__) _A = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):\n Indices of input...
279
1
'''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 _a ( unittest.TestCase ): """simple docstring""" def lo...
451
'''simple docstring''' def A_ ( SCREAMING_SNAKE_CASE_ ) ->bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
451
1
import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from...
717
'''simple docstring''' import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __snake_case : Union[str, Any] ...
687
0
'''simple docstring''' import argparse import os import re import packaging.version A = '''examples/''' A = { '''examples''': (re.compile(R'''^check_min_version\(\"[^\"]+\"\)\s*$''', re.MULTILINE), '''check_min_version(\"VERSION\")\n'''), '''init''': (re.compile(R'''^__vers...
125
import math def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> list: __lowerCamelCase : Union[str, Any] = [True] * n __lowerCamelCase : List[Any] = False __lowerCamelCase : int = False __lowerCamelCase : An...
652
0
from __future__ import annotations def snake_case__ ( lowerCamelCase_ ): A : Optional[Any] = 0.00 A : Union[str, Any] = 0 for resistor in resistors: if resistor <= 0: A : List[Any] = F'Resistor ...
423
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Dict = logging.get_logger(__name__) lowercase : List[str] = { "facebook/vit-mae-base": "https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json", # See all ViT MA...
423
1
'''simple docstring''' import warnings from ..trainer import Trainer from ..utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) class lowerCAmelCase ( __lowerCAmelCase): def __init__( self , __SCREAMING_SNAKE_CASE=None , **__SCREAMING_SNAKE_CAS...
24
'''simple docstring''' def _snake_case ( A ) -> int: if n == 1 or not isinstance(A , A ): return 0 elif n == 2: return 1 else: lowerCAmelCase__ = [0, 1] for i in range(2 , n...
90
0
from __future__ import annotations from cmath import sqrt def _a ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" if a == 0: raise ValueError('''Coefficient \'a\' must not be zero.''' ) UpperCamelCase__ ...
106
import functools def _a ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str ): """simple docstring""" UpperCamelCase__ : str = len(SCREAMING_SNAKE_CASE ) UpperCamelCase__ : Optional[Any] = len(SCREAMING_SNAKE_CASE ) @functools.cach...
106
1
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTes...
287
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class UpperCAmelCase ( snake_case_ ): def __init__( self :...
207
0
"""simple docstring""" # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPToken...
309
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ : Any = { """configuration_poolformer""": [ """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PoolFor...
309
1
'''simple docstring''' import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _lowerCAmelCase ( lowerCamelCas...
502
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( lowerCamelCase_ : list , lowerCamelCase_ : int | None = None , lowerCamelCase_ : int | None = None ): if start is None: __lowercase = 0 if end ...
502
1
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_t...
407
from pathlib import Path import fire def _lowerCAmelCase ( __magic_name__ :str , __magic_name__ :str , __magic_name__ :int ): UpperCAmelCase_ = Path(__magic_name__ ) UpperCAmelCase_ = Path(__magic_name__ ) dest_dir.mkdir(exist_ok=__ma...
407
1
def __lowerCAmelCase ( a__ = 10 ) -> str: if not isinstance(a__ , a__ ) or n < 0: raise ValueError('''Invalid input''' ) __a = 10**n __a = 2_8433 * (pow(2 , 783_0457 , a__ )) + 1 return str(number % modulus ) ...
219
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, ResNetCo...
219
1
"""simple docstring""" from __future__ import annotations _lowerCamelCase = 8.988e9 # units = N * m^s * C^-2 def lowerCAmelCase_ ( lowercase_ : float , lowercase_ : float , lowercase_ : float , lowercase_ : float ): '''simple doc...
401
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class snake_case : def __init__( self :Dict , _lowerCamelCase :List[str] ): __SCREAMING_SNAKE_CASE : Union[str, Any] = str(id_ ) __SCREAMING_SNAKE_CAS...
401
1
"""simple docstring""" import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_mod...
83
"""simple docstring""" import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, ...
337
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { "microsoft/unispeech-large-1500h-cv": ( "https://huggingface.c...
714
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function lowerCAmelCase_ = 1.0_5457_1817E-34 # unit of ℏ : J * s lowerCAmelCase_ = 3E8 # unit of c : m * s^-1 ...
426
0
'''simple docstring''' import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if i...
421
'''simple docstring''' def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : int ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : str = (1 + 2_4 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : ...
421
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvai...
683
class __snake_case : """simple docstring""" def __init__( self : Optional[int] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {} ...
683
1
'''simple docstring''' from torch import nn def lowerCAmelCase_ ( snake_case_ : int ) -> Dict: '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": ...
78
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers...
47
0
'''simple docstring''' 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 imp...
61
'''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
1
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class _lowercase ( nn.Module ): def __init__( self , UpperCamelCase_ = 16 , UpperCamelCase_ = 88 , UpperCamelCase_ = None...
490
"""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 BartForConditi...
490
1
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_com...
721
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _SCREAMING_SNAKE_CASE = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa ...
534
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_...
142
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Optional[Any] = { """configuration_funnel""": ["""FUNNEL_PRETRAIN...
142
1
'''simple docstring''' import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch ...
713
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A = {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FNetConfig']} try: if not is_s...
234
0
"""simple docstring""" def _snake_case ( ): return 1 def _snake_case ( lowercase__ ): return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def _snake_case ( lowercase__ ): return 0 if x < 0 else five_pe...
630
"""simple docstring""" import operator as op def _snake_case ( lowercase__ ): _lowerCamelCase : Dict = [] _lowerCamelCase : List[str] = lambda lowercase__ , lowercase__ : int(x / y ) # noqa: E731 integer ...
630
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class lowerCAmelCase__ ( _lowerCamelCase ): def __init__( self : Dict ) -> Optional[int]: # test for the above condition self.test() def __UpperC...
700
def lowerCamelCase_ ( lowerCAmelCase__ : list ) -> int: '''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] ) ): ...
224
0
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration __SCREAMING_SNAKE_CASE = 5_00_00 __SCREAMING_SNAKE_CASE = 50_00 __SCREAMING_SNAKE_CASE = os.path.split(__file__) __SCREAMING_SNAKE_CASE = os.path.join(RESULT...
553
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCamelCase__ : Tuple = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translati...
387
0
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable A_ : Optional[Any] = {"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXConfi...
718
"""simple docstring""" import os def lowerCamelCase_ ( ): with open(os.path.dirname(_lowerCamelCase ) + '/p022_names.txt' ) as file: lowerCamelCase__ : Union[str, Any] = str(file.readlines()[0] ) lowerCamelCase__ : int = names.replace('"' , '' ...
696
0
from typing import TYPE_CHECKING from ...utils import _LazyModule A__: Dict = {'''tokenization_byt5''': ['''ByT5Tokenizer''']} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys A__: List[str] = _LazyModule(__name__, globals()['''__file__'''...
380
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A__: Union[str, Any] = logging.get_logger(__name__) A__: int = {'''vocab_file''': '''senten...
380
1
import argparse from collections import defaultdict import yaml __lowerCamelCase = """docs/source/en/_toctree.yml""" def UpperCamelCase__ ( UpperCAmelCase ) -> Tuple: """simple docstring""" _a : Union[str, Any] = defaultdict(UpperCAmelCase ) ...
720
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase__ ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> Tuple: ...
307
0
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import Aut...
569
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer snake_case : List[Any] = {"""vocab_file""": """vocab.txt""", "...
545
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, )...
712
'''simple docstring''' import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def __snake_case (__UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): """simple docstring""" lowerCamelCase_ : Optional[int] = ...
418
0
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, JumanppTokenizer...
184
import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...
33
0
from queue import PriorityQueue from typing import Any import numpy as np def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , __snake_case ,...
402
def _SCREAMING_SNAKE_CASE ( __snake_case ) -> float: return 1_0 - x * x def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(__snake_case ) * equ...
402
1