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
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.testing_utils import is...
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 unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, req...
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 : int ) -> bool: '''simple docstring''' if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
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 : list[list[int | float]] ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = len(matrix[0] ) SCREAMING_SNAKE_CASE = min(_UpperCamelCase , _UpperCamelCase ) for ro...
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 math def __lowerCAmelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return Fa...
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 unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from ...
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
def __lowerCAmelCase ( _UpperCamelCase : int ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE = [0] * len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = [1] * len(_UpperCamelCase ) for values in graph.values(): for i in v...
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 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
# # 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 json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : ...
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 = 1_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ =...
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 sys a_ : Tuple = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "6689664895044524452316173185640309871112...
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
def __lowerCAmelCase ( _UpperCamelCase : int ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = int(_UpperCamelCase ) if n_element < 1: SCREAMING_SNAKE_CASE = ValueError('a should be a positive number' ) raise my_error SCREAMING_SNAKE_CASE = [1] SC...
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 unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def __lowerCAmelCase ( ) -> List[Any]: '''simple docstring''' raise RuntimeError('CUDA out of memory.' ) cl...
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 subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class UpperCamelCase ( SCREAMING_SNAKE_CASE ): @require_torch def UpperCamelCase ( self : Optional[int] ): ...
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 importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from tra...
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
# # 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
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 os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn from...
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_ : Union[str, Any] = {"configuration_xglm": ["XGLM_PRET...
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 math def __lowerCAmelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' return math.sqrt(_UpperCamelCase ) * math.sqrt(_UpperCamelCase ) == num def __lowerCAmelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' SCREAMING_SNAK...
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
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : str , _UpperCamelCase : Optional[str] = None ) -> str: '''simple docstring''' if ver...
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 operator def __lowerCAmelCase ( _UpperCamelCase : list , _UpperCamelCase : bool = False , _UpperCamelCase : list | None = None ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = operator.lt if reverse else operator.gt 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
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
# 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 import os from typing import Any import requests a_ : Any = "https://api.github.com" # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user a_ : List[Any] = BASE_URL + "/user" # https://github.com/se...
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
# 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 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
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging.se...
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
# 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
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
def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : str ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) + 1 SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix ...
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 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_big_bird impo...
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 functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : List[str] = { "asapp/sew-tiny-100k": "https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json", # ...
700
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
0
'''simple docstring''' def __lowerCAmelCase ( _UpperCamelCase : List[str] ) -> Union[str, Any]: '''simple docstring''' SCREAMING_SNAKE_CASE = hex_num.strip() if not hex_num: raise ValueError('No value was passed to the function' ) SCREAMING_SNAKE_CASE = hex_num...
701
# # 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
0
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before to...
702
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
0
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, ...
703
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
0
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils ...
704
# 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
0
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class UpperCamelCase ( unittest.TestCase...
705
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
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node a_ : Any = 4 a_ : int = 3 class UpperCamelCase ( __lowerCamelCase ):...
706
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
0
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor a_ : Any = logging.get_logger(__name__) class UpperCamelCase ( UpperCAmelCase_ ): def __init__( self : Optional[Any] , *snake_case__ : Optional[int...
707
# 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
0
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 ...
708
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
0
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def __lowerCAmelCase ( *_UpperCamelCase : int ) -> Dict: '''simple docstring''' if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): SCREAMING_SNAKE_CASE ...
709
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
0
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class UpperCamelCase ( pl.LightningModule ): def __init__( self : Optional[Any] , snake_case__ : str ): """simpl...
710
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
0
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_available()...
711
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
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, ...
712
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
0
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class UpperCamelCase ( tf.keras.optimizers.schedules.LearningRateSchedule ): ...
713
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
0
from __future__ import annotations import math def __lowerCAmelCase ( _UpperCamelCase : Any , _UpperCamelCase : Optional[int] , _UpperCamelCase : Union[str, Any] , _UpperCamelCase : Tuple , _UpperCamelCase : Tuple ) -> List[Any]: '''simple docstring''' ...
714
# 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
0
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import To...
715
# 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
0
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: import jax ...
716
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
0
def __lowerCAmelCase ( _UpperCamelCase : str ) -> Union[str, Any]: '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("Program to check whether a number is a Perfect number or not...") a...
717
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
0
from __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase : float , _UpperCamelCase : float , _UpperCamelCase : float , ) -> tuple[str, float]: '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('You can...
718
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
0
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Rando...
719
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
0
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class UpperCamelCase : __UpperCamelCase =None def UpperCamelCase ( self : Optional[int] ): """simple docstring""" SCREAMING_SNAKE_CASE = self...
720
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
0
from __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int ) -> Any: '''simple docstring''' if b == 0: return (1, 0) (SCREAMING_SNAKE_CASE) = extended_euclid(__UpperCamelCase , a % b ) SCREAMING_SNAKE_CASE ...
721
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
0
def __lowerCAmelCase ( _UpperCamelCase : list[list[int]] , _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : set ) -> Tuple: '''simple docstring''' SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = len(snake_case__ ), len(grid[0] ) if ...
700
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
0
'''simple docstring''' import re def __lowerCAmelCase ( _UpperCamelCase : Any ) -> list: '''simple docstring''' return [char.split() for char in re.split(R'[^ a-z A-Z 0-9 \s]' , str_ )] def __lowerCAmelCase ( _UpperCamelCase : List[str] ) -> str: ...
701
# # 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
0
def __lowerCAmelCase ( _UpperCamelCase : list[int] , _UpperCamelCase : int ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each ar...
702
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
0
import unittest from transformers import MPNetConfig, 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 ...test_pipeline_mixin ...
703
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
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ : Any = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNo...
704
# 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
0
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from trans...
705
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
0
import os import sys import transformers a_ : Tuple = "3" print("Python version:", sys.version) print("transformers version:", transformers.__version__) try: import torch print("Torch version:", torch.__version__) print("Cuda available:", torch.cuda.is_available()) prin...
706
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : int = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } try: if not is_torch_available(): ...
707
# 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
0
def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int ) -> str: '''simple docstring''' return "\n".join( f"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number...
708
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
0
import math import qiskit def __lowerCAmelCase ( _UpperCamelCase : int = 1 , _UpperCamelCase : int = 1 , _UpperCamelCase : int = 1 ) -> qiskit.result.counts.Counts: '''simple docstring''' if ( isinstance(_lowercase , _lowercase ) or isinstance(_lowerc...
709
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
0
from math import isclose, sqrt def __lowerCAmelCase ( _UpperCamelCase : float , _UpperCamelCase : float , _UpperCamelCase : float ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = point_y / 4 / point_x SCREAMING_SNAKE_CASE = 2 * normal_gradien...
710
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
0
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...
711
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
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class UpperCamelCase ( UpperCamelCase_ ): def __init__( self : str , snake_case__ : Optional[int] , snake_case__ : Optional[int] ...
712
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
0
from __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase : List[Any] , _UpperCamelCase : Dict , _UpperCamelCase : List[str] ) -> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError('One and only...
713
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
0
from scipy.stats import spearmanr import datasets a_ : Any = "\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no correlation.\nPositive correlations im...
714
# 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
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer a_ : Opti...
715
# 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
0
def __lowerCAmelCase ( _UpperCamelCase : List[str] ) -> int: '''simple docstring''' if not isinstance(_lowerCAmelCase , _lowerCAmelCase ): raise TypeError('only integers accepted as input' ) else: SCREAMING_SNAKE_CASE = str(abs(_lowerCAmelCase ) ) SCREAMING_SNAKE_CAS...
716
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
0
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel a_ : List[str] = { '''gwf-440k''':...
717
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
0
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from ...
718
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
0
import logging import os import threading import time try: import warnings except ImportError: a_ : Tuple = None try: import msvcrt except ImportError: a_ : List[Any] = None try: import fcntl except ImportError: a_ : List[Any] = None # Back...
719
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
0
def __lowerCAmelCase ( _UpperCamelCase : int = 10 ) -> str: '''simple docstring''' if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or n < 0: raise ValueError('Invalid input' ) SCREAMING_SNAKE_CASE = 10**n SCREAMING_SNAKE_CASE = 2_84_33 * (pow(2 , ...
720
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
0
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __lowerCAmelCase ( _UpperCamelCase : str , _UpperCamelCase : str ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = list(_UpperCamelCase ) SCREAMING_SNAKE_CAS...
721
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
0
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer, ...
700
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
0
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase ( SCREAMING_SNAKE_C...
701
# # 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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Optional[Any] = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]} try: if not is_vision_avail...
702
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
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_tor...
703
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
0
import random def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = num - 1 SCREAMING_SNAKE_CASE = 0 while s % 2 == 0: SCREAMING_SNAKE_CASE = s // 2 t += 1 for _ in range(5 ): SCREAMING_SNAKE_CASE ...
704
# 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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Dict = {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() e...
705
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
0
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokenizer,...
706
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
0
import argparse import json from tqdm import tqdm def __lowerCAmelCase ( ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=lowercase_ , default='biencoder-nq-dev...
707
# 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
0
import math def __lowerCAmelCase ( _UpperCamelCase : List[Any] ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ret...
708
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
0
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...
709
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
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ : Any = logging.get_logger(__name__) a_ : Tuple = { "facebook/xmod-base": "https://huggingface.c...
710
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
0
a_ : Any = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a_ : Union[str, Any] = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a_ : List[Any] = { 0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday', 6: 'Saturday', } def ...
711
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
0
from __future__ import annotations from random import choice def __lowerCAmelCase ( _UpperCamelCase : str ) -> List[str]: '''simple docstring''' return choice(lowerCamelCase_ ) def __lowerCAmelCase ( _UpperCamelCase : list[int] , _UpperCamelCase : int )...
712
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
0
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __lowerCAmelCase ( _UpperCamelCase : str ) -> None: '''simple docstring''' SCREAMING_SNAKE_CASE = analyze_text(__snake_case ) SCREAMING_SNAKE_CASE = ...
713
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
0
import os a_ : Union[str, Any] = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} def __lowerCAmelCase ( _UpperCamelCase : str ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = 0 while index < len(a...
714
# 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
0
import itertools import string from collections.abc import Generator, Iterable def __lowerCAmelCase ( _UpperCamelCase : Iterable[str] , _UpperCamelCase : int ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE = iter(UpperCamelCase__ ) while True: SCREAMING_...
715
# 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
0
import heapq import sys import numpy as np a_ : List[Any] = tuple[int, int] class UpperCamelCase : def __init__( self : str ): """simple docstring""" SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = set() def UpperCamelCase ( ...
716
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
0
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) from transform...
717
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
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Acceler...
718
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
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_determinism, load_numpy, ...
719
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
0
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin a_ : ...
720
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
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class UpperCamelCase ( __SCREAMING_SNAKE_CASE ): __UpperCamelCase =field(def...
721
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
0
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, prepare_image_inputs if is_to...
700
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
0
'''simple docstring''' from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils ...
701
# # 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
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a_ : Optional[int] = logging.get_logger(__name__) a_ : ...
702
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
0
def __lowerCAmelCase ( _UpperCamelCase : Union[str, Any] , _UpperCamelCase : Tuple ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE = len(SCREAMING_SNAKE_CASE_ ) SCREAMING_SNAKE_CASE = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for ea...
703
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
0
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_availa...
704
# 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
0
from torch import nn def __lowerCAmelCase ( _UpperCamelCase : str ) -> Union[str, Any]: '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f"""Unsupport...
705
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
0