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 unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _lowercase : Optional[Any] = get_tests_dir("fixtures/test_sentencepiece_wit...
641
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
1
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _lowercase : List[str] = numpy.array([0, 0]) _lowercase : Tuple = numpy.array([0.5, 0.8_66_02_54]) _lowercase : Optional[int] = ...
641
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .benchma...
641
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
641
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
1
import qiskit def _lowerCAmelCase ( UpperCamelCase__: int = 2 ) -> qiskit.result.counts.Counts: """simple docstring""" A = qubits # Using Aer's simulator A = qiskit.Aer.get_backend("""aer_simulator""" ) # Creating a Quantum Circuit acting on the q...
641
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
1
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _lowercase : Dict = logging.get_logger("transformers.models.speecht5") def _lowerCAmelCase ( UpperCamelCase__: Optional[int] , ...
641
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
1
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from d...
641
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.modeli...
641
1
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
1
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
1
def _lowerCAmelCase ( UpperCamelCase__: list , UpperCamelCase__: list , UpperCamelCase__: int , UpperCamelCase__: int , UpperCamelCase__: int ) -> int: """simple docstring""" if index == number_of_items: return 0 A = 0 A ...
641
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = 'encoder-decoder' lowerCAm...
641
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
1
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets _lowercase : List[Any] = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wang, Alex ...
641
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
1
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function _lowercase : Any = 1.0_5457_1817E-34 # unit of ℏ : J * s _lowercase : Union[str, Any] = 3E8 # unit of c : m * s^-1 def ...
641
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
1
_lowercase : Any = "Input must be a string of 8 numbers plus letter" _lowercase : Any = "TRWAGMYFPDXBNJZSQVHLCKE" def _lowerCAmelCase ( UpperCamelCase__: str ) -> bool: """simple docstring""" if not isinstance(UpperCamelCase__ , UpperCamelCas...
641
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
1
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = 'EncodecFeatureExtractor' lowerCAmelCase = ('T5Tok...
641
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
641
1
# 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 # # Unless required by applic...
641
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
1
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation _lo...
641
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
1
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup _lowercase : Any = [ "kernels/rwkv/wkv_cuda.cu", "kernels/rwkv/wkv_op.cpp", "kernels/deformable_detr/ms_deform_attn.h", "kernels/deformable_detr/cuda/ms_deform_im2col_cuda.cuh", ...
641
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
1
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor _lowercase : int = logging.get_logger(__name__) class _UpperCamelCase ( __snake_case ): """simple docstring""" def __init__( self , *a__ ...
641
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
1
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel fr...
641
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
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 ...
641
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
1
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 _lowercase : Optional[int] = logging.get_logger(__name__)...
641
# 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 # # Unless required by applic...
641
1
def _lowerCAmelCase ( UpperCamelCase__: int , UpperCamelCase__: int , UpperCamelCase__: list[list[int]] ) -> int: """simple docstring""" def update_area_of_max_square(UpperCamelCase__: int , UpperCamelCase__: int ) -> int: # BASE CASE if row >= rows or c...
641
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
1
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxModelTest...
641
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class _UpperCamelCase ( unittest.Te...
641
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
1
# 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 a...
641
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
1
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="""session""" ) def _lowerCAmelCase ( ) -> Dict: """simpl...
641
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
1
from __future__ import annotations def _lowerCAmelCase ( UpperCamelCase__: list[float] , UpperCamelCase__: Union[str, Any] ) -> Optional[Any]: """simple docstring""" print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(UpperCamelCase__ ): print...
641
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
1
import string def _lowerCAmelCase ( UpperCamelCase__: str ) -> str: """simple docstring""" A = """""" for i in sequence: A = ord(UpperCamelCase__ ) if 65 <= extract <= 90: output += chr(1_55 - extract ) elif 97 <= extract <= 1_22: outpu...
641
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.modeli...
641
1
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py _lowercase : Optional[Any] = "." if __name__ == "__main__": _lowercase : str = os.path.join(REPO_PATH, "utils/documentat...
641
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
1
from __future__ import annotations def _lowerCAmelCase ( UpperCamelCase__: list[int] ) -> list[int]: """simple docstring""" if len(UpperCamelCase__ ) == 0: return array A , A = min(UpperCamelCase__ ), max(UpperCamelCase__ ) # Compute the variabl...
641
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor...
641
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
1
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAMES, Prop...
641
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
1
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger _lowercase : str = get_logger(__name__) class _UpperCamelCase ( enum.Enum ): """simple docstring""" lowerCAmelCase = 'al...
641
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
1
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf, ...
641
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
1
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
1
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from...
641
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
641
1
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers.models...
641
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
1
import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ConfigTester from ...te...
641
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
1
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @require_torch...
641
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : Dict = logging.get_logger(__name__) _lowercase : int = { "google/bigbird-roberta-base...
641
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
1
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
641
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
1
def _lowerCAmelCase ( UpperCamelCase__: int , UpperCamelCase__: int ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def _lowerCAmelCase ( ) -> None: """simple docstring""" assert and_gate(0 , 0 ) == 0 asse...
641
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
1
def _lowerCAmelCase ( UpperCamelCase__: int , UpperCamelCase__: int ) -> int: """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def _lowerCAmelCase ( ) -> None: """simple docstring""" assert or_gate(0 , 0 ) == 0 asser...
641
# 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 # # Unless required by applic...
641
1
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 import torch.nn as nn ...
641
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
1
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
1
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 _lowerCAmelCase ( UpperCamelCase__: Tuple , UpperCamelCase__: Optional[...
641
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
1
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
641
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
1
from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask fro...
641
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowercase : int = logging.get_logger(__name__) _lowercase : Tuple = { "t5-small": "https://huggingface.co/t5-small/res...
641
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : Dict = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: if not...
641
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.modeli...
641
1
from sklearn.metrics import fa_score import datasets _lowercase : Union[str, Any] = "\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" _lowercase : Any = "\nArgs:\n ...
641
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
1
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute...
641
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
1
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, ...
641
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...u...
641
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
1
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.te...
641
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
1
from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : str = {"processing_wav2vec2_with_lm": ["Wav2Vec2ProcessorWithLM"]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys _lowercase : List[Any] ...
641
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
1
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _UpperCamelCase : """simple docstring""" def __init__( self , a__ , a__ , a__ ) -> int: if dst_width < 0 or dst_height < 0: raise ValueError("""Destination width/height ...
641
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
1
import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class _UpperCamelCase ( ...
641
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
641
1
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 OptionalDependencyNotAvailable: from ...utils....
641
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
1
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tenso...
0
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCa...
1
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
0
from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=_A): """simple docstring""" a__ : Any = ["torch", "transformers", "onnx"] def __init__( self : Union[str, Any] , *__lowerCAmelCase : Union[str, Any] , **__lower...
2
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
0
'''simple docstring''' import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def A_( A : str , A : List[Any] , A : Optional[Any]): UpperCamelCase = AutoConfig.from_pretrained(A) UpperC...
3
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
0
"""simple docstring""" # Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - ...
4
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
0
'''simple docstring''' def A (__lowerCamelCase :int ): _lowerCAmelCase = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def A (__lowerCamelCase :int = 5000 ): _lowerCAmelCase = [(i * (3 * i - 1)) // 2 for i in range(1 , __lowerCamelCase )] fo...
5
# 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 # # Unless required by applic...
641
0
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list[float] , UpperCamelCase__: list[float] ): SCREAMING_SNAKE_CASE__ = sorted(numsa + numsa ) SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = divmod(len(UpperC...
6
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
0
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated a = collections.namedtuple('''_Datasets'''...
7
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional @dataclass class SCREAMING_SNAKE_CASE : lowerCAmelCase = field( default='''codeparrot/codeparrot''' , metadata={'''help''': '''Model name or path of model...
8
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = {'''voca...
9
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
import math class lowerCAmelCase_ : def __init__( self : Tuple , _A : int=0 ): # a graph with Node 0,1,...,N-1 _UpperCamelCase = n _UpperCamelCase = [ [math.inf for j in range(0 , _A )] for i in range(0 , _A...
10
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
'''simple docstring''' from math import factorial class __A : '''simple docstring''' def __init__(self , A , A ) -> str: """simple docstring""" _a = real if isinstance(A , A ): _a = [1] * rank else:...
11
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
lowerCamelCase__ : Optional[Any] = """0.18.2""" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, ...
12
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.modeli...
641
0
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prep...
13
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
import math from collections.abc import Iterator from itertools import takewhile def __UpperCAmelCase ( __a : int ) -> bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or n...
14
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
def UpperCamelCase ( __magic_name__ : int , __magic_name__ : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) lowercase__ = str(bin(__magic_name__ ) )[2:] # remove the lea...
15
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
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 requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
0
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 lowerCamelCase_ ( datasets.BuilderConfig ): _lowercase : Optional[datasets.Features] = None ...
17
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __a(SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : bool = False ): ...
18
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, res...
19
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
from __future__ import annotations from PIL import Image # Define glider example _lowerCAmelCase: Dict = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, ...
20
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
641
0
class __A : def __init__( self :List[str] , __snake_case :str , __snake_case :Optional[Any] ): '''simple docstring''' __magic_name__ : int =name __magic_name__ : Optional[int] =val def __str__( self ...
21
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
'''simple docstring''' def snake_case_ (UpperCamelCase : str ): '''simple docstring''' _a = [int(UpperCamelCase ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(UpperCamelCase ) == 4 and all(0 <= int(UpperCamelCase ) <=...
22
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configurat...
23
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
0
'''simple docstring''' from __future__ import annotations UpperCAmelCase_ : Union[str, Any] = [True] * 1_0_0_0_0_0_1 UpperCAmelCase_ : Optional[Any] = 2 while i * i <= 1_0_0_0_0_0_0: if seive[i]: for j in range(i * i, 1_0_0_0_0_0_1, i): UpperCAmelCase_ ...
24
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
641
0
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a_ = TypeVar('KEY') a_ = TypeVar('VAL') @dataclass(frozen=__A , slots=__A ) class _UpperCamelCase ( Generic[KEY, VAL] ): '''simple docstring''' ...
25
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
0
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_visio...
26
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
0
def __lowerCAmelCase( _SCREAMING_SNAKE_CASE ) -> list: """simple docstring""" _A = False while is_sorted is False: # Until all the indices are traversed keep looping _A = True for i in range(0 , len(_SCREAMING...
27
# 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 # # Unless required by applic...
641
0
'''simple docstring''' import os from collections import deque import torch from torch.utils.data import Dataset class _a ( SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self, A="", A="train" ): ...
28
_lowercase : 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, ) from .data_loader import skip_first_batche...
641
0
"""simple docstring""" from __future__ import annotations def lowercase ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ): if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: raise ValueError('''daily_int...
29
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __a( unittest.TestCase ): """simple docstring""" lowerCAmelCase = JukeboxTokenizer lowerCAmelCase = { '''artist''': '''Zac Brown Band''', ...
30
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCamelCase__ : Any = TypeVar('KEY') lowerCamelCase__ : str = TypeVar('VAL') @dataclass(frozen=_SCREAMING_SNAKE_CASE , slots=_SCREAMING_SNAK...
31
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
import argparse import os import re UpperCAmelCase_ = "src/diffusers" # Pattern that looks at the indentation in a line. UpperCAmelCase_ = re.compile(r"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. UpperCAmelCase_ = re.compile(r"^\s*\"([^\"]+)\":") # Patter...
32
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
import torch from diffusers import StableDiffusionPipeline lowerCamelCase__ : Any = """path-to-your-trained-model""" lowerCamelCase__ : List[str] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") lowerCamelCase...
33
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
"""simple docstring""" from math import pow def __snake_case ( _lowercase ,_lowercase ,_lowercase ,_lowercase ,_lowercase ,): """simple docstring""" if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. ...
34
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.modeli...
641
0
def a ( A__ , A__ ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE__ : int = len(A__ ) SCREAMING_SNAKE_CASE__ : int = [] for i in range(len(A__ ) - pat_len + 1 ): SCREAMING_SNAKE_CASE__ ...
35
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _A ( snake_case ): '''simple docstring''' def __init__( self ,SCREA...
36
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase : Optional[Any] = get_tests_dir...
37
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
0
'''simple docstring''' import re from filelock import FileLock try: import nltk A_ : Optional[int] = True except (ImportError, ModuleNotFoundError): A_ : List[Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) ...
38
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
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 ..t...
39
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0