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
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class UpperCamelCase_ : def __init__( self , A ) -> None: UpperCAmelCase : Optional[Any] = value UpperCAmelCase : Node | None = None UpperCAmelCa...
714
'''simple docstring''' a : Tuple = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def __lowerCamelCase ( _lowercase ) -> int: UpperCAmelCase : str = 0 while number: # Increased Speed Slightly by checking ev...
672
0
from __future__ import annotations def __lowerCamelCase ( _lowercase ) -> list[int]: UpperCAmelCase : Optional[int] = 2 UpperCAmelCase : Optional[Any] = [] while i * i <= n: if n % i: i += 1 else: ...
715
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { ...
672
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class UpperCamelCase_ ( datasets.BeamBasedBuilder ): def _lowercase( ...
716
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def __lowerCamelCase ( _lowercase , _lowercase = True , _lowercase = math.inf , _lowercase = -math.inf , _lowercase = math.inf , _lowercase = ...
672
0
'''simple docstring''' import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig a : List[Any] = logging.get_logger(__name__) a : str ...
717
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : Any = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: ...
672
0
'''simple docstring''' import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a = get_tests_dir("""fixtures...
718
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a : Tuple = False class UpperCamelCase_ ( unit...
672
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoF...
719
'''simple docstring''' # 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 TensorF...
672
0
'''simple docstring''' import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_...
720
'''simple docstring''' from datetime import datetime as dt import os from github import Github a : int = [ """good first issue""", """good second issue""", """good difficult issue""", """feature request""", """new model""", """wip""", ] def __lowerCamelCase...
672
0
'''simple docstring''' import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a : str = logging.get_logger(__name__) ...
721
'''simple docstring''' 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...
672
0
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
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
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class UpperCame...
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
def __lowerCAmelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' if num < 0: return False SCREAMING_SNAKE_CASE = num SCREAMING_SNAKE_CASE = 0 while num > 0: SCREAMING_SNAKE_CASE = rev_num * 10 + (num % 10) num //= 10 return num_copy == ...
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
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup a_ : Dict = [ "kernels/rwkv/wkv_cuda.cu", "kernels/rwkv/wkv_op.cpp", "kernels/deformable_detr/ms_deform_attn.h", "kernels/deformable_detr/cuda/ms_deform_im2col_cuda.cuh", "mod...
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 flax.linen as nn import jax import jax.numpy as jnp class UpperCamelCase ( nn.Module ): __UpperCamelCase =42 __UpperCamelCase =jnp.floataa def UpperCamelCase ( self : int ): """simple docstring""" SCREAMING_SNAKE_CASE = nn.Conv( ...
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 socket def __lowerCAmelCase ( ) -> Any: '''simple docstring''' SCREAMING_SNAKE_CASE = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) SCREAMING_SNAKE_CASE = socket.gethostname() SCREAMING_SNAKE_CASE = 1_23_12 sock.connect((host, port) ) so...
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 datetime import datetime import matplotlib.pyplot as plt import torch def __lowerCAmelCase ( _UpperCamelCase : Union[str, Any] ) -> List[Any]: '''simple docstring''' for param in module.parameters(): SCREAMING_SNAKE_CASE = False def __lowerCAmelCase ( ...
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
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
# 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 ( ) -> int: '''simple docstring''' return [ a * b * (10_00 - a - b) for a in range(1 , 9_99 ) for b in range(_UpperCamelCase , 9_99 ) if (a * a + b * b == (10_00 - a - b) ** 2) ][0] if __name__ == "__main__": print(F"""{solutio...
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 collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ : Optional[Any] = logging.get_logger(__name__) a_ : int = { "andreasmadsen/efficient_mlm_m0.40":...
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
from __future__ import annotations from cmath import sqrt def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : int ) -> tuple[complex, complex]: '''simple docstring''' if a == 0: raise ValueError('Coefficient \'a\' must not be zer...
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 torch from diffusers import StableDiffusionPipeline a_ : int = "path-to-your-trained-model" a_ : List[str] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda") a_ : Dict = "A photo of sks dog in a bucket" a_ : ...
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 functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def __lowerCAmelCase ( *_UpperCamelCase : int ) -> Tuple: '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): SCREAMING_SNAKE_CASE =...
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 : int , _UpperCamelCase : bool = False ) -> bool: '''simple docstring''' if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check last digit return False if n > 3_31_70...
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 Dict, Optional import numpy as np import datasets a_ : List[Any] = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes) or multi-cla...
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 glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a_ : List[Any] = "...
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 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 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 import numpy as np from transformers import DistilBertConfig, 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 f...
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 collections import defaultdict def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = 1 SCREAMING_SNAKE_CASE = True for v in tree[start]: if v not in visited: ret += dfs(_UpperCamelCase ) if ret % 2 == 0: cut...
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 : int = 1_00_00_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = set(range(3 , _UpperCamelCase , 2 ) ) primes.add(2 ) for p in range(3 , _UpperCamelCase , 2 ): if p not in primes: continue prime...
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 argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ : Optional[Any] = argparse.ArgumentParser() parser.add_argument("--dump_path", default=None, ty...
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 dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Dict = logging.get_logger(__name__) # TODO Update this a_ : List[str] = { "facebook/esm-1b": "https://huggingface.co/f...
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 math class UpperCamelCase : def __init__( self : List[str] , snake_case__ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" SCREAMING_SNAKE_CASE = n SCREAMING_SNAKE_CASE = [ [math.inf for j in rang...
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 os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# a_ : List[Any] = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weight", "time_embedding.linear_1.weight"), ...
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
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since th...
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, is_vision_available a_ : Tuple = { "configuration_poolformer": [ "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PoolFormerConfig", "PoolFormerOnnxConfig...
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 cva import destroyAllWindows, imread, imshow, waitKey def __lowerCAmelCase ( _UpperCamelCase : Optional[Any] ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = img.shape[0], img.shape[1] # converting each pixel's color to its negati...
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 __future__ import annotations from collections import deque class UpperCamelCase : def __init__( self : Optional[Any] , snake_case__ : list[str] ): """simple docstring""" SCREAMING_SNAKE_CASE = [] self.adlist.append( {'value': '', 'ne...
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 typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable a_ : int = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]} try: if not is_v...
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 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 DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbosit...
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 manim import * class UpperCamelCase ( SCREAMING_SNAKE_CASE ): def UpperCamelCase ( self : List[str] ): """simple docstring""" SCREAMING_SNAKE_CASE = Rectangle(height=0.5 , width=0.5 ) SCREAMING_SNAKE_CASE = Rectangle(height=0.46 ...
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 os from collections import deque import torch from torch.utils.data import Dataset class UpperCamelCase ( SCREAMING_SNAKE_CASE ): def __init__( self : Tuple , snake_case__ : Any="" , snake_case__ : Tuple="train" ): """simple docstring""" ...
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 unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import tor...
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 Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase ( SCR...
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 ....utils import logging a_ : Union[str, Any] = logging.get_logger(__name__) class UpperCamelCase ( SCREAMING_SNAKE_CASE ): def __init__( self : str , snake_case__ : List[Any] , snake_case__ : Tuple=None , snake_case__ : Opt...
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 Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configurat...
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 __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase : list , _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : int ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE , SCREAMING...
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 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
# 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 time a_ : str = list[tuple[int, int]] a_ : Optional[int] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, ...
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 LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
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 ) -> 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
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 typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaT...
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 unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inp...
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
def __lowerCAmelCase ( _UpperCamelCase : int ) -> list[int]: '''simple docstring''' if num <= 0: raise ValueError('Input must be a positive integer' ) SCREAMING_SNAKE_CASE = [True] * (num + 1) SCREAMING_SNAKE_CASE = 2 while p * p <= num: if primes[p]: for i i...
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 ...configuration_utils import PretrainedConfig from ...utils import logging a_ : int = logging.get_logger(__name__) a_ : str = { "facebook/s2t-small-librispeech-asr": ( "https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json" ), ...
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 math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging a_ : Optional[Any] = logging.get_logger(__name__) class UpperCamelCase ( SCREAMING_SNAKE_CASE ): __Up...
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 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_ : Any = "▁" a_ : List[str] = {"vocab_file": "spiece.model"} 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
import numpy class UpperCamelCase : def __init__( self : Union[str, Any] , snake_case__ : numpy.ndarray , snake_case__ : numpy.ndarray ): """simple docstring""" SCREAMING_SNAKE_CASE = input_array # Random initial weights are assigned ...
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 time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder a_ : List[str] = "__DUMMY_TRANSFORMERS_USER__" a_ : str = "Dummy User" a_ : List[str] = "hf_hZEmnoOEYISjr...
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 functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Optional[Any] = logging.get_logger(__name__) a_ : List[Any] = { "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-base-960h/resolve/...
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 collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, DPR...
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 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
# 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_ : Optional[int] = logging.get_logger(__name__) a_ : Any = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/c...
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 warnings from functools import wraps from typing import Callable def __lowerCAmelCase ( _UpperCamelCase : Callable ) -> Callable: '''simple docstring''' @wraps(_UpperCamelCase ) def _inner_fn(*_UpperCamelCase : List[str] , **_UpperCamelCase : List[str] ): warnings.w...
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 typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever a_ : Union[str, Any] = logging.getLogger(__name__) class UpperCamelCase ( SCREAMING_SNAKE_CASE ): def _...
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 copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import ca...
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
a_ : Union[str, Any] = "Tobias Carryer" from time import time class UpperCamelCase : def __init__( self : Optional[Any] , snake_case__ : int , snake_case__ : Dict , snake_case__ : Dict , snake_case__ : Optional[int]=int(ti...
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
# 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
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 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
# 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 typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph class...
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 os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging a_ : Union[str, Any] ...
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 MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
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 datetime def __lowerCAmelCase ( _UpperCamelCase : str ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE = { '0': 'Sunday', '1': 'Monday', '2': 'Tuesday', '3': 'Wednesday', '4': 'Thursday', '5': 'Friday', '6': 'Saturd...
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 dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smartaa_timesteps, sma...
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 : List[str] ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE = len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = sum(_UpperCamelCase ) SCREAMING_SNAKE_CASE = [[False for x in range(s + 1 )] for y in range(n + 1...
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 shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTok...
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 pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging a_ : List[str] = logging.get_logger(__name__) def __lowerCAmelCase ( _Upper...
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 Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPENA...
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
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : int = logging.get_logger(__name__) a_ : Any = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", # See all ViT MSN models at https://h...
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 Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ : Optional[int] = logging.get_logger(__name__) a_ : Union[str, Any] = { "facebook/xmod-base": "h...
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 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
# 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 re from filelock import FileLock try: import nltk a_ : List[str] = True except (ImportError, ModuleNotFoundError): a_ : Dict = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) def __...
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 collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase ( yaml.SafeLoader ): def UpperCamelCase ( self : List[str] , snake_case__ : int ): """simple docstring""" SCREAMING_SNAKE_CASE ...
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 dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Option...
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 import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTes...
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 functools import lru_cache @lru_cache def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' if num < 0: raise ValueError('Number should not be negative.' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import...
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
from __future__ import annotations from typing import Any def __lowerCAmelCase ( _UpperCamelCase : list[Any] ) -> None: '''simple docstring''' create_state_space_tree(_UpperCamelCase , [] , 0 ) def __lowerCAmelCase ( _UpperCamelCase : list[Any] , ...
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 sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class UpperCamelCase : def __init__( self : Dict , snake_case__ : int , s...
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 diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class UpperCamelCase ( SCREAM...
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 os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class UpperCamelCase ( unittest.TestCase ): def UpperCamelCase ( self : Dict ): ...
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 json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers 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 os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and no...
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 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
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
def __lowerCAmelCase ( _UpperCamelCase : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE = set() # Replace all the whitespace in our sentence SCREAMING_SNAKE_CASE = input_str.replace(' ' , '' )...
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 os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import requir...
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 def __lowerCAmelCase ( _UpperCamelCase : int | float | str , _UpperCamelCase : int | float | str ) -> list[str]: '''simple docstring''' if nth_term == "": return [""] SCREAMING_SNAKE_CASE = int(_UpperCamelCase ) SCREAMING_SNAKE_CA...
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 hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils imp...
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
def __lowerCAmelCase ( _UpperCamelCase : Optional[int] , _UpperCamelCase : Any , _UpperCamelCase : Tuple , _UpperCamelCase : List[Any] , _UpperCamelCase : Any , _UpperCamelCase : Union[str, Any] ) -> Any: '''simple docstring''' if index == r: ...
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 logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow a_ : Tuple = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ "text-classification", ...
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 logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) a_ : Optional[int] = logging.getLogger(__name__...
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 math 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 SchedulerMixin, SchedulerOutput class UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): __Upp...
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 dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class UpperCamelCase ( SCREAMING_SNAKE_CASE ): __UpperCame...
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