code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
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_f...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase : List[str] = str(bin(UpperCamelCase__ ) ...
263
0
from math import factorial snake_case : Dict = {str(d): factorial(d) for d in range(10)} def __lowerCamelCase ( UpperCAmelCase_ : int ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(UpperCamelCase__ ) ) def __lowerCamelC...
94
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase :int = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise Option...
263
0
from math import isqrt def A (__A : int ) -> Union[str, Any]: """simple docstring""" UpperCAmelCase_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
51
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) _l...
263
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__: int = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependencyNo...
149
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): '''simple docstring''' def __init__( self ...
263
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
259
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , Uppe...
263
0
'''simple docstring''' def lowerCamelCase__ ( _A ): return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') lowerCAmelCase: Tuple ...
297
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _lowerCAmelCase :str = object() # For specifying empty leaf dict `{}` _lowerCAmelCase :str = obj...
263
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) UpperCAmelCase_ : List[Any] = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/re...
91
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _UpperCAmelCase ( unittest.TestCase ): ...
263
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase :Union[str, Any] = logging.get_logger(__name__) l...
331
"""simple docstring""" 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_...
263
0
import math def UpperCAmelCase_ ( __lowerCAmelCase ) -> Tuple: __lowercase : Optional[int] = [] __lowercase : int = 2 __lowercase : List[Any] = int(math.sqrt(UpperCamelCase__ ) ) # Size of every segment __lowercase : Optional[Any] ...
156
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCAmelCase :str = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertCon...
263
0
"""simple docstring""" from __future__ import annotations import math def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> str: if depth < 0: raise ValueError('Depth cannot be less ...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase :List[Any] = {'configuration_opt': ['OPT_PRETRAINED_CON...
263
0
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor _a = logging.getLogger(__name__) _a ...
194
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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...
263
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {'configuration_opt': ['OPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'OPTConfig'...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int ): if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) _UpperCAmelCase : str = 0 while numb...
263
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, te...
94
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : str , UpperCamelCase__ : Optional[Any] ): _UpperCAm...
263
0
def A (__A : int , __A : Optional[int] ) -> int: """simple docstring""" UpperCAmelCase_ = [0 for i in range(r + 1 )] # nc0 = 1 UpperCAmelCase_ = 1 for i in range(1 , n + 1 ): ...
51
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :List[str] = logging.get_logger(__name__) _lowerCAmelCase :Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiua...
263
0
import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.models.bert....
149
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase :int = ['small', 'medium', 'large'] _lowerCAmelCase :int = 'lm_head.decoder.weight' _lowerCAmelCase :Dict = 'lm_head.weight' def lowerCamelCase_ ...
263
0
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 import ids_tensor if is_torch_avail...
259
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping _lowerCAmelCase :Tuple = tuple[int, int] class _UpperCAmelCase : '''simple docstring''' def __init__( self , A , A ) -> None: _Upper...
263
0
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME lowerCAmelCase: int = ['small', 'medium', 'large'] lowerCAmelCase: int = 'lm_head.decoder.weight' lowerCAmelCase: Dict = 'lm_head.weight...
297
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :int = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/co...
263
0
"""simple docstring""" import unittest from transformers import DonutProcessor UpperCAmelCase_ : str = 'naver-clova-ix/donut-base' class lowerCAmelCase__ ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE ( self : int): ...
91
"""simple docstring""" from __future__ import annotations import math def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : bool , UpperCamelCase__ : list[int] , UpperCamelCase__ : float ): if depth < 0: ...
263
0
'''simple docstring''' import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging lowerCAmelCase :int = logging.get_logger(__name__) def lowerCamelCase ( lowerCAmelCase : int ...
331
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device _lowerCAmelCase :Optional[Any] = False class _UpperCA...
263
0
from __future__ import annotations from typing import Any class __lowerCAmelCase : """simple docstring""" def __init__( self : Dict , _snake_case : Optional[int] , _snake_case : str , _snake_case : Optional[int] = 0 ): ...
156
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import l...
263
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: snake_case_ = _modexpt(UpperCamelCase__ , exponent // 2 , Up...
69
"""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 import ids_tensor...
263
0
"""simple docstring""" import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
194
"""simple docstring""" import math from numpy import inf from scipy.integrate import quad def lowerCamelCase_ (UpperCamelCase__ : float ): if num <= 0: raise ValueError('''math domain error''' ) return quad(UpperCamelCase__ , 0 , UpperCamelCase__ , ...
263
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { 'configuration_longformer': [ 'LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase : List[str] = str(bin(UpperCamelCase__ ) ...
263
0
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 NestedDataStructureLike, PathLik...
94
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase :int = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise Option...
263
0
from math import sqrt def A (__A : int ) -> Tuple: """simple docstring""" assert isinstance(UpperCamelCase__ , UpperCamelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" UpperCAmelCase_ ...
51
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) _l...
263
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available...
149
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): '''simple docstring''' def __init__( self ...
263
0
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() __snake_case = loggin...
259
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , Uppe...
263
0
'''simple docstring''' import numpy as np import qiskit def lowerCamelCase__ ( _A = 8 , _A = None ): a : List[Any] = np.random.default_rng(seed=UpperCamelCase__ ) # Roughly 25% of the qubits will contribute to the key. # So we take more than we need. a ...
297
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _lowerCAmelCase :str = object() # For specifying empty leaf dict `{}` _lowerCAmelCase :str = obj...
263
0
"""simple docstring""" import argparse 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 ...
91
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _UpperCAmelCase ( unittest.TestCase ): ...
263
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase :Tuple =...
331
"""simple docstring""" 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_...
263
0
import torch from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer from .base import PipelineTool class __lowerCAmelCase ( lowerCAmelCase_ ): """simple docstring""" A__ : Tuple = '''facebook/bart-large-mnli''' A__ : Optional[i...
156
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCAmelCase :str = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertCon...
263
0
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel __UpperCamelCase = loggi...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase :List[Any] = {'configuration_opt': ['OPT_PRETRAINED_CON...
263
0
"""simple docstring""" from manim import * class _UpperCAmelCase( lowerCamelCase ): def UpperCAmelCase ( self) -> Dict: '''simple docstring''' _UpperCamelCase = Rectangle(height=0.5 , width=0.5) _UpperC...
194
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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...
263
0
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def _snake_case( SCREAMING_SNAKE_CASE__ : Optional[int] , SCREAMING_SNAKE_CASE__ : Tuple=1 ) -> List[Any]: '''simple docstring''' ...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int ): if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) _UpperCAmelCase : str = 0 while numb...
263
0
from math import sqrt def __lowerCamelCase ( UpperCAmelCase_ : int ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even number...
94
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : str , UpperCamelCase__ : Optional[Any] ): _UpperCAm...
263
0
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_configuration_common import...
51
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :List[str] = logging.get_logger(__name__) _lowerCAmelCase :Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiua...
263
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A__: Dict = {'configuration_mra': ['MRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MraConfig']} try: if not is...
149
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase :int = ['small', 'medium', 'large'] _lowerCAmelCase :int = 'lm_head.decoder.weight' _lowerCAmelCase :Dict = 'lm_head.weight' def lowerCamelCase_ ...
263
0
def _A ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : list ): _enforce_args(UpperCamelCase__ , UpperCamelCase__ ) if n == 0: return 0 UpperCamelCase :List[str] = float('''-inf''' ) for i in range(1 , n + 1 ): ...
259
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping _lowerCAmelCase :Tuple = tuple[int, int] class _UpperCAmelCase : '''simple docstring''' def __init__( self , A , A ) -> None: _Upper...
263
0
'''simple docstring''' import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelera...
297
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :int = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/co...
263
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging UpperCAmelCase_ : Tup...
91
"""simple docstring""" from __future__ import annotations import math def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : bool , UpperCamelCase__ : list[int] , UpperCamelCase__ : float ): if depth < 0: ...
263
0
'''simple docstring''' from math import ceil def lowerCamelCase ( lowerCAmelCase : Union[str, Any] , lowerCAmelCase : Any ): """simple docstring""" __magic_name__ : Tuple = list(range(0 , UpperCamelCase__ ) ) __magic_name__ : Any = [item for ...
331
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device _lowerCAmelCase :Optional[Any] = False class _UpperCA...
263
0
import math def UpperCAmelCase_ ( __lowerCAmelCase ) -> Dict: __lowercase : Dict = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(UpperCamelCase__ ) def UpperCAmelCase_ ( __lowerCAmelCase = 1 / 12_345 ) -> int: ...
156
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import l...
263
0
"""simple docstring""" import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils ...
69
"""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 import ids_tensor...
263
0
"""simple docstring""" class _UpperCAmelCase: def __init__( self , __a) -> None: '''simple docstring''' _UpperCamelCase = len(__a) _UpperCamelCase = [0] * len_array if len_array > 0: _UpperCamelCase ...
194
"""simple docstring""" import math from numpy import inf from scipy.integrate import quad def lowerCamelCase_ (UpperCamelCase__ : float ): if num <= 0: raise ValueError('''math domain error''' ) return quad(UpperCamelCase__ , 0 , UpperCamelCase__ , ...
263
0
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class A ( unittest.TestCase ): """simple docstring...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase : List[str] = str(bin(UpperCamelCase__ ) ...
263
0
import math from numpy import inf from scipy.integrate import quad def __lowerCamelCase ( UpperCAmelCase_ : float ): """simple docstring""" if num <= 0: raise ValueError('''math domain error''' ) return quad(UpperCamelCase__ , 0 , UpperCamelCase__ ,...
94
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase :int = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise Option...
263
0
from __future__ import annotations def A (__A : list[int] , __A : list[int] , __A : int ) -> str: """simple docstring""" UpperCAmelCase_ = list(range(len(UpperCamelCase__ ) ) ) UpperCAmelCas...
51
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) _l...
263
0
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import ar...
149
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowerCAmelCase :Optional[int] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): '''simple docstring''' def __init__( self ...
263
0
import math def _A ( SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : float ): if ( not isinstance(UpperCamelCase__ , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('''power_factor must be a valid float...
259
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , Uppe...
263
0
'''simple docstring''' from math import isqrt def lowerCamelCase__ ( _A ): return all(number % divisor != 0 for divisor in range(2 , isqrt(UpperCamelCase__ ) + 1 ) ) def lowerCamelCase__ ( _A = 10**6 ): a : Optional[int] = 0 a :...
297
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _lowerCAmelCase :str = object() # For specifying empty leaf dict `{}` _lowerCAmelCase :str = obj...
263
0
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _A () -> Tuple: """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = { '''r...
91
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _UpperCAmelCase ( unittest.TestCase ): ...
263
0
'''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 _lowerCamelCase ( l...
331
"""simple docstring""" 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_...
263
0
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, slow from ...test_tokenization_common ...
156
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCAmelCase :str = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertCon...
263
0
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase , ...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase :List[Any] = {'configuration_opt': ['OPT_PRETRAINED_CON...
263
0
"""simple docstring""" import heapq def lowerCamelCase__ ( __snake_case ) -> Union[str, Any]: """simple docstring""" _UpperCamelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq mo...
194
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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...
263
0
import heapq as hq import math from collections.abc import Iterator class A : """simple docstring""" def __init__( self : Optional[Any],lowercase_ : Union[str, Any] )-> Optional[int]: '''simple docstring''' ...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int ): if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) _UpperCAmelCase : str = 0 while numb...
263
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case : int = logging.get_logger(__name__) snake_case : List[Any] = { 'junnyu/roformer_ch...
94
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def lowerCamelCase_ (UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : str , UpperCamelCase__ : Optional[Any] ): _UpperCAm...
263
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : List[str] = logging.get_logger(__name__) snake_case_ : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': '...
51
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :List[str] = logging.get_logger(__name__) _lowerCAmelCase :Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiua...
263
0
import datasets from .evaluate import evaluate A__: List[Any] = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint ar...
149
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase :int = ['small', 'medium', 'large'] _lowerCAmelCase :int = 'lm_head.decoder.weight' _lowerCAmelCase :Dict = 'lm_head.weight' def lowerCamelCase_ ...
263
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : List[Any] = { '''configuration_distilbert''': [ ...
264
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer e...
264
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 _UpperCAmelCase ...
264
"""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 ModelTes...
264
1
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, r...
264
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
264
1
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset lowercase__ : Dict = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2),...
264
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class _UpperCAmelCase : def __init__( self : List[Any] ): snake_case_ : List[str] = '''''' snake_case_ : Tuple = '''''' snake_case_ : in...
264
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( lowerCAmelCase__):...
264
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
264
1
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class _UpperCAmelCase : _lowerCAmelCase : float _lowerCAmelCase : TreeNode | None = None _lowerCAmelCase : TreeNode | None = None def __lowercase ( _a ...
264
"""simple docstring""" import numpy as np def __lowercase ( _a ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
264
1
"""simple docstring""" def __lowercase ( _a , _a = False ): if not isinstance(_a , _a ): snake_case_ : int = f"Expected string as input, found {type(_a )}" raise ValueError(_a ) if not isinstance(_a , _a ): snake_case_ : Any = f"Expecte...
264
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset from utils import logger class _UpperCAmelCase ( lowerCAmelCase__): def __init__( self : Optional[int] , lowercase_ : str , lowercase_ : int ): snake_case_ : ...
264
1
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __lowercase ( _a , _a , _a = "x" , _a = 10**-10 , _a = 1 , ): snake_case_ : Any = symbols(_a ) snake_case_ : int = lambdify(_a , _a ) snake_...
264
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __lowercase ( _a , _a , _a = "x" , _a = 10**-10 , _a = 1 , ): snake_case_ : Any = symbols(_a ) snake_case_ : int = lambdify(_a , _a ) snake_...
264
1
"""simple docstring""" import json import sys def __lowercase ( _a , _a ): with open(_a , encoding='''utf-8''' ) as f: snake_case_ : Tuple = json.load(_a ) snake_case_ : int = ['''<details>''', '''<summary>Show updated benchmarks!</summary>''', ''' '''] ...
264
"""simple docstring""" from __future__ import annotations def __lowercase ( _a , _a , _a , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values''' ) elif stress < 0: raise ValueError('''Stress cann...
264
1
"""simple docstring""" from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.s...
264
"""simple docstring""" from functools import lru_cache @lru_cache def __lowercase ( _a ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest...
264
1
"""simple docstring""" from datetime import datetime import matplotlib.pyplot as plt import torch def __lowercase ( _a ): for param in module.parameters(): snake_case_ : str = False def __lowercase ( ): snake_case_ : Tuple = '''cuda''' if torch.cuda.is_avai...
264
"""simple docstring""" import sys lowercase__ : Dict = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557'''...
264
1
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline...
264
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : List[Any] = { '''configuration_distilbert''': [ ...
264
1
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, sl...
264
"""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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
264
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters lowercase__ : Dict = (7_20, 12_80) # Height, Width lowercase__ : Optional[Any] = (0.4, 0.6) # if height or width lower than this scale, d...
264
"""simple docstring""" import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowercase__ : Dict = [ '''wor...
264
1
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import req...
264
"""simple docstring""" def __lowercase ( _a , _a , _a=False ): if isinstance(_a , _a ) and isinstance(_a , _a ): snake_case_ : Union[str, Any] = len(set_a.intersection(_a ) ) if alternative_union: snake_case_ : Any = len(_a ) + l...
264
1
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS...
264
"""simple docstring""" import os from datetime import datetime as dt from github import Github lowercase__ : int = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '''wip''',...
264
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, ...
264
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowercase ( _a , _a ): # Load checkpoint...
264
1
"""simple docstring""" def __lowercase ( _a ): snake_case_ : str = [] snake_case_ : List[str] = set({'''(''', '''[''', '''{'''} ) snake_case_ : Tuple = set({''')''', ''']''', '''}'''} ) snake_case_ : Union[str, Any] = {'''{''': '''}''', '''[''': ''']''',...
264
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS...
264
1
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
264
"""simple docstring""" 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 i...
264
1
"""simple docstring""" import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterToken...
264
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : str = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextCon...
264
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : List[Any] = logging.get_logger(__name__) lowercase__ : Dict = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class _UpperCAmelCas...
264
"""simple docstring""" 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_pro...
264
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
264
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : int = logging.get_logger(__name__) lowercase__ : List[Any] = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/confi...
264
1
"""simple docstring""" from __future__ import annotations import bisect def __lowercase ( _a , _a , _a = 0 , _a = -1 ): if hi < 0: snake_case_ : Tuple = len(_a ) while lo < hi: snake_case_ : List[str] = lo + (hi - lo) // 2 if sorted_collect...
264
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer e...
264
1
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def __lowercase ( _a ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.or...
264
"""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 ModelTes...
264
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 _UpperCAmelCase ( unittest.TestCase): def _snake_case ...
264
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
264
1
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from da...
264
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class _UpperCAmelCase : def __init__( self : List[Any] ): snake_case_ : List[str] = '''''' snake_case_ : Tuple = '''''' snake_case_ : in...
264
1
"""simple docstring""" import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingSt...
264
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
264
1
"""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, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandi...
264
"""simple docstring""" import numpy as np def __lowercase ( _a ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
264
1
"""simple docstring""" def __lowercase ( _a = 1_000 ): return sum(e for e in range(3 , _a ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f'{solution() = }')
264
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset from utils import logger class _UpperCAmelCase ( lowerCAmelCase__): def __init__( self : Optional[int] , lowercase_ : str , lowercase_ : int ): snake_case_ : ...
264
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase__): _lowerCAmelCase : Optional[Any] = ["""flax""", """transformers"""] def __init__( self : Any , *lowercase_ : Any , **lowercase_ ...
264
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __lowercase ( _a , _a , _a = "x" , _a = 10**-10 , _a = 1 , ): snake_case_ : Any = symbols(_a ) snake_case_ : int = lambdify(_a , _a ) snake_...
264
1
"""simple docstring""" import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_M...
264
"""simple docstring""" from __future__ import annotations def __lowercase ( _a , _a , _a , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values''' ) elif stress < 0: raise ValueError('''Stress cann...
264
1
"""simple docstring""" import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __lowercase ( _a , _a , _a , _a , _a ): # load base model snake_case_ : Dict = StableDiffusionPipeline.from_pretrained(_a , to...
264
"""simple docstring""" from functools import lru_cache @lru_cache def __lowercase ( _a ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest...
264
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer lowercase__ : List[str] = logging.g...
264
"""simple docstring""" import sys lowercase__ : Dict = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557'''...
264
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__...
264
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : List[Any] = { '''configuration_distilbert''': [ ...
264
1
"""simple docstring""" def __lowercase ( _a = 1_000 ): snake_case_ : int = 3 snake_case_ : Union[str, Any] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __nam...
264
"""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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
264
1
"""simple docstring""" from __future__ import annotations lowercase__ : Any = 10 def __lowercase ( _a ): snake_case_ : str = 1 snake_case_ : str = max(_a ) while placement <= max_digit: # declare and initialize empty buckets snake_case_ : ...
264
"""simple docstring""" import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowercase__ : Dict = [ '''wor...
264
1
"""simple docstring""" from __future__ import annotations def __lowercase ( _a ): # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(_a ) ): m...
264
"""simple docstring""" def __lowercase ( _a , _a , _a=False ): if isinstance(_a , _a ) and isinstance(_a , _a ): snake_case_ : Union[str, Any] = len(set_a.intersection(_a ) ) if alternative_union: snake_case_ : Any = len(_a ) + l...
264
1
"""simple docstring""" def __lowercase ( _a , _a ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
264
"""simple docstring""" import os from datetime import datetime as dt from github import Github lowercase__ : int = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '''wip''',...
264
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : int = logging.get_logger(__name__) lowercase__ : List[Any] = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/confi...
264
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowercase ( _a , _a ): # Load checkpoint...
264
1
"""simple docstring""" import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): ...
264
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS...
264
1
"""simple docstring""" import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( ...
264
"""simple docstring""" 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 i...
264
1