code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json''', } class lowerCAmelCase_ ( ...
40
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_UpperCamelCase ...
636
0
'''simple docstring''' def _A ( A__ , A__ ): """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
41
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.appe...
636
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "google/realm-cc-news-pretrained-embedder": ( "https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json" ), "goog...
42
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstr...
636
0
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffuse...
43
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamelCase ...
636
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Any = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwri...
44
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import D...
45
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC _lowerCAmelCase : List[str] = parse(importlib.metadata.version('''torch''')) def lowerCamelCase_( _lowerCamelCas...
46
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availa...
47
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
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__ : Dict ...
48
"""simple docstring""" from __future__ import annotations class _UpperCamelCase : '''simple docstring''' def __init__( self , __a=None ): __lowerCAmelCase = data __lowerCAmelCase = None def __repr__( self )...
636
0
"""simple docstring""" def lowercase__ ( snake_case_ :int = 100 ): __UpperCAmelCase = set() __UpperCAmelCase = 0 __UpperCAmelCase = n + 1 # maximum limit for a in range(2 , snake_case_ ): for b in range(2 , snake_case_ ): __UpperC...
49
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
0
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmar...
50
"""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 A : List[Any] = ...
636
0
'''simple docstring''' from math import isqrt def __snake_case ( SCREAMING_SNAKE_CASE_ : int ) -> bool: """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(SCREAMING_SNAKE_CASE_ ) + 1 ) ) def __snake_case ( SCREAMING_SNAKE_CASE_ : ...
51
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
0
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa:...
52
"""simple docstring""" import baseaa def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baadecode(_UpperCamelCase ).decode("utf-...
636
0
from math import factorial def a_ ( lowerCAmelCase_ : int = 20 ): __lowerCAmelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... __lowerCAmelCase = n // 2 return int(factorial(lowerCAmelCase_ ) / (f...
53
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_t...
636
0
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : Optional[int] =logging.get_logger(__name__) __lowercase : Optional[Any] ={ """microsoft/xprophetnet-large-wiki100-cased""": ( """h...
54
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCamelCase : '''simple docstring''' def __init__( self , __a ): __lowerCAmelCase = str(id_ ) __lowerCAmelCase = No...
636
0
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 IFWatermarker from diffusers.utils.testin...
55
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor A : Optional[Any] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self ...
636
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : int = logging.get_logger(__name__) _a : Optional[Any] = { "YituTech/...
56
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_avail...
636
0
from __future__ import annotations def snake_case (UpperCAmelCase__ , UpperCAmelCase__ ) -> list[str]: if nth_term == "": return [""] UpperCamelCase_: List[str] = int(UpperCAmelCase__ ) UpperCamelCase_: Any = int(UpperCAmelCase_...
57
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _UpperCamelCase ( unittest.Test...
636
0
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def __lowerCAmelCase ( __UpperCamelCase : Optional[Any] ...
58
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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_mo...
636
0
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class _SCREAMING_SNAKE_CASE ( unittest....
59
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping __lowerCAmelCase = True for i in range(0 , le...
636
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dime...
60
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, ...
636
0
def _A ( lowerCAmelCase_ : Optional[int] , lowerCAmelCase_ : List[str] , lowerCAmelCase_ : Tuple , lowerCAmelCase_ : List[Any] , lowerCAmelCase_ : str , lowerCAmelCase_ : List[str] ): """simple docstring""" if index == r: for j ...
61
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : int =["""torch"""] def __init__( self , *__a , **__a ): requ...
636
0
snake_case = 8.314462 # Unit - J mol-1 K-1 def lowerCamelCase__ ( lowercase , lowercase , lowercase ): """simple docstring""" if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("Invalid inputs. Enter positive value." ) return moles * kelvin * UNIVERSAL...
62
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_UpperCamelCase ...
636
0
from typing import Any def lowerCamelCase__ ( __lowerCamelCase : list , __lowerCamelCase : list , __lowerCamelCase : dict , __lowerCamelCase : dict , __lowerCamelCase : dict , ): _validation( __lowerCamelCase ...
63
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.appe...
636
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def A__ ( snake_case_ : int = 3 ): if isinstance(snake_case_ , snake_case_ ): raise TypeError('''number of qubits must be a integer.''' ) if number...
64
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstr...
636
0
"""simple docstring""" import argparse from collections import defaultdict import yaml __UpperCAmelCase = 'docs/source/en/_toctree.yml' def lowerCAmelCase ( __UpperCamelCase ): '''simple docstring''' UpperCAmelCase__ : List[str] = defaultdict(__U...
65
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamelCase ...
636
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # ...
66
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def SCREAMING_SNAKE_CASE__ ( snake_case__ :Tuple ) -> Tuple: # This defines a "chinese character" as anything in the CJK Unicode block: ...
67
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTokenizer __A ...
68
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a : str = TypeVar('''KEY''') a : Tuple = TypeVar('''VAL''') @dataclass(frozen=_UpperCamelCase , slots=_...
69
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
0
from PIL import Image def _SCREAMING_SNAKE_CASE ( lowercase : Image ): '''simple docstring''' lowerCamelCase_ , lowerCamelCase_ = image.size lowerCamelCase_ = 0 lowerCamelCase_ = image.load() for i in ...
70
"""simple docstring""" from __future__ import annotations class _UpperCamelCase : '''simple docstring''' def __init__( self , __a=None ): __lowerCAmelCase = data __lowerCAmelCase = None def __repr__( self )...
636
0
'''simple docstring''' from torch import nn def a__ ( _SCREAMING_SNAKE_CASE : Tuple ) -> str: """simple docstring""" if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() el...
71
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
0
'''simple docstring''' import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) def UpperCamelCase ( lowercase_ : Optional...
72
"""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 A : List[Any] = ...
636
0
class _snake_case : def __init__( self , a) -> None: SCREAMING_SNAKE_CASE = size SCREAMING_SNAKE_CASE = [0] * size SCREAMING_SNAKE_CASE = [0] * size @staticmethod def SCREAMING_SNAKE_CASE__ ( a) -> int: ...
73
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
0
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) lowercase_ = models.Sequential() # Step 1 - Convolution # Here ...
74
"""simple docstring""" import baseaa def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baadecode(_UpperCamelCase ).decode("utf-...
636
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ = {'''configuration_plbart''': ['''PLBART_PRETRAINED_C...
75
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_t...
636
0
"""simple docstring""" import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_avail...
76
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCamelCase : '''simple docstring''' def __init__( self , __a ): __lowerCAmelCase = str(id_ ) __lowerCAmelCase = No...
636
0
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pa...
77
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor A : Optional[Any] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self ...
636
0
'''simple docstring''' from __future__ import annotations def lowerCAmelCase_ ( snake_case_ : list ) -> float: '''simple docstring''' if not nums: raise ValueError("List is empty" ) return sum(snake_case_ ) / len(snake_case_ ) if __nam...
78
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_avail...
636
0
from typing import Any class UpperCAmelCase_ : def __init__( self , _lowerCAmelCase ): UpperCAmelCase__ : Tuple = data UpperCAmelCase__ : str = None def __repr__( self ): return ...
79
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _UpperCamelCase ( unittest.Test...
636
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils import floats_tensor,...
80
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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_mo...
636
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
81
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping __lowerCAmelCase = True for i in range(0 , le...
636
0
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration lowerCamelCase = 50_000 lowerCamelCase = 5_000 lowerCamelCase , lowerCamelCase = os.path.split(__file__) lowerCamelCase = os.pat...
82
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, ...
636
0
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( '''files''', [ ['''full:README.md''', '''dataset_infos.json'''], ['''empty:READM...
83
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : int =["""torch"""] def __init__( self , *__a , **__a ): requ...
636
0
from itertools import product def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = sides_number lowercase = max_face_number * dice_number lowercase = [0] * (max_total + 1) lowercase = 1 lowercase = range...
84
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_UpperCamelCase ...
636
0
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-tes...
85
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.appe...
636
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...
86
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstr...
636
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' def __init__( self : Optional[Any] , UpperCAmelCase__ : List[str] ...
87
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamelCase ...
636
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], ...
88
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def UpperCamelCase_( ) -> Any: _lowercase...
89
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
'''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.ut...
90
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
"""simple docstring""" 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 ( SegformerConfig, SegformerForImageClassification, SegformerForSemanti...
91
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
0
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int , __magic_name__ : int ) -> Dict: if b == 0: return 1 if (b % 2) == 0: return actual_power(__magic_name__ , int(b / 2 ) ) * actual_power(__magic_name__ , int(b ...
92
"""simple docstring""" from __future__ import annotations class _UpperCamelCase : '''simple docstring''' def __init__( self , __a=None ): __lowerCAmelCase = data __lowerCAmelCase = None def __repr__( self )...
636
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" lowerCAmelCase__ :Any = [0] * len(_SCREAMING_SNAKE_CASE ) lowerCAmelCase__ :str = [] lowerCAmelCase__ :Dict = [] lowerCAmelCase__ :Tupl...
93
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
0
'''simple docstring''' from collections import deque from .hash_table import HashTable class UpperCAmelCase_ ( __A ): """simple docstring""" def __init__( self : Tuple , *UpperCAmelCase : List[Any] , **UpperCAmelCase : Dict ) -> str: '''si...
94
"""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 A : List[Any] = ...
636
0
"""simple docstring""" import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration lowerCamelCase_ = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'...
95
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
0
"""simple docstring""" from __future__ import annotations def a ( __UpperCAmelCase : list ) -> list: if len(__UpperCAmelCase ) == 0: return [] __magic_name__, __magic_name__: List[str] = min(__UpperCAmelCase ), max(__U...
96
"""simple docstring""" import baseaa def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baadecode(_UpperCamelCase ).decode("utf-...
636
0
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def a ( snake_case__: int , snake_case__: List[Any] , snake_case__: Union[str, Any] , snake_case__: Dict=1_024 ): '''simple docstring''' lowerca...
97
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_t...
636
0
'''simple docstring''' import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class ...
98
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCamelCase : '''simple docstring''' def __init__( self , __a ): __lowerCAmelCase = str(id_ ) __lowerCAmelCase = No...
636
0
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 SCREAMING_SNAKE_CASE = logging.get_logger(__name__)...
99
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor A : Optional[Any] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self ...
636
0
from __future__ import annotations def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> list[tuple[int, int]]: SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = position SCREAMING_SNAKE_CASE__ = [ (y + 1, x + 2), (y - 1, x + ...
100
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_avail...
636
0
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : str =logging.get_logger(__name__) lowerCAmelCase__ : Any ={ 'vocab_file'...
101
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _UpperCamelCase ( unittest.Test...
636
0
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class lowercase__ ( __SCREAMING_SNAKE_CASE ): ...
102
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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_mo...
636
0
"""simple docstring""" import datasets from .evaluate import evaluate snake_case = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, jo...
103
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping __lowerCAmelCase = True for i in range(0 , le...
636
0
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( UpperCAmelCase_ : int | str ) -> bool: """simple docstring""" A__ = str(UpperCAmelCase_ ) return n == n[::-1] def _lowerCamelCase (...
104
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, ...
636
0
print((lambda quine: quine % quine)('''print((lambda quine: quine %% quine)(%r))'''))
105
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : int =["""torch"""] def __init__( self , *__a , **__a ): requ...
636
0
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() __snake_case :Optional[Any] =logging.get_logg...
106
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_UpperCamelCase ...
636
0
'''simple docstring''' from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
107
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.appe...
636
0
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 @slow @requ...
108
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstr...
636
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json", } class __a ( _snake_case ): __Upper...
109
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamelCase ...
636
0
"""simple docstring""" import json import sys def __snake_case ( __A ,__A ) -> Union[str, Any]: with open(_UpperCamelCase ,encoding="""utf-8""" ) as f: lowercase : int = json.load(_UpperCamelCase ) lowercase : Tuple ...
607
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _SCREAMING_SNAKE_CASE (__...
567
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torcha...
368
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common im...
101
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
0
from ....configuration_utils import PretrainedConfig from ....utils import logging __lowerCamelCase : Any = logging.get_logger(__name__) # TODO: upload to AWS __lowerCamelCase : Any = { "yjernite/retribert-base-uncased": ( "https://huggingface.co/yjernite/retribert-base-uncase...
323
"""simple docstring""" from __future__ import annotations class _UpperCamelCase : '''simple docstring''' def __init__( self , __a=None ): __lowerCAmelCase = data __lowerCAmelCase = None def __repr__( self )...
636
0
'''simple docstring''' import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ ...
125
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
0
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class A ( lowerCAme...
22
"""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 A : List[Any] = ...
636
0
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_im...
688
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
0
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
24
"""simple docstring""" import baseaa def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' return baseaa.baadecode(_UpperCamelCase ).decode("utf-...
636
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Dict = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]} try: if not is_vision_available(...
568
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_t...
636
0
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRobe...
148
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCamelCase : '''simple docstring''' def __init__( self , __a ): __lowerCAmelCase = str(id_ ) __lowerCAmelCase = No...
636
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_aut...
607
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor A : Optional[Any] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self ...
636
0
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class SCREAMING_SNAKE_CASE__ ( nn.Module ): def __init__( self : Optional[Any] , lowerCAmelCase_ : Dict = 1_6 , lowe...
567
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_avail...
636
0
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a__ : str = logging.get_logger(__...
368
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _UpperCamelCase ( unittest.Test...
636
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT...
101
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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_mo...
636
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) class __magic_name__ ( lowerCAmelCase__ ): def __init__( self : List[str] , *UpperCamelCase__ : str ...
323
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping __lowerCAmelCase = True for i in range(0 , le...
636
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A = { "configuration_efficientformer": [ "EFFICIENTFORMER_PRETRAINED_CONFIG_A...
125
"""simple docstring""" import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, ...
636
0
'''simple docstring''' def snake_case_ (UpperCamelCase : Union[str, Any] , UpperCamelCase : Tuple , UpperCamelCase : str ): '''simple docstring''' if len(_UpperCamelCase ) != len(_UpperCamelCase ): raise ValueError('''The l...
22
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : int =["""torch"""] def __init__( self , *__a , **__a ): requ...
636
0
'''simple docstring''' import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) ...
688
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_UpperCamelCase ...
636
0
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase : __lowercase : torch.Tensor # [batch_size x 3] __lowercase : torch.Tensor # [batch_size x 3] __lowercase : torch.Tensor # [b...
24
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.appe...
636
0
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def lowerCAmelCase__ ( _a : str , _a : Tuple ): snake_case_ : List[Any] = F'''{sampling_rate}''' snake_case_ : Tuple = ...
568
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstr...
636
0
import math import sys def __lowercase ( a__ ) -> int: __SCREAMING_SNAKE_CASE = '' try: with open(_UpperCamelCase , 'rb' ) as binary_file: __SCREAMING_SNAKE_CASE = binary_file.read() for dat in data...
148
"""simple docstring""" from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamelCase ...
636
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, res...
607
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : List[str] ="""Speech2TextFeatureExtractor""" __Up...
636
0
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.nump...
567
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class __snake_case ( lowerCAmelC...
368
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
def a__ ( A__ = 1_0_0_0_0_0_0 ): SCREAMING_SNAKE_CASE_ : Dict = [i - 1 for i in range(limit + 1 )] for i in range(2, limit + 1 ): if phi[i] == i - 1: for j in range(2 * i, limit + 1, _UpperCamelCase ): phi[j] -= phi[j] // i...
101
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : Dict = get_logger(__name__) A : Dict = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(...
636
0
import unittest from transformers import AutoTokenizer, FalconConfig, 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 Mod...
323
"""simple docstring""" from __future__ import annotations class _UpperCamelCase : '''simple docstring''' def __init__( self , __a=None ): __lowerCAmelCase = data __lowerCAmelCase = None def __repr__( self )...
636
0
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : Tuple = 10 , lowerCAmelCase__ : Dict = 10_00 , lowerCAmelCase__ : Tuple = True) -> str: '''simple docstring''' assert ( isinstance(_UpperCamelCase , _UpperCamel...
125
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase : Tuple =(...
636
0
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class A ( lowerCAmelCase__ ): lowercase_ = (KDPMaDiscreteScheduler,) ...
22
"""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 A : List[Any] = ...
636
0
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensio...
688
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
636
0