code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
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 ap...
673
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
1
import os def __lowerCAmelCase ( ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = os.path.dirname(os.path.realpath(_UpperCamelCase ) ) SCREAMING_SNAKE_CASE = os.path.join(_UpperCamelCase , 'triangle.txt' ) with open(_UpperCamelCase ) as f: SCREAMING_SN...
673
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
673
1
import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load_metric from .utils impor...
673
# 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...
673
1
def __lowerCAmelCase ( _UpperCamelCase : int ) -> str: '''simple docstring''' if isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('...
673
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a_ : List[str] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize a_ : Di...
673
1
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.utils import logging...
673
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
1
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTes...
673
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __lowerCAmelCase ( _UpperCamelCase : List[str] , _UpperCamelCase : Union[str, Any] , _UpperCamelCase : Tuple ) -> Union[str, Any]: '''simple docstri...
673
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
1
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor import ...
673
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
1
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : str ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = [] for i in range(len(_UpperCamelCase ) - pat_len + 1 ): SCREAMING_SNAKE_CASE = ...
673
def __lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = str(_UpperCamelCase ) SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 for i in list_...
673
1
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppTokenizer...
673
# 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...
673
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : Tuple = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class UpperCamelCase ( SCREAMING...
673
# 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 # - generate model_cards - usef...
673
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
673
import random def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> dict: '''simple docstring''' SCREAMING_SNAKE_CASE = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than ...
673
1
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline a_ : Any = { "n_samples": 64, "horizon": 32, "num_inference_steps": 20, "n_guide_steps": 2, # can set to 0 for faster sampling, does not use value network "scale_grad_by_std": T...
673
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Dict = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available()...
673
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: f...
673
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 from...
673
import heapq import sys import numpy as np a_ : Optional[int] = tuple[int, int] class UpperCamelCase : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ...
673
1
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto import T...
673
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
673
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import...
673
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() a_ : List[Any] = logging.get_logger("transformers.models.speecht5") def __lowerCAmelCase ( _UpperCamelCase : Tuple , _U...
673
1
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def __lowerCAmelCase ( _UpperCamelCase : Any ) -> Tuple: '''simple docstring''' return x + 2 class UpperCamelCase ( unittest.TestCase ): d...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
1
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline a_ : Union[str, Any] = logging.get_logger(__name__) class UpperCamel...
673
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-t...
673
1
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow a_ : Dict = False class UpperCamelCase ( unittest.TestCase ): def UpperCamelCase ( sel...
673
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : Optional[Any] = {"vocab_file": "vocab.j...
673
1
def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int ) -> int: '''simple docstring''' while a != 0: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = b % a, a return b def __lowerCAmelCase ( _UpperCamelCase : int , _UpperC...
673
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = abs(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 while n > 0: res += n % 10 n //= 10 return res def __lowerCAmelCase ( _UpperCamelCase : int ) -...
673
1
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_available ...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
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 applica...
673
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
1
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available from...
673
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
673
1
def __lowerCAmelCase ( ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] SCREAMING_SNAKE_CASE = 6 SCREAMING_SNAKE_CASE = 1 SCREAMING_SNAKE_CASE = 19_01 SCREAMING_SNAKE_CASE = ...
673
# 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...
673
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCamelCase ( SCREAMING_SNAKE_CASE ): @staticmethod @abstractmethod def UpperCamelCase ( snake_case__ : ArgumentParser ): """simple docstring""" raise NotImplementedError() ...
673
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a_ : List[str] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize a_ : Di...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : int = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], "proce...
673
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
1
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
673
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
1
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, ) a_ : str = { "configuration_albert": ["ALBERT_PRETRAI...
673
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
1
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
1
import math def __lowerCAmelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_UpperCamelCase ) def __lowerCAmelCase ( _UpperCamelCase : ...
673
def __lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = str(_UpperCamelCase ) SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 for i in list_...
673
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a_ : Dict = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "feature_extraction_encodec": ["...
673
# 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...
673
1
import math def __lowerCAmelCase ( _UpperCamelCase : int = 1_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = sum(i * i for i in range(1 , n + 1 ) ) SCREAMING_SNAKE_CASE = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_su...
673
# 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 # - generate model_cards - usef...
673
1
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available, ...
673
import random def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> dict: '''simple docstring''' SCREAMING_SNAKE_CASE = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than ...
673
1
from __future__ import annotations from math import gcd def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int = 2 , _UpperCamelCase : int = 1 , _UpperCamelCase : int = 3 , ) -> int | None: '''simple docstring''' if num < 2: raise Value...
673
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...
673
1
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : List[str] ) -> Tuple: '''simple docstring''' SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorte...
673
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: f...
673
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 da...
673
import heapq import sys import numpy as np a_ : Optional[int] = tuple[int, int] class UpperCamelCase : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ...
673
1
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTester fro...
673
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available a_ : Optional[Any] = { "configuration_audio_spectrogram_transformer": [ "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "AS...
673
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() a_ : List[Any] = logging.get_logger("transformers.models.speecht5") def __lowerCAmelCase ( _UpperCamelCase : Tuple , _U...
673
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ : Tuple = logging.get_logger(__name__) a_ : Tuple = { "roberta-base": "https://huggingface.co/ro...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
1
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' if n == 1 or not isinstance(_UpperCamelCase , _UpperCamelCase ): return 0 elif n == 2: return 1 else: SCREAMING_SNAKE_CASE = [0, 1] for i in range(2 , n + 1 ): sequence.append...
673
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-t...
673
1
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class UpperCamelCase : def __init__( self : Dict , snake_case__ : Tuple=2 , snake_case__ : int=3 , snake_case__ : Any=6_4 ...
673
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : Optional[Any] = {"vocab_file": "vocab.j...
673
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a_ : Tuple = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
673
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = abs(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 while n > 0: res += n % 10 n //= 10 return res def __lowerCAmelCase ( _UpperCamelCase : int ) -...
673
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() a_ : ...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
1
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class UpperCamelCase : def __init__(...
673
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : Optional[int] = "▁" a_ : ...
673
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
673
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __lowerCAmelCase ( ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = ArgumentParser( description=( ...
673
# 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...
673
1
from datetime import datetime as dt import os from github import Github a_ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __lowerCAmelCase ( ) -> Optional[int]: '...
673
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a_ : List[str] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize a_ : Di...
673
1
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
1
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __lowerCAmelCase ( _UpperCamelCase : str ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE = [ 'encoder.version', 'decoder...
673
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
1
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Train...
673
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Any = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]} try: if not is_vision_available(): ...
673
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
1
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokeni...
673
def __lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = str(_UpperCamelCase ) SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 for i in list_...
673
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 import...
673
# 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...
673
1
import heapq import sys import numpy as np a_ : Optional[int] = tuple[int, int] class UpperCamelCase : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ...
673
# 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 # - generate model_cards - usef...
673
1
import argparse from collections import defaultdict import yaml a_ : Tuple = "docs/source/en/_toctree.yml" def __lowerCAmelCase ( _UpperCamelCase : int ) -> Optional[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE = defaultdict(_UpperCamelCase ) for doc ...
673
import random def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> dict: '''simple docstring''' SCREAMING_SNAKE_CASE = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than ...
673
1
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
673
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...
673
1
from __future__ import annotations import math def __lowerCAmelCase ( _UpperCamelCase : int ) -> list[int]: '''simple docstring''' if num <= 0: SCREAMING_SNAKE_CASE = f"""{num}: Invalid input, please enter a positive integer.""" raise ValueError(_UpperCamelCase ) SCREAMI...
673
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: f...
673
1
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : str = " " ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = 0 for index, char in enumerate(_UpperCamelCase ): if char == separator: split_words.append(strin...
673
import heapq import sys import numpy as np a_ : Optional[int] = tuple[int, int] class UpperCamelCase : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ...
673
1
import random def __lowerCAmelCase ( _UpperCamelCase : List[Any] , _UpperCamelCase : Optional[int] , _UpperCamelCase : str ) -> Any: '''simple docstring''' SCREAMING_SNAKE_CASE = a[left_index] SCREAMING_SNAKE_CASE = left_index + 1 for j in range(lef...
673
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
673
1
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() a_ : List[Any] = logging.get_logger("transformers.models.speecht5") def __lowerCAmelCase ( _UpperCamelCase : Tuple , _U...
673
1
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWit...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
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...
673
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-t...
673
1
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device a_ : int = False class UpperCamelCase ( unittest.TestCase ): ...
673
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : Optional[Any] = {"vocab_file": "vocab.j...
673
1
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging a_ : str = ...
673
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = abs(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 while n > 0: res += n % 10 n //= 10 return res def __lowerCAmelCase ( _UpperCamelCase : int ) -...
673
1
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. a_ : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generation and must be sma...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
1
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Path from urllib.p...
673
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import Interp...
673
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
673
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCondi...
673
# 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...
673
1
def __lowerCAmelCase ( _UpperCamelCase : int = 2_00_00_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = [0 for i in range(n + 1 )] SCREAMING_SNAKE_CASE = 1 SCREAMING_SNAKE_CASE = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i...
673
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a_ : List[str] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize a_ : Di...
673
1
import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() a_ : Optional[int] = loggi...
673
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
1
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray , _UpperCamelCase : np.ndarray , _UpperCamelCase : float = 1e-12 , _UpperCamelCase : int = 1_00 , ) -> tuple[float, np.ndarray]: '''simple docstring''' assert np.shape(_UpperCamelCas...
673
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : Any = {"processing_layoutxlm": ["LayoutXLMProcessor"]} try: if n...
673
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCamelCase ( unittest.TestCase , SCREAMING_SNAKE_CASE ): def UpperCamelCase ( self : List[Any] ): """simple docstring""" SCREAMING_SNAKE_CASE = load...
673
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from t...
673
def __lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = str(_UpperCamelCase ) SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 for i in list_...
673
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class UpperCamelCase ( unittest.TestCase ): __UpperCamelCase =inspect.getfile(a...
673
# 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...
673
1
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline a_ : List[str] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argument("--dpm", action="stor...
673
# 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 # - generate model_cards - usef...
673
1
from __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : List[Any] , _UpperCamelCase : Dict , _UpperCamelCase : str ) -> Union[str, Any]: # noqa: E741 '''simple docstring''' while r - l > 1: SCREAMING_SNAKE_CASE ...
673
import random def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> dict: '''simple docstring''' SCREAMING_SNAKE_CASE = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than ...
673
1
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() a_ : List[Any] = logging.get_logger("transformers.models.speecht5") def __lowerCAmelCase ( _UpperCamelCase : Tuple , _U...
673
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a_ : int = { "configuration_biogpt": ["BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BioGptConfig"], "tokenization_biogpt": ["BioGptTokenizer"], } try:...
673
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: f...
673
1
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 ...onnx import OnnxCo...
673
import heapq import sys import numpy as np a_ : Optional[int] = tuple[int, int] class UpperCamelCase : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ...
673
1
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
673
1
from functools import reduce a_ : str = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452445231617...
673
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() a_ : List[Any] = logging.get_logger("transformers.models.speecht5") def __lowerCAmelCase ( _UpperCamelCase : Tuple , _U...
673
1
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __lowerCAmelCase ( _UpperCamelCase : D...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
1
from __future__ import annotations a_ : Optional[Any] = list[list[int]] # assigning initial values to the grid a_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3...
673
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-t...
673
1
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTe...
673
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : Optional[Any] = {"vocab_file": "vocab.j...
673
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Any = logging.get_logger(__name__) a_ : Any = { "naver-clova-ix/donut-base": "https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json", # See all Donut models at https...
673
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = abs(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 while n > 0: res += n % 10 n //= 10 return res def __lowerCAmelCase ( _UpperCamelCase : int ) -...
673
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
1
from typing import TYPE_CHECKING from ..utils import _LazyModule a_ : Union[str, Any] = { "config": [ "EXTERNAL_DATA_FORMAT_SIZE_LIMIT", "OnnxConfig", "OnnxConfigWithPast", "OnnxSeq2SeqConfigWithPast", "PatchingSpec", ], "convert": ["export", "v...
673
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
673
1
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters a_ : Dict = (720, 1280) # Height, Width a_ : Tuple = (0.4, 0.6) # if height or width lower than this scale, drop it. a_ : str = 1 / 100 a...
673
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
673
1
import copy 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 ..auto import CONFIG_MAPPING a_ : int = logging.get_logger(__name__) a_ ...
673
# 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...
673
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
673
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a_ : List[str] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokenize a_ : Di...
673
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Any = { "configuration_bigbird_pegasus": [ "BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP", "BigBirdPegasusConfig", "BigBirdPegasusOnnxConfig", ...
673
import numpy as np def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase ( _UpperCamelCase : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sig...
673
1
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transformers import DPRContex...
673
from ....configuration_utils import PretrainedConfig from ....utils import logging a_ : Any = logging.get_logger(__name__) a_ : Dict = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
673
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer a_ : int = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"} a_ : int ...
673
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod(...
673
1
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
673
1
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCase ( SCREAMING_SNAKE_CASE , unittest.TestCase ): __UpperCamelCase =CTRLTokenizer ...
673
def __lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = str(_UpperCamelCase ) SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 for i in list_...
673
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def __lowerCAmelCase ...
673
# 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...
673
1
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __lowerCAmelCase ( _UpperCamelCase : float , _UpperCamelCase : float , _UpperCamelCase : bool = False ) -> list[float]: '''simple docstring'...
673
# 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 # - generate model_cards - usef...
673
1