code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' lowercase_ = {} def lowerCamelCase ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int ) ->List[Any]: if late == 3 or absent == 2: return 0 # if we have no days left, and have not failed a...
58
from math import factorial, radians def _snake_case ( lowerCAmelCase : float , lowerCAmelCase : int = 1_8 , lowerCAmelCase : int = 1_0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) ...
18
0
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 : Any = logging.getLogger(__name__) if __name__ == "__main__": _lowerCame...
366
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : List[Any] = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { "kssteven/ibert-rober...
159
0
'''simple docstring''' 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_docstri...
250
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 1_0, """max_num_job...
147
0
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import ...
359
'''simple docstring''' from math import asin, atan, cos, radians, sin, sqrt, tan _A : List[str] =637_8137.0 _A : Dict =635_6752.31_4245 _A : int =6_378_137 def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ...
129
0
'''simple docstring''' from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import (...
161
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ : List[Any] = { "configuration_vision_text_dual_encoder": ["Vis...
161
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a : List[str] = logging.get_logger(__name__) ...
357
"""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/lic...
79
0
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) # TODO Update this UpperCAmelCase__ = { '''facebook/esm-1b''': '''https://huggingface.co/fac...
5
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) # TODO Update this UpperCAmelCase__ = { '''facebook/esm-1b''': '''https://huggingface.co/fac...
5
1
"""simple docstring""" import numpy as np import qiskit def A ( snake_case :int = 8 , snake_case :int | None = None ) -> str: __UpperCamelCase = np.random.default_rng(seed=snake_case ) # Roughly 25% of the qubits will contribute to the key. # So we take more than we nee...
263
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import...
263
1
'''simple docstring''' import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path fro...
344
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCamelCase_ ( _a : List[Any] ): '''simple docstring''' UpperCAmelCase_ : Optional[int] = [ """decoder.version""", ...
345
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import StableDi...
355
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
304
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 transform...
90
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { '...
32
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalD...
88
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() d...
88
1
"""simple docstring""" def _A ( UpperCamelCase_ : int = 1000) -> int: '''simple docstring''' __lowercase ,__lowercase = 1, 1 __lowercase = 2 while True: __lowercase = 0 __lowercase = fa + fa __lowercase ,__lowerc...
17
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import...
17
1
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int ): if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(__lowerCamelCase ,__lowerCamelCase ): raise TypeError("Input value must be a 'int' type" ) retu...
147
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class a_ ( _lowerCAmelCase ): @staticmethod @abstractmethod def lowercase__ ( lowercase : ArgumentParser ): """simple docs...
147
1
'''simple docstring''' 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_config...
35
from typing import Union import fire import torch from tqdm import tqdm def _lowerCAmelCase ( lowerCAmelCase_ :str , lowerCAmelCase_ :str = "cpu" , lowerCAmelCase_ :Union[str, None] = None )->None: '''simple docstring''' snake_case_ ...
159
0
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class UpperCAmelCase : """simple docstring""" _UpperCAmelCase :s...
362
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: lowercase__: int = '''''' for word_or_phrase in separated: if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise Exception('''join() accepts only strings to...
2
0
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, requir...
94
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 lowerCAmelCase__ ( lowerCamelCase_ : Optional[Any]): # picklable for multiprocessi...
129
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVeca...
367
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormat...
219
0
import csv import tweepy # Twitter API credentials A_ :int = '''''' A_ :str = '''''' A_ :Dict = '''''' A_ :Optional[int] = '''''' def A ( a_ ) -> None: # authorize twitter, initia...
71
'''simple docstring''' class _UpperCAmelCase : """simple docstring""" def __init__( self : List[str] , __UpperCAmelCase : list[int] ): '''simple docstring''' _A = len(__UpperCAmelCase ) _A = [0] * len_array if len_array...
79
0
import math from collections.abc import Callable def lowerCAmelCase__ ( a__: Callable[[float], float] , a__: float , a__: float ) -> float: '''simple docstring''' _UpperCAmelCase = xa _UpperCAmelCase = xa while True: if x_n ...
185
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional im...
185
1
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class snake_case : """simple docstring""" def __init__( self : int , __A : ...
53
"""simple docstring""" from __future__ import annotations def lowercase_ ( __UpperCAmelCase ) -> int: if not nums: return 0 lowerCAmelCase__ : List[Any] = nums[0] lowerCAmelCase__ : List[str] = 0 for num in nums[1:]: ...
242
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers impo...
371
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" lowerCAmelCase__ :list[list[int]] = [[0 for _ in range(_SCREAMING_SNAKE_CASE )] for _ in range(m + 1 )] for i in range(m + 1 ): lowerCAmelCase__ :str ...
254
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class lowerCAmelCase__ : def __init__( self : Any ): _snake_case = {} def lowercase ( ...
288
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.ut...
288
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
126
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str ,_lowerCamelCase : bool = False ) -> str: if not isinstance(_lowerCamelCase ,_lowerCamelCase ): _lowerCAmelCase : Union[str, Any] = f"Expected string as input, found {type(_l...
126
1
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __lowerCAmelCase : Any = logging.get_logger(__name__) class UpperCAmelCase_ ( _A ): '''simple docstring''' def __init__( self : Option...
88
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableData...
88
1
'''simple docstring''' def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> float: if edge <= 0 or not isinstance(UpperCamelCase , UpperCamelCase ): raise ValueError("""Length must be a positive.""" ) return 3 * ((25 + 10 * (5 ** (1 / 2))) *...
370
'''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 impo...
129
0
import numpy as np from transformers import Pipeline def lowerCAmelCase_ (lowerCAmelCase__: str ): """simple docstring""" UpperCAmelCase_: Union[str, Any] = np.max(lowerCAmelCase__ , axis=-1 , keepdims=lowerCAmelCase__ ) Upper...
147
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 transform...
147
1
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available()...
367
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import g...
349
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfig', 'DeiTOnnxConfig']} t...
90
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase : List[str] = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned...
2
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property ...
355
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _lowerCamelCase = logging.get_logger(__...
177
0
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 UpperCAmelCase : Optional[Any] ...
128
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate im...
219
0
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase, ...
369
'''simple docstring''' a : Dict = 6_5521 def __magic_name__ ( __UpperCAmelCase ) -> int: '''simple docstring''' snake_case_ = 1 snake_case_ = 0 for plain_chr in plain_text: snake_case_ = (a + ord(__UpperCAmelCase...
72
0
'''simple docstring''' A__ : dict[tuple[int, int, int], int] = {} def UpperCAmelCase__ ( UpperCAmelCase_ : int , UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no fur...
185
'''simple docstring''' import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_c...
185
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A : Any = logging.get_logger(__name__) _A : st...
365
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : List[str] = { """snap-research/efficientformer-l1-300""": ( """https:/...
330
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPooli...
18
'''simple docstring''' import qiskit def lowercase_ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ): """simple docstring""" __UpperCAmelCase : Union[str, Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum...
254
0
"""simple docstring""" import math from typing import Dict, Iterable, List, Optional, Tuple, 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 from ...image_utils im...
73
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py __SCREAMING...
73
1
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) lowerCAm...
126
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import...
126
1
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : Any , SCREAMING_SNAKE_CASE__...
117
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _UpperCAmelCase ( SCREAMING_SNAKE_CA...
117
1
'''simple docstring''' def a_ ( lowerCamelCase : int , lowerCamelCase : int , lowerCamelCase : list[list[int]] ): def update_area_of_max_square(lowerCamelCase : int , lowerCamelCase : int ) -> int: # BASE CASE if row >= rows or col >= cols: ret...
4
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreT...
129
0
"""simple docstring""" from bisect import bisect from itertools import accumulate def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: __lowerCAmelCase: Dict = sorted(zip(__SCREAMIN...
355
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) __A = { "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP",...
108
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __A( unittest.TestCase ): """simple docstring""" SCREAMING_SNAKE_CASE__ = JukeboxTokenizer SCREAMING_SNAKE_CASE__ = { """artist""": """Zac Brown Band""", """g...
244
import torch from diffusers import StableDiffusionPipeline lowerCamelCase_ = '''path-to-your-trained-model''' lowerCamelCase_ = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('''cuda''') lowerCamelCase_ = '''A photo of sks dog in a bucket''' lowerCamel...
244
1
'''simple docstring''' import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeach...
107
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class __magic_name__ : lowerCAmelCase : str = field( ...
107
1
'''simple docstring''' import os import sys import unittest lowerCamelCase : Optional[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E4...
2
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_lilt": ["LILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LiltConfig"], } try: if not is_torch_available(): raise OptionalDepen...
177
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class lowercase__ ( _UpperCAmelCase ): def __init__( self : str , UpperCAmelCase_ : Union[str, Any] , UpperCAmelCase_ : Union[str, Any] ): SCREA...
350
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ ( _UpperCAmelCase ): A__ : Any =(CMStochasticIterativeScheduler,) A__ : Optional[int] =1_0 def A_ ( self : Dict , ...
169
0
"""simple docstring""" # This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def _...
84
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
72
0
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __UpperCamelC...
365
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a : Dict = logging.get_logger(__name__) a : List[Any] = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/mai...
79
0
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch ...
37
def a__ ( _UpperCamelCase : int ): if not isinstance(_UpperCamelCase ,_UpperCamelCase ): __lowerCamelCase = F"""Input value of [number={number}] must be an integer""" raise TypeError(_UpperCamelCase ) if number < 0: return False __lowerCa...
330
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, DPRQ...
47
import copy import re class _SCREAMING_SNAKE_CASE : lowerCAmelCase__ = 'hp' lowerCAmelCase__ = {} lowerCAmelCase__ = None @classmethod def SCREAMING_SNAKE_CASE_( cls , lowercase , lowercase ) -> Tuple: lowerCamelCase_ = prefix ...
47
1
from ..utils import DummyObject, requires_backends class A_ ( metaclass=SCREAMING_SNAKE_CASE ): _UpperCAmelCase : List[str] = ['''keras_nlp'''] def __init__( self : Tuple ,*SCREAMING_SNAKE_CASE__ : Any ,**SCREAMING_SNAKE_CASE__ : List[s...
73
# This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests from os.path impo...
73
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As co...
347
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Optional[Any] = { "configuration_wav2vec2": ["WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP...
347
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) snake_case__ : Union[str, Any] = {'configuration_vit': ['VIT_PR...
117
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def _a ( lowerCamelCase: np.ndarray , lowerCamelCase: np.ndarray , lowerCamelCase: np.ndarray , lowerCamelCase: int , lowerCamelCase: int ) -> np.ndarray: ...
117
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : str = logging.get_logger(__name__) A_ : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/reso...
141
from argparse import ArgumentParser from . import BaseTransformersCLICommand def UpperCamelCase (lowercase_: int ) -> str: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class _a (__magic_name__ ): '''simple docstring'''...
141
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_common import To...
68
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import T...
108
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSp...
370
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ = { 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTokenizer'], ...
111
0
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __magic_name__ ( A : int ): '''simple docstring''' return sum(param.float().sum()...
107
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class snake_case__ : """simple docstring""" SCREAMING_SNAKE_CASE_ : str ...
107
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a: Tuple = { """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""], } try: if not is_torch_available(): ...
359
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): def merge(UpperCAmelCase , UpperCAmelCase ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right return list(_merge() ) ...
214
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 import IFWa...
181
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _UpperCamelCase ( lowerCAmelCase ): UpperCAmelCa...
169
0
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowercase_ = logging.get_logger(__name__) class A ( _UpperCAmelCase ): """simple docstring""" def __init__( self : int,*lowercase_...
282
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailabl...
282
1
'''simple docstring''' a_ : Tuple = [ """VerificationMode""", """Version""", """disable_progress_bar""", """enable_progress_bar""", """is_progress_bar_enabled""", """experimental""", ] from .info_utils import VerificationMode from .logging import disable_progress_bar...
55
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_co...
79
0
def A__ ( lowerCamelCase , lowerCamelCase ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCamelCase_: Optional[int] = str(bin(lowerCamelCase ) )[2:] # remove the leading "0b" UpperCamelCase_: int = str...
223
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowerCamelCase_ : Optional[Any] = datasets.utils.logging...
223
1
'''simple docstring''' import os def _lowerCAmelCase ( ) -> List[str]: """simple docstring""" with open(os.path.dirname(_UpperCamelCase ) + '/grid.txt' ) as f: _SCREAMING_SNAKE_CASE =[] # noqa: E741 for _ in range(20 ): l.ap...
47
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCamelCase : Optional[int] = False class A__ ( ...
47
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.ut...
68
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _UpperCAmelCase : '''simple docstring''' a__ ...
68
1
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ...
347
"""simple docstring""" 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 Flax...
347
1
"""simple docstring""" import unittest from transformers import DonutProcessor __A = "naver-clova-ix/donut-base" class UpperCAmelCase (unittest.TestCase ): """simple docstring""" def _snake_case ( self ): lowercase__: int = DonutProcessor.fr...
2
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger __A = "<<<<<<< This should probably be modified because it mentions: " __A = "=...
2
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterM...
141
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __UpperCamelCase ( lowercase__ : Optional[int], lowercase__ : str, lowercase__ : int ): '''simple docstring''' __...
141
1
import heapq import sys import numpy as np _UpperCAmelCase : str = tuple[int, int] class lowercase : def __init__( self ) -> Tuple: """simple docstring""" UpperCamelCase = [] UpperCamelCase = set() def __UpperCamelCase ( self ) -> Tuple: ...
110
from __future__ import annotations def A ( lowercase , lowercase ) -> tuple[int, int]: '''simple docstring''' if b == 0: return (1, 0) ((UpperCamelCase) , (UpperCamelCase)) = extended_euclid(lowercase , a % b ) UpperCamelCase = a // b return (y, x - k ...
110
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__lowerCamelCase ) class __UpperCAmelCase (__lowerCamelCase ): __snake_case : List[str] = fie...
306
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp ...
111
0
"""simple docstring""" def _snake_case ( _snake_case : int = 1000000 ): lowerCAmelCase : Optional[int] = limit + 1 lowerCAmelCase : int = [0] * limit for first_term in range(1 , _snake_case ): for n in range(_snake_case , _snake_case ,...
314
"""simple docstring""" from math import sqrt def _snake_case ( _snake_case : int ): assert isinstance(_snake_case , _snake_case ) and ( number >= 0 ), "'number' must been an int and positive" lowerCAmelCase : Dict = True # 0 and 1 are none...
314
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github snake_case_ = [ """good first issue""", """feature request""", """wip""", ] def _lowerCAmelCase ( ): UpperCAmelCase = Github(os.environ['GITHUB...
78
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
0
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int ): assert ( isinstance(__lowerCamelCase ,__lowerCamelCase ) and number_of_steps > 0 ), F'number_of_steps needs to be positive integer, your input {number_of_steps}' if number_of_steps == 1: ...
147
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int | float | str ): try: lowercase_ :Optional[int] = float(__lowerCamelCase ) except ValueError: raise ValueError("Please enter a valid number" ) lowercase_ :Dict = ...
147
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowerCamelCase : Dict = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: ...
282
import numpy as np def a_ ( __lowercase : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
282
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : int = ...
369
"""simple docstring""" from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule de...
318
0
'''simple docstring''' import numpy as np def UpperCAmelCase_ ( __lowerCamelCase : np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
223
'''simple docstring''' import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) lowerCAmelCase : ...
223
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : ...
318
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise Optio...
318
1
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thing...
68
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json""", } class a_...
68
1
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> list[int]: '''simple docstring''' if num <= 0: raise ValueError('Input must be a positive integer' ) lowerCAmelCase : List[str] = [True] * (num + 1) lowerCAmelCase : int = 2 whi...
364
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __A : Dict = models.Sequential() # Step 1 - Convolution # ...
323
0
'''simple docstring''' import unittest from transformers import DonutProcessor lowerCamelCase : Tuple = 'naver-clova-ix/donut-base' class __lowerCAmelCase (unittest.TestCase ): '''simple docstring''' def UpperCamelCase__ (self : int ): '...
2
'''simple docstring''' import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
2
1
import re import subprocess import sys __a :int = subprocess.check_output('git merge-base main HEAD'.split()).decode('utf-8') __a :Tuple = ( subprocess.check_output(F"git diff --diff-filter=d --name-only {fork_point_sha}".split()).decode('utf-8').split() ) __a :int = '|'.join(sys.argv[1:]) _...
362
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_modules import _PACKAGE...
329
0
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, AutoMode...
110
from ..utils import DummyObject, requires_backends class _a ( metaclass=UpperCamelCase__ ): _lowercase : Any = ['''torch''', '''scipy'''] def __init__( self: int , *UpperCamelCase_: Any , **UpperCamelCase_: Optional[Any] ) -> List[st...
110
1
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTester...
356
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nes...
153
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase__ : Dict = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_availa...
112
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn #...
239
0
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): fro...
358
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL im...
77
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer a : List[str] = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} ...
147
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device fr...
147
1
from sklearn.metrics import fa_score import datasets A_ : Tuple = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' A_ : Tuple = '\nArgs:\n predictions (`list`...
358
from abc import ABC, abstractmethod from argparse import ArgumentParser class _lowerCAmelCase( UpperCAmelCase_ ): """simple docstring""" @staticmethod @abstractmethod def _a ( _lowerCamelCase ): raise NotImplemen...
292
0
'''simple docstring''' import argparse import datetime import io import itertools import json import math import os import platform import re import shlex import subprocess import sys from pathlib import Path from statistics import fmean import pandas as pd import torch from tqdm import tqdm import transformers...
27
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImagePro...
318
0
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __a = _symbol_database.Def...
235
def lowerCamelCase__ ( _lowercase , _lowercase ): '''simple docstring''' return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowerCamelCase__ ( _lowercase , _lowercase=0 ): '''simple docstring''' return sorted(_lowercase ...
235
1
'''simple docstring''' import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common impo...
346
'''simple docstring''' import math def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : int ): '''simple docstring''' assert isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and ...
346
1
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowercase: '''simple docstri...
132
"""simple docstring""" from __future__ import annotations from math import gcd def UpperCAmelCase__ (snake_case__ : int , snake_case__ : int = 2 , snake_case__ : int = 1 , snake_case__ : int = 3 , ): """simple docstring""" if num < 2: ...
132
1
'''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 R...
80
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """microsoft/git-base""": """https://huggingface.co/microsoft/gi...
323
0
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A__ : Optional[Any] = '''.''' if __name__ == "__main__": A__ : Optional[Any] = os.path.join(REPO_PATH...
363
'''simple docstring''' def a_ ( _UpperCAmelCase : int = 1_00 ) -> int: __snake_case : Any = n * (n + 1) * (2 * n + 1) / 6 __snake_case : Union[str, Any] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == ...
0
0
"""simple docstring""" from PIL import Image def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): def brightness(UpperCamelCase_ ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError("""level must be between -255.0 (black) and 255...
100
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer lowerCAmelCase__ :Optional[int] = logging.getLogger(__name__) def lowerCAmelCase__ ( ) -> Tuple: '''simple docstring''' _UpperCAmelCase = argpar...
329
0
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) UpperCamelCase_ = pytest.mark.integration ...
246
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = {"openai-gpt": "https://huggingface.co/openai-gpt/resolve/main/config.json"} class _...
246
1
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def lowercase ( ): '''simple docstring''' _UpperCAmelCase = ArgumentParser('''Diffusers CLI tool''' , usage='''diffusers-cli <command> [<args...
260
"""simple docstring""" from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _lowerCamelCase ( _lowercase ...
153
0
"""simple docstring""" import doctest from collections import deque import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self : Dict ): '''simple docstring''' A__ : List[str] = [2, 1, 2, -1] A__ : ...
363
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP...
296
0
from __future__ import annotations def __lowerCAmelCase ( a__ , a__ , a__ , ) -> Optional[Any]: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values''' ) elif electron_conc < 0: ...
6
"""simple docstring""" _UpperCamelCase : Union[str, Any] = 8.3_1_4_4_5_9_8 def a_ ( _lowerCAmelCase : float , _lowerCAmelCase : float ): '''simple docstring''' if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) ...
77
0
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AN...
324
"""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 @requ...
324
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE :str = { '''configuration_roformer''...
22
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import flo...
292
0
'''simple docstring''' from timeit import timeit lowerCAmelCase_ : List[str] = { 'MALAYALAM': True, 'String': False, 'rotor': True, 'level': True, 'A': True, 'BB': True, 'ABC': False, 'amanaplanacanalpanama': True, # "a man a plan a canal panama" } # Ensure ...
346
'''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 BartForCo...
346
1
from __future__ import annotations def _snake_case ( lowerCAmelCase : list[int] ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Tuple = len(__lowerCamelCase ) // 2 # choose the middle 3 elements SCREAMING_SNAKE_CASE_ : int = lst[m - 1 : m + 2] # if mi...
18
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slo...
223
0
'''simple docstring''' import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class a__ ( a__ , a__ ): '''simple docstring''' @register_to_config ...
228
'''simple docstring''' def _snake_case ( A = 10 , A = 22 ) -> int: lowerCAmelCase__ = range(1 , A ) lowerCAmelCase__ = range(1 , A ) return sum( 1 for power in powers for base in bases if len(str(base**power ) ) =...
228
1