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 os def __lowerCamelCase ( ) -> str: with open(os.path.dirname(a_ ) + """/grid.txt""" ) as f: lowerCamelCase_ : Union[str, Any] = [] # noqa: E741 for _ in range(20 ): l.append([int(a_ ) for x in f.readline().split()] ) lowerCa...
278
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn...
698
0
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging ...
664
"""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 .tokenization_dpr import DPR...
698
0
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import loggin...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Optional[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-bas...
698
0
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging SCREAMING_SNAKE_CASE_: Tuple =logging.get_logger(__name__) SCREAMING_SNAKE_CASE_: Optional[int] ={ "t5-small": "https://hugg...
78
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
698
0
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_av...
315
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : List[Any] = { "uw-madison/mra-base-512-4": "https://huggingface.co/uw-madison/mra-base-512-...
698
0
def __UpperCAmelCase ( lowerCamelCase_ : list[list] ) -> list[list]: """simple docstring""" SCREAMING_SNAKE_CASE_ : Any = current_set.copy() for row_index, row in enumerate(a_ ): SCREAMING_SNAKE_CASE_ : Dict = row[0] for colu...
105
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : str = logging.get_logger(__name__) lowerCamelCase__ : List[str] = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/...
698
0
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset 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 ImageProcessin...
275
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, Stabl...
698
0
from torch import nn class lowerCamelCase_ ( nn.Module ): def __init__( self , lowerCamelCase_ , lowerCamelCase_ ) -> Union[str, Any]: """simple docstring""" super().__init__() _UpperCamelCase = class_size _UpperCamelCase = em...
147
"""simple docstring""" def __A ( a_ : list , a_ : int = 0 )-> list: '''simple docstring''' SCREAMING_SNAKE_CASE : int = length or len(a_ ) SCREAMING_SNAKE_CASE : List[Any] = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]:...
698
0
"""simple docstring""" from itertools import product def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" _UpperCAmelCase = sides_number _UpperCAmelCase = max_face_number * dice_number _UpperCAmelCase = [0] * (max_total + 1) _UpperCAmelCase ...
657
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase__( _UpperCAmelCa...
698
0
"""simple docstring""" import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging a_ = logging.get_logger(__name__) a_ = {"vocab_file": ...
76
"""simple docstring""" import qiskit def __A ( a_ : int , a_ : int )-> qiskit.result.counts.Counts: '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q regist...
698
0
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to...
479
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow...
698
0
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 diffusers.pipelines.stable_diffusion_safe ...
278
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
698
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule __magic_name__ : List[Any] ={"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys __magic_name__ : Tuple =_LazyModule(__na...
664
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Any =...
698
0
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @re...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : str = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/main...
698
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 cl...
78
"""simple docstring""" # using dfs for finding eulerian path traversal def __A ( a_ : Dict , a_ : int , a_ : str , a_ : Optional[Any]=None )-> List[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[Any] = (path or []) + [u] for v in gr...
698
0
def _a ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> float: """simple docstring""" lowerCamelCase__ : Optional[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def ...
315
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokeni...
698
0
def __UpperCAmelCase ( lowerCamelCase_ : int ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
105
"""simple docstring""" from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase__( _UpperCAmelCase ): '''simple docstring''' def __lowerCAmelCase ( self :Union[str, Any] ) -> str: '''simple doc...
698
0
'''simple docstring''' from heapq import heappop, heappush import numpy as np def UpperCamelCase_ ( A__ : np.ndarray , A__ : tuple[int, int] , A__ : tuple[int, int] , A__ : bool , ): '''simple docstring''' ...
275
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def __A ( a_ : Callable[[int | float], int | float] , a_ : int | float , a_ : int | float , a_ : int = 1_00 , )-> float: '''simple docstring''' SCREAMIN...
698
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __lowerCAmelCase = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
147
"""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 # ...
698
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_trust_remot...
657
"""simple docstring""" def __A ( a_ : int = 10 , a_ : int = 10_00 , a_ : bool = True )-> int: '''simple docstring''' assert ( isinstance(a_ , a_ ) and isinstance(a_ , a_ ) and isinstance(a_ , a_ ) ), "Invalid type of value(s) specified to funct...
698
0
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_devi...
76
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, ...
698
0
_a : Tuple = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []} _a : List[Any] = ["a", "b", "c", "d", "e"] def UpperCamelCase__ ( _A: Dict , _A: Any , _A: List[Any] ): '''simple docstring''' __lowerCame...
479
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase__ : Union[str, Any] = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", ...
698
0
import math def __lowerCamelCase ( A__ : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # ...
278
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn...
698
0
'''simple docstring''' from __future__ import annotations from cmath import sqrt def __snake_case ( lowerCamelCase_ : int , lowerCamelCase_ : int , lowerCamelCase_ : int ): '''simple docstring''' if a == 0: raise ValueError("Coefficient \'a\' must...
664
"""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 .tokenization_dpr import DPR...
698
0
import qiskit def lowerCAmelCase__(__snake_case ,__snake_case ) -> qiskit.result.counts.Counts: '''simple docstring''' lowerCamelCase__ = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register lowerCamelCase__ ...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Optional[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-bas...
698
0
'''simple docstring''' from math import isqrt, loga def lowerCAmelCase_ ( snake_case_ : int ) -> list[int]: '''simple docstring''' UpperCAmelCase_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is...
78
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
698
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transformers.utils im...
315
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : List[Any] = { "uw-madison/mra-base-512-4": "https://huggingface.co/uw-madison/mra-base-512-...
698
0
from pathlib import Path import numpy as np from PIL import Image def __UpperCAmelCase ( lowerCamelCase_ : np.ndarray ) -> np.ndarray: """simple docstring""" SCREAMING_SNAKE_CASE_ : str = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2_9_8_9...
105
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : str = logging.get_logger(__name__) lowerCamelCase__ : List[str] = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/...
698
0
'''simple docstring''' __A : Dict = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) f...
275
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, Stabl...
698
0
import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version __lowerCAmelCase = get_lo...
147
"""simple docstring""" def __A ( a_ : list , a_ : int = 0 )-> list: '''simple docstring''' SCREAMING_SNAKE_CASE : int = length or len(a_ ) SCREAMING_SNAKE_CASE : List[Any] = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]:...
698
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise Optio...
657
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase__( _UpperCAmelCa...
698
0
"""simple docstring""" import numpy as np import qiskit def __UpperCAmelCase ( __UpperCamelCase = 8 , __UpperCamelCase = None ): __lowercase : Union[str, Any] = np.random.default_rng(seed=a_ ) # Roughly 25% of the qubits will contribute to the key...
76
"""simple docstring""" import qiskit def __A ( a_ : int , a_ : int )-> qiskit.result.counts.Counts: '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q regist...
698
0
def UpperCamelCase__ ( _A: int ): '''simple docstring''' if not isinstance(a_ , a_ ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) __lowerCamelCase = str(a_ ) __lowerCamelCase = ''''''.j...
479
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow...
698
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, DP...
278
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
698
0
'''simple docstring''' __magic_name__ : Dict ="Tobias Carryer" from time import time class UpperCamelCase_ : """simple docstring""" def __init__( self : str , _lowerCamelCase : str , _lowerCamelCase : List[str] , _lowerCame...
664
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Any =...
698
0
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def lowerCAmelCase__(__snake_cas...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : str = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/main...
698
0
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from...
78
"""simple docstring""" # using dfs for finding eulerian path traversal def __A ( a_ : Dict , a_ : int , a_ : str , a_ : Optional[Any]=None )-> List[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[Any] = (path or []) + [u] for v in gr...
698
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers....
315
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokeni...
698
0
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modelin...
105
"""simple docstring""" from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase__( _UpperCAmelCase ): '''simple docstring''' def __lowerCAmelCase ( self :Union[str, Any] ) -> str: '''simple doc...
698
0
'''simple docstring''' import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def ...
275
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def __A ( a_ : Callable[[int | float], int | float] , a_ : int | float , a_ : int | float , a_ : int = 1_00 , )-> float: '''simple docstring''' SCREAMIN...
698
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCamelCase_ : def __init__( self , lowerCamelCase_ ) -> Tuple: """simple docstring""" _UpperCamelCase = data _UpperCamelCase = [0x6745_2301, 0x...
147
"""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 # ...
698
0
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataS...
657
"""simple docstring""" def __A ( a_ : int = 10 , a_ : int = 10_00 , a_ : bool = True )-> int: '''simple docstring''' assert ( isinstance(a_ , a_ ) and isinstance(a_ , a_ ) and isinstance(a_ , a_ ) ), "Invalid type of value(s) specified to funct...
698
0
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) ...
76
"""simple docstring""" import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, ...
698
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_...
479
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase__ : Union[str, Any] = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", ...
698
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCamelCase ( A__ : np.ndarray , A__ : np.ndarray ) -> float: return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(a_ , a_ ) ) )...
278
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn...
698
0
'''simple docstring''' import argparse import os import re import packaging.version __magic_name__ : Any ="examples/" __magic_name__ : Optional[Any] ={ "examples": (re.compile(R'^check_min_version\(\"[^\"]+\"\)\s*$', re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R'^__vers...
664
"""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 .tokenization_dpr import DPR...
698
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json", } class __A ( _UpperCAmelCase ): '...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Optional[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-bas...
698
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy SCREAMING_SNAKE_CASE_: str =logging.get_logger(...
78
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
698
0
from __future__ import annotations def _a ( UpperCAmelCase ) -> list[int]: # This function is recursive """simple docstring""" lowerCamelCase__ : Union[str, Any] = len(a_ ) # If the array contains only one element, we return it (it's the stop condition of # re...
315
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : List[Any] = { "uw-madison/mra-base-512-4": "https://huggingface.co/uw-madison/mra-base-512-...
698
0
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) def __UpperCAmelCase ( lowerCamelCase_ : Union[tf.Tensor, np.ndarray] ) -> List[int]: ...
105
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : str = logging.get_logger(__name__) lowerCamelCase__ : List[str] = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/...
698
0
'''simple docstring''' from __future__ import annotations import numpy as np def UpperCamelCase_ ( A__ : np.ndarray ): '''simple docstring''' lowerCAmelCase_ : Tuple = np.shape(a_ ) if rows != columns: lowerCAmelCase_ : Di...
275
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, Stabl...
698
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCamelCase_ ( _UpperCAmelCase ): __lowercase ...
147
"""simple docstring""" def __A ( a_ : list , a_ : int = 0 )-> list: '''simple docstring''' SCREAMING_SNAKE_CASE : int = length or len(a_ ) SCREAMING_SNAKE_CASE : List[Any] = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]:...
698
0
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow c...
657
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase__( _UpperCAmelCa...
698
0
"""simple docstring""" import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_...
76
"""simple docstring""" import qiskit def __A ( a_ : int , a_ : int )-> qiskit.result.counts.Counts: '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q regist...
698
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) _a : str = {"configuration_beit": ["BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BeitConfig", "BeitOnnxConfig"]} tr...
479
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow...
698
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_environ...
278
"""simple docstring""" from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
698
0
'''simple docstring''' import numpy as np class UpperCamelCase_ : """simple docstring""" def __init__( self : Optional[int] ) -> Union[str, Any]: __magic_name__ = (0, 0) __magic_name__ = None __magic_name__ = 0 ...
664
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamelCase__ : Any =...
698
0
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : str = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/main...
698
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, InputFeatures,...
78
"""simple docstring""" # using dfs for finding eulerian path traversal def __A ( a_ : Dict , a_ : int , a_ : str , a_ : Optional[Any]=None )-> List[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[Any] = (path or []) + [u] for v in gr...
698
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _A : Any = logging.get_log...
315
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokeni...
698
0
import datasets _UpperCAmelCase = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n ...
699
def __UpperCamelCase (lowerCAmelCase : list[int] ) -> int: if not numbers: return 0 if not isinstance(lowerCAmelCase, (list, tuple) ) or not all( isinstance(lowerCAmelCase, lowerCAmelCase ) for number in numbers ): raise ValueError('numbers m...
699
1
class _UpperCAmelCase : '''simple docstring''' def __init__( self : Dict , UpperCamelCase__ : Tuple ): A = val A = None A = None def UpperCamelCase ( self : Optional[Any] , UpperCamelCase__ : ...
699
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, InputFeatures, SingleSentenceClassificat...
699
1
def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int, lowerCAmelCase : int ) -> int: if exponent == 1: return base if exponent % 2 == 0: A = _modexpt(lowerCAmelCase, exponent // 2, lowerCAmelCase ) % modulo_value ...
699
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "microsoft/biogpt": "https://huggingface.co/microsoft/biogpt/resolve/main/config.json", # See all BioGPT models at https://huggin...
699
1
from ....configuration_utils import PretrainedConfig from ....utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ...
699
import sys def __UpperCamelCase (lowerCAmelCase : Dict ) -> Dict: A = len(lowerCAmelCase ) A = [[0 for x in range(lowerCAmelCase )] for x in range(lowerCAmelCase )] A = [[0 for x in range(lowerCAmelCase )] for x in range(lowerCAmelCase )] for chai...
699
1
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _UpperCAmelCase = l...
699
from math import isqrt def __UpperCamelCase (lowerCAmelCase : int ) -> bool: return all(number % divisor != 0 for divisor in range(2, isqrt(lowerCAmelCase ) + 1 ) ) def __UpperCamelCase (lowerCAmelCase : int = 10**6 ) -> int: A = 0 A = 1 ...
699
1
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class...
699
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor _UpperCAmelCase = logging.get_logger(__name__) class _UpperCAmelCase ( __lowercase ): '''simple docstring''' def __init__( self : List[str] , *UpperCame...
699
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dis...
699
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 @maybe_allow_in_graph class ...
699
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegmentation, ...
699
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "vocab_file": "vocab.json", "tokenizer_config_file": "to...
699
1
import requests from bsa import BeautifulSoup def __UpperCamelCase (lowerCAmelCase : str, lowerCAmelCase : dict ) -> str: A = BeautifulSoup(requests.get(lowerCAmelCase, params=lowerCAmelCase ).content, 'html.parser' ) A = soup.find('div', attrs={'c...
699
# 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 ap...
699
1
import numpy as np _UpperCAmelCase = [ ["a", "b", "c", "d", "e"], ["f", "g", "h", "i", "k"], ["l", "m", "n", "o", "p"], ["q", "r", "s", "t", "u"], ["v", "w", "x", "y", "z"], ] class _UpperCAmelCase : '''simple docstring''' def __init__( self : str ...
699
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging _UpperCAmelCase = logging.get_logger(__name__) def __UpperCamelCase (lowerCAmelCase : List[str] ) -> Dict: A = r'...
699
1
from __future__ import annotations _UpperCAmelCase = 1.6_021E-19 # units = C def __UpperCamelCase (lowerCAmelCase : float, lowerCAmelCase : float, lowerCAmelCase : float, ) -> tuple[str, float]: if (conductivity, electron_conc, mobility).count(0 ) != ...
699
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _UpperCAmelCase : '''simple docstring''' def __init__( self : List[Any] , UpperCamelCase__ : Collection[float] | None = None ): if...
699
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExtractio...
699
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.uti...
699
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCAmelCase = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "tokenization_gp...
699
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelCase ( __lowercase ): '''simple docstring...
699
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _UpperCAmelCase ( __lowercase ): '''simple docstring''' SCREAMING_SNAKE_CASE : Dict = ['''image_processor''', '''tokenizer'''] SCREAMING_SNAKE_CA...
699
def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int ) -> str: return "\n".join( f'''{number} * {i} = {number * i}''' for i in range(1, number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10))
699
1
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=__lowercase ): '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[Any] = ['''flax''', '''transformers'''] def __init__( self : Optional[Any] , *UpperCamelCase_...
699
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class _UpperCAmelCase ( __lowercase , __lowercase ): ...
699
1
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __UpperCamelCase () -> Dict: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with...
699
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 _UpperCAmelCase = 0b10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_...
699
1
import math import os import sys def __UpperCamelCase (lowerCAmelCase : str ) -> str: A = '' try: with open(lowerCAmelCase, 'rb' ) as binary_file: A = binary_file.read() for dat in data: A = f'''{dat:...
699
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "post_extract_proj": "feature_projecti...
699
1
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
699
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _UpperCAmelCase = TypeVar("T") class _UpperCAmelCase ( Generic[T] ): '''simple docstring''' def __init__( self : Tuple , UpperCamelCase__ : T )...
699
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "microsoft/biogpt": "https://huggingface.co/microsoft/biogpt/resolve/main/config.json", # See all BioGPT models at https://huggin...
699
from __future__ import annotations import math def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int, lowerCAmelCase : bool, lowerCAmelCase : list[int], lowerCAmelCase : float ) -> int: if depth < 0: raise ValueError('Depth can...
699
1
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 diffusers.pipelines.stable_diffusion_safe i...
699
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequenceCl...
699
1
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 @maybe_allow_in_graph class ...
699
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase = {"configuration_xglm": ["XGLM_PRETRAINED_C...
699
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequenceCl...
699
def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int ) -> Optional[int]: if b == 0: return 1 if (b % 2) == 0: return actual_power(lowerCAmelCase, int(b / 2 ) ) * actual_power(lowerCAmelCase, int(b / 2 ) ) else: r...
699
1
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_trust_remote_code from ...image_p...
699
def __UpperCamelCase (lowerCAmelCase : list[int] ) -> int: if not numbers: return 0 if not isinstance(lowerCAmelCase, (list, tuple) ) or not all( isinstance(lowerCAmelCase, lowerCAmelCase ) for number in numbers ): raise ValueError('numbers m...
699
1
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _UpperCAmelCase ( __lowercase...
699
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, InputFeatures, SingleSentenceClassificat...
699
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.uti...
699
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "microsoft/biogpt": "https://huggingface.co/microsoft/biogpt/resolve/main/config.json", # See all BioGPT models at https://huggin...
699
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try: i...
699
import sys def __UpperCamelCase (lowerCAmelCase : Dict ) -> Dict: A = len(lowerCAmelCase ) A = [[0 for x in range(lowerCAmelCase )] for x in range(lowerCAmelCase )] A = [[0 for x in range(lowerCAmelCase )] for x in range(lowerCAmelCase )] for chai...
699
1
from collections import namedtuple _UpperCAmelCase = namedtuple("from_to", "from_ to") _UpperCAmelCase = { "cubicmeter": from_to(1, 1), "litre": from_to(0.0_0_1, 1_000), "kilolitre": from_to(1, 1), "gallon": from_to(0.0_0_4_5_4, 2_6_4.1_7_2), "cubicyard": from_to(0....
699
from math import isqrt def __UpperCamelCase (lowerCAmelCase : int ) -> bool: return all(number % divisor != 0 for divisor in range(2, isqrt(lowerCAmelCase ) + 1 ) ) def __UpperCamelCase (lowerCAmelCase : int = 10**6 ) -> int: A = 0 A = 1 ...
699
1
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _UpperCAmelCase ( pl.LightningModule ): '''simple docstring''' def __init__( self : List[str] , UpperCamelCase__ ...
699
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor _UpperCAmelCase = logging.get_logger(__name__) class _UpperCAmelCase ( __lowercase ): '''simple docstring''' def __init__( self : List[str] , *UpperCame...
699
1
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class _UpperCAmelCase ( datasets.BuilderConfig ): '''simple docstring''' SCREAMING_SNAKE_CASE : ...
699
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 @maybe_allow_in_graph class ...
699
1
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def __UpperCamelCase (lowerCAmelCase : Dict, lowerCAmelCase : str, lowerCAmelCase : Tuple, lowerCAmelCase : str=5 ) -> List[Any]: # Adapted from https://github.com/pytorch/fairseq/bl...
699
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "vocab_file": "vocab.json", "tokenizer_config_file": "to...
699
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _UpperCAmelCase = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConfig", "SwiftFormerOnnxConf...
699
# 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 ap...
699
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logg...
699
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging _UpperCAmelCase = logging.get_logger(__name__) def __UpperCamelCase (lowerCAmelCase : List[str] ) -> Dict: A = r'...
699
1
import random def __UpperCamelCase (lowerCAmelCase : list, lowerCAmelCase : Union[str, Any] ) -> tuple: A , A , A = [], [], [] for element in data: if element < pivot: less.append(lowerCAmelCase ) elif element > ...
699
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _UpperCAmelCase : '''simple docstring''' def __init__( self : List[Any] , UpperCamelCase__ : Collection[float] | None = None ): if...
699
1
from math import sqrt def __UpperCamelCase (lowerCAmelCase : int ) -> bool: assert isinstance(lowerCAmelCase, lowerCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" A = True # 0 and 1 are none primes. if number <= 1: ...
699
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.uti...
699
1
from pathlib import Path import numpy as np from PIL import Image def __UpperCamelCase (lowerCAmelCase : np.ndarray ) -> np.ndarray: A , A , A = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2989 * r + 0.5870 * g + 0.1140 * b def __UpperCamelCase (...
699
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelCase ( __lowercase ): '''simple docstring...
699
1
def __UpperCamelCase (lowerCAmelCase : int ) -> "list[int]": if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) A = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 A = 1 if upper_limit > 0: A...
699
def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int ) -> str: return "\n".join( f'''{number} * {i} = {number * i}''' for i in range(1, number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10))
699
1
def __UpperCamelCase (lowerCAmelCase : int, lowerCAmelCase : int ) -> Optional[int]: if b == 0: return 1 if (b % 2) == 0: return actual_power(lowerCAmelCase, int(b / 2 ) ) * actual_power(lowerCAmelCase, int(b / 2 ) ) else: r...
699
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class _UpperCAmelCase ( __lowercase , __lowercase ): ...
699
1
import os from distutils.util import strtobool def __UpperCamelCase (lowerCAmelCase : List[str], lowerCAmelCase : List[Any] ) -> int: for e in env_keys: A = int(os.environ.get(lowerCAmelCase, -1 ) ) if val >= 0: return val ...
699
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 _UpperCAmelCase = 0b10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_...
699
1
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def __UpperCamelCase () -> Optional[int]: ...
699
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "post_extract_proj": "feature_projecti...
699
1
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __UpperCamelCase (lowerCAmelCase : str, lowerCAmelCase : List[Any], ...
699
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _UpperCAmelCase = TypeVar("T") class _UpperCAmelCase ( Generic[T] ): '''simple docstring''' def __init__( self : Tuple , UpperCamelCase__ : T )...
699
1