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
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 lowerCamelCase_ ( lowerCamelCase ): a__ = field(default='''audio-classi...
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
0
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 __snake_case = '''▁''' __snake_case = {'''vocab_file''': '''spiece.m...
1
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
612
0
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin...
2
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittest.TestCase ): @pr...
612
0
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union lowerCAmelCase : Optional[Any] = re.compile(r'^(?P<major>\d+)' r'\.(?P<minor>\d+)' r'\.(?P<patch>\d+)$') @to...
3
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
612
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Optional[Any] = { '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig''...
4
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A(lowerCAmelCase ) -> Dict: """simple docstring""" _UpperCamelCase = os.path.join(args.tf_model_dir , """parameters.json""" ) _UpperCamelC...
612
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/mai...
5
import warnings from .generation import TFGenerationMixin class lowerCAmelCase__ ( __lowercase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transform...
612
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamelCase_ = "encoder-decoder" lowerCamelCase_ = ...
6
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
612
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailabl...
7
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
612
0
'''simple docstring''' import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokeniz...
8
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
0
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import AutoC...
9
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
# 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: F401 from ..controlnet.pipeline_controlnet import ...
10
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("T") lowerCamelCase__ = TypeVar("U") class lowerCAmelCase__ ( Generic[T, U] ): def __init__( self , a , a ) ...
612
0
'''simple docstring''' def lowerCAmelCase (__A , __A): """simple docstring""" while a != 0: _a , _a = b % a, a return b def lowerCAmelCase (__A , __A): """simple docstring""" if gcd(__A , __A) != 1: ...
11
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 @req...
612
0
def UpperCamelCase ( lowercase_ ) -> list: '''simple docstring''' for i in range(len(lowercase_ ) - 1 , 0 , -1 ): lowercase__ : Union[str, Any] = False for j in range(lowercase_ , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: lower...
12
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
612
0
'''simple docstring''' from decimal import Decimal, getcontext from math import ceil, factorial def UpperCAmelCase__ ( UpperCAmelCase_ : int ) -> str: if not isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): raise TypeError('Undefined for non-integers' ...
13
from collections.abc import Sequence def __A(lowerCAmelCase = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _UpperCamelCase = nums[0] for i in range(1 , len(lowerCAmelCase ) ): _U...
612
0
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCAmelCase ( __a : str ,__a : Optional[int] ...
14
from __future__ import annotations lowerCamelCase__ = "#" class lowerCAmelCase__ : def __init__( self ) -> None: '''simple docstring''' _UpperCamelCase = {} def A_ ( self , a ) -> None: ''...
612
0
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 require_elast...
15
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( __lowercase ): @staticmethod @abstractmethod def A_ ( a ) -> Union[str, Any]: '''simple docstring''' raise NotImplementedError() ...
612
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(): ...
16
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
612
0
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ) -> int: monkeypatch.setattr("""datasets.utils.deprecation_utils._emitted_deprecation_warnings""" ,set() ) @pytest.fixture def ...
17
def __A(lowerCAmelCase ) -> bool: """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) _UpperCamelCase = str(lowerCAmelCase ) _UpperCamelCase = """""".join(sort...
612
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class lowerCAmelCase_ ( __magic_name__...
18
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( __lowercase ): UpperCamelCase_ : int = (KDPMaDiscreteScheduler,) UpperCamelCase_ : Optional[int...
612
0
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class _UpperCAmelCase: def __init__( self , __a) -> Optional[int]: ...
19
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __A(lowerCAmelCase , lowerCAmelCase ) -> np.array: """simple docstring""" _UpperCamelCase = F'{sampling_rate}' _UpperCamelCase = """1""" _UpperCam...
612
0
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import to...
20
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
import unittest import numpy as np from transformers import RoFormerConfig, 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_available(): import jax.num...
21
from __future__ import annotations def __A(lowerCAmelCase , lowerCAmelCase ) -> list[list[int]]: """simple docstring""" _UpperCamelCase = [] _UpperCamelCase = [] _UpperCamelCase = 0 _UpperCamelCase = sum(lowerCAmelCase ) create_st...
612
0
'''simple docstring''' class A : def __init__( self : int , lowerCAmelCase_ : Union[str, Any] , lowerCAmelCase_ : Dict , lowerCAmelCase_ : List[str] ) -> Dict: """simple docstring""" ...
22
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available snake_case__ : Tuple = { """configuration_audio_spectrogram_transformer""": [ """AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CO...
23
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
612
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.util...
24
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittest.TestCase ): @pr...
612
0
import math def lowerCamelCase__ ( _a = 100): SCREAMING_SNAKE_CASE : Tuple = sum(i * i for i in range(1 , n + 1)) SCREAMING_SNAKE_CASE : Optional[int] = int(math.pow(sum(range(1 , n + 1)) , 2)) return square_of_sum - sum_of_squares if __name__ == "_...
25
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
612
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ....
26
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A(lowerCAmelCase ) -> Dict: """simple docstring""" _UpperCamelCase = os.path.join(args.tf_model_dir , """parameters.json""" ) _UpperCamelC...
612
0
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class lowerCamelCase( __snake_case ): '''simple docstring''' __magic_name__ = '' __magic_name__ = ...
27
import warnings from .generation import TFGenerationMixin class lowerCAmelCase__ ( __lowercase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transform...
612
0
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transf...
28
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
612
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { """edbeeching/decision-transformer-gym-hopper-medium""": ( """https://huggingface.co/edbeeching/decision-transformer-gym-hopper-m...
29
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
612
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available __a = { 'configuration_ernie': ['ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ErnieConfig', 'ErnieOnnxConfig'], } try: if not is_torch_available(...
30
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
0
def UpperCAmelCase_ ( ) -> Tuple: for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def UpperCAmelCase_ ( __UpperCAmelCase : Union[str, Any] ) -> Union[str, Any]: SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = ...
31
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "facebook/lev...
32
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("T") lowerCamelCase__ = TypeVar("U") class lowerCAmelCase__ ( Generic[T, U] ): def __init__( self , a , a ) ...
612
0
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class __magic_name__ (yaml.SafeLoader ): '''simple docstring''' def SCREAMING_SNAKE_CASE__ ( self:Union[str, Any] , _a:List[str] ): snake_cas...
33
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 @req...
612
0
"""simple docstring""" import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTe...
34
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
612
0
from collections import Counter from timeit import timeit def a ( A__ = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def a ( A__ = "" ) -> b...
35
from collections.abc import Sequence def __A(lowerCAmelCase = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _UpperCamelCase = nums[0] for i in range(1 , len(lowerCAmelCase ) ): _U...
612
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowercase : Dict = logging.get_logger(__name__) __lowercase : Tuple = { '''shi-labs/nat-mini-in1k-...
36
from __future__ import annotations lowerCamelCase__ = "#" class lowerCAmelCase__ : def __init__( self ) -> None: '''simple docstring''' _UpperCamelCase = {} def A_ ( self , a ) -> None: ''...
612
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class A__ ( A__ ): """simple docstring""" _lowercase = (PNDMScheduler,) _lowercase = (('num_inference_steps', 5_0),) def _UpperCamelCase( self : int ,...
37
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( __lowercase ): @staticmethod @abstractmethod def A_ ( a ) -> Union[str, Any]: '''simple docstring''' raise NotImplementedError() ...
612
0
'''simple docstring''' import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput A_ : Dict = logging.getLogger(__name__) if is_torch_tpu_ava...
38
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
612
0
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelF...
39
def __A(lowerCAmelCase ) -> bool: """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) _UpperCamelCase = str(lowerCAmelCase ) _UpperCamelCase = """""".join(sort...
612
0
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin __Up...
40
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( __lowercase ): UpperCamelCase_ : int = (KDPMaDiscreteScheduler,) UpperCamelCase_ : Optional[int...
612
0
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trus...
41
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __A(lowerCAmelCase , lowerCAmelCase ) -> np.array: """simple docstring""" _UpperCamelCase = F'{sampling_rate}' _UpperCamelCase = """1""" _UpperCam...
612
0
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from tra...
42
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if number < 0: raise ValueError('''number must not be negative''' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
43
from __future__ import annotations def __A(lowerCAmelCase , lowerCAmelCase ) -> list[list[int]]: """simple docstring""" _UpperCamelCase = [] _UpperCamelCase = [] _UpperCamelCase = 0 _UpperCamelCase = sum(lowerCAmelCase ) create_st...
612
0
'''simple docstring''' from math import sqrt def A_ ( _lowerCAmelCase : int ): """simple docstring""" assert isinstance(_lowerCAmelCase , _lowerCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" _lowerCamelCas...
44
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
0
def A ( lowercase__ : int , lowercase__ : float , lowercase__ : float ) -> float: return round(float(moles / volume ) * nfactor ) def A ( lowercase__ : float , lowercase__ : float , lowercase__ : float ) -> float: return round(float((moles * 0.0821 * temperature) / (...
45
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
612
0
"""simple docstring""" from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings ...
46
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittest.TestCase ): @pr...
612
0
import math import tensorflow as tf from packaging import version def UpperCAmelCase__ ( lowerCamelCase_ : Tuple ): __a : Any = tf.convert_to_tensor(lowerCamelCase_ ) __a : Any = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(...
47
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
612
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ : List[str] = { "configuration_lilt": ["LILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LiltConfig"], } try: if not is_torch_available(): raise...
48
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A(lowerCAmelCase ) -> Dict: """simple docstring""" _UpperCamelCase = os.path.join(args.tf_model_dir , """parameters.json""" ) _UpperCamelC...
612
0
"""simple docstring""" import numpy as np import datasets _lowercase : Tuple = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the E...
49
import warnings from .generation import TFGenerationMixin class lowerCAmelCase__ ( __lowercase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transform...
612
0
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffuser...
50
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
612
0
'''simple docstring''' def __snake_case ( SCREAMING_SNAKE_CASE_ : int = 1_000_000 ) -> int: """simple docstring""" UpperCAmelCase = set(range(3 , SCREAMING_SNAKE_CASE_ , 2 ) ) primes.add(2 ) for p in range(3 , SCREAMING_SNAKE_CASE_ , 2 ): ...
51
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
612
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A = { '''configuration_perceiver''': ['''PERCEIVER_PRETR...
52
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
0
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax if i...
53
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __lowercase : Optional[Any] =TypeVar("""T""") class A ( Generic[T] ): def __init__( self: List[Any] , _lowerCAmelCase: T ) -> Unio...
54
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("T") lowerCamelCase__ = TypeVar("U") class lowerCAmelCase__ ( Generic[T, U] ): def __init__( self , a , a ) ...
612
0
from __future__ import annotations import math import random from typing import Any class UpperCAmelCase : '''simple docstring''' def __init__( self : Tuple ): __A = [] __A = 0 __A = 0 def UpperCamelCase_ ( self : Li...
55
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 @req...
612
0
'''simple docstring''' from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin ...
56
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
612
0
from __future__ import annotations def snake_case (UpperCAmelCase__ ) -> float: UpperCamelCase_: Optional[Any] = 0.00 UpperCamelCase_: List[Any] = 0 for resistor in resistors: if resistor <= 0: UpperCamelCase_: Union[str, Any] ...
57
from collections.abc import Sequence def __A(lowerCAmelCase = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _UpperCamelCase = nums[0] for i in range(1 , len(lowerCAmelCase ) ): _U...
612
0
"""simple docstring""" from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample...
58
from __future__ import annotations lowerCamelCase__ = "#" class lowerCAmelCase__ : def __init__( self ) -> None: '''simple docstring''' _UpperCamelCase = {} def A_ ( self , a ) -> None: ''...
612
0
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowerCAmelCase_ ( __a , __a ) -> Any: """simple docstring""" lowerCamelCase__: Dict =k_si...
59
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( __lowercase ): @staticmethod @abstractmethod def A_ ( a ) -> Union[str, Any]: '''simple docstring''' raise NotImplementedError() ...
612
0
import math import sys def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring""" snake_case_ : Any = '''''' try: with open(_UpperCamelCase , '''rb''' ) as binary_file: snake_case_ : Dict ...
60
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
612
0
from collections.abc import Callable def _A ( lowerCAmelCase_ : Callable[[float], float] , lowerCAmelCase_ : float , lowerCAmelCase_ : float ): """simple docstring""" lowerCAmelCase__ = a lowerCAmelCase__ = b if funct...
61
def __A(lowerCAmelCase ) -> bool: """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) _UpperCamelCase = str(lowerCAmelCase ) _UpperCamelCase = """""".join(sort...
612
0
import argparse import struct import unittest class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : int , UpperCAmelCase_ : bytes ): SCREAMING_SNAKE_CASE : Dict = data # Initialize hash values ...
62
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( __lowercase ): UpperCamelCase_ : int = (KDPMaDiscreteScheduler,) UpperCamelCase_ : Optional[int...
612
0
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling...
63
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __A(lowerCAmelCase , lowerCAmelCase ) -> np.array: """simple docstring""" _UpperCamelCase = F'{sampling_rate}' _UpperCamelCase = """1""" _UpperCam...
612
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class _lowerCamelCase ( UpperCamelCase_ ): @require_torch def UpperCamelCase_ ( self ) -> Any: # this tes...
64
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simp...
65
from __future__ import annotations def __A(lowerCAmelCase , lowerCAmelCase ) -> list[list[int]]: """simple docstring""" _UpperCamelCase = [] _UpperCamelCase = [] _UpperCamelCase = 0 _UpperCamelCase = sum(lowerCAmelCase ) create_st...
612
0
from math import isqrt def __magic_name__ ( SCREAMING_SNAKE_CASE ) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(SCREAMING_SNAKE_CASE ) + 1 ) ) def __magic_name__ ( SCREAMING_SNAKE_CASE = 10**6 ) -> int: _lowerc...
66
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
0
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 ...
67
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
612
0
from __future__ import annotations def lowercase__ ( A_: list[int] , A_: list[int] , A_: list[int] , A_: list[list[str]] , A_: int , ) -> None: """simple docstring""" __UpperCAmelCase =len(A_ ) ...
68
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittest.TestCase ): @pr...
612
0
'''simple docstring''' import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAm...
69
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
612
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils im...
70
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A(lowerCAmelCase ) -> Dict: """simple docstring""" _UpperCamelCase = os.path.join(args.tf_model_dir , """parameters.json""" ) _UpperCamelC...
612
0
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : Union[str, Any] ) -> List[str]: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_expone...
71
import warnings from .generation import TFGenerationMixin class lowerCAmelCase__ ( __lowercase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transform...
612
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_auto import TF_MODEL_F...
72
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
612
0
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self) -> Optional[Any]: SCREA...
73
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
612
0
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...t...
74
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
0
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_tor...
75
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("T") lowerCamelCase__ = TypeVar("U") class lowerCAmelCase__ ( Generic[T, U] ): def __init__( self , a , a ) ...
612
0
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar A = TypeVar("""T""") class a__ ( Generic[T] ): lowercase_ = 42 # Cache store of keys lowercase_ = 42 # References of the keys in c...
77
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 @req...
612
0
'''simple docstring''' SCREAMING_SNAKE_CASE_: List[str] ={ 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', '...
78
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
612
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class UpperCAmelCase_ ( __lowerCamelCase ): @require_torch def __UpperCAmelCase ( sel...
79
from collections.abc import Sequence def __A(lowerCAmelCase = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _UpperCamelCase = nums[0] for i in range(1 , len(lowerCAmelCase ) ): _U...
612
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __UpperCamelCase : Optional[int] = version.parse(importlib_metadata.version("""nltk""")) if NLTK_VERSION >= version.Version("""3.6.4"""): from nltk import word_t...
80
from __future__ import annotations lowerCamelCase__ = "#" class lowerCAmelCase__ : def __init__( self ) -> None: '''simple docstring''' _UpperCamelCase = {} def A_ ( self , a ) -> None: ''...
612
0
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _snake_case : Dict = logging.get_logger(__name__) _snake_case : Optional[Any] = { "vocab_file": "vo...
81
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( __lowercase ): @staticmethod @abstractmethod def A_ ( a ) -> Union[str, Any]: '''simple docstring''' raise NotImplementedError() ...
612
0
"""simple docstring""" import flax.linen as nn import jax import jax.numpy as jnp class lowercase__ ( nn.Module ): '''simple docstring''' UpperCamelCase = 42 UpperCamelCase = jnp.floataa def lowercase__ ( self : Uni...
82
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.ut...
612
0
"""simple docstring""" def snake_case_ ( A_ : int, A_ : list ): '''simple docstring''' _enforce_args(A_, A_ ) if n == 0: return 0 _lowerCamelCase : Tuple = float('''-inf''' ) for i in range(1, ...
83
def __A(lowerCAmelCase ) -> bool: """simple docstring""" if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) _UpperCamelCase = str(lowerCAmelCase ) _UpperCamelCase = """""".join(sort...
612
0
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = '''▁''' UpperCAmelCase = {'''...
84
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( __lowercase ): UpperCamelCase_ : int = (KDPMaDiscreteScheduler,) UpperCamelCase_ : Optional[int...
612
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snake_case ...
85
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __A(lowerCAmelCase , lowerCAmelCase ) -> np.array: """simple docstring""" _UpperCamelCase = F'{sampling_rate}' _UpperCamelCase = """1""" _UpperCam...
612
0
import math from collections.abc import Iterator from itertools import takewhile def __snake_case ( __UpperCamelCase : int ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or num...
86
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class UpperCamelCase_ ( enum.Enum ): ...
87
from __future__ import annotations def __A(lowerCAmelCase , lowerCAmelCase ) -> list[list[int]]: """simple docstring""" _UpperCamelCase = [] _UpperCamelCase = [] _UpperCamelCase = 0 _UpperCamelCase = sum(lowerCAmelCase ) create_st...
612
0
"""simple docstring""" import datasets from .evaluate import evaluate UpperCAmelCase = """\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={...
88
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _lowerCamelCase( unittest.TestCase ): def UpperCamelCase ( ...
89
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
612
0
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import...
90
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittest.TestCase ): @pr...
612
0
"""simple docstring""" from copy import deepcopy class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Optional[Any] ,A_ : list[int] | None = None ,A_ : int | None = None ) -> None: if arr is None and size is not None: A = size ...
91
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
612
0
'''simple docstring''' import numpy as np def _lowerCAmelCase ( __magic_name__ : str , __magic_name__ : Optional[Any] , __magic_name__ : Optional[int] , __magic_name__ : int , __magic_name__ : str ) -> List[str]: lowercase : ...
92
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A(lowerCAmelCase ) -> Dict: """simple docstring""" _UpperCamelCase = os.path.join(args.tf_model_dir , """parameters.json""" ) _UpperCamelC...
612
0
"""simple docstring""" # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __A = re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""") @total_ordering @da...
93
import warnings from .generation import TFGenerationMixin class lowerCAmelCase__ ( __lowercase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transform...
612
0
'''simple docstring''' import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # no...
94
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
612
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
95
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
612
0
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __lowerCamelCase = logging.get_logger(__name__) def a ( __UpperCAmel...
96
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
612
0
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def a ( snake_case__: int , snake_case__: int , snake_case__: int , snake_case__: int , snake_case__: int , snake_case__: int ): '''simple docstring''' #...
97
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMA...
612
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
98
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("T") lowerCamelCase__ = TypeVar("U") class lowerCAmelCase__ ( Generic[T, U] ): def __init__( self , a , a ) ...
612
0
import collections import os import re from pathlib import Path SCREAMING_SNAKE_CASE = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re.compile(r'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} SCREAMING_SNAKE_CASE ...
99
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 @req...
612
0