code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
from __future__ import annotations def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' lowercase = sorted(numsa + numsa ) lowercase , lowercase = divmod(len(lowerCAmelCase__ ) , 2 ) if mod == 1: return al...
101
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : List[str] = {"""vocab_file""": """v...
102
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
42
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__ : List[str] = { '''facebook/data2vec-text-base''': '''https://...
103
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_vision_encoder_decoder''': ['''VisionEncoderDecoderConf...
104
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase ( _lowerCamelCase ): def lowerCamelCase ( self , lowerCAmelCase_ ): ""...
42
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEF...
105
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput __UpperCamelCase : Optional[Any] = '''scheduler_conf...
106
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
def __magic_name__ ( A : list ): '''simple docstring''' def merge(A : list, A : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right ...
107
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Any = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCLI...
42
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple def a__ ( SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : float ): '''simple docstring''' lowerCAmelCase : Opti...
108
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _snake_case ( UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : int...
109
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __UpperCAmelCase ( _lowerCamelCase ): @require_torch def lowerCamelCase ...
42
0
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 lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = {'vocab_f...
110
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
0
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __UpperCamelCase : List[str] = "src/transformers" # Th...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2Stru...
42
0
'''simple docstring''' import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowercase__ ( ctypes.Structure ): # _fields is a specific attr expected by ctypes lowercase__ = [(""...
83
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase : list[int] = [ord(letter)...
42
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 1_000_000 ) -> int: _snake_case = limit + 1 _snake_case = [0] * limit for first_term in range(1 , __A ): for n in range(__A , __A , __A ): _snake_case = first_term + n / first_term if commo...
42
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization_xlm": ["XLMTokenizer"], } t...
87
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization...
42
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLNetC...
317
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging lowerCAmelCase_ = logging.get_logger(__name__) def snake_case( __magic_name__ , __magic_name_...
308
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase : Optional[Any] = False class __...
42
0
"""simple docstring""" def a__ ( snake_case__ ) -> int: if not isinstance(__A , __A ): lowerCamelCase = F'Input value of [number={number}] must be an integer' raise TypeError(__A ) if number < 1: lowerCamelCase = F'Input value of ...
291
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 100 ) -> int: _snake_case = n * (n + 1) * (2 * n + 1) / 6 _snake_case = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solution() = }''')
42
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2StructConfig", ...
311
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVeca...
42
0
"""simple docstring""" import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_lowerCamel...
108
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/...
42
0
"""simple docstring""" a = range(2, 20 + 1) a = [10**k for k in range(ks[-1] + 1)] a = {} def _snake_case ( _snake_case : Dict , _snake_case : List[str] , _snake_case : Dict , _snake_case : int ) -> Any: ...
315
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
42
0
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, I...
310
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
42
0
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.scheduling_...
182
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowercase : List[str] = logging.get_logger("transformers.models.speecht5") def SCREAMING_SNAKE_CASE__ ( ...
42
0
'''simple docstring''' from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": snake_case_ : Tuple = input('Enter image url: ').strip() print(F"""Downloading image from {url} ...""") snake_case_ : Optional[int] = BeautifulSoup(request...
83
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
"""simple docstring""" 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 __SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) __SCREAMING_S...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
42
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Layout...
87
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class snake_case : '''simple docstring''' def __init__( self : Optional[Any] , lowerCAmelCase : List[str]) -> int: """simple docstring""" ...
317
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase ( _lowerCamelCase ): def lowerCamelCase ( self , lowerCAmelCase_ ): ""...
42
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _A ( _lowerCamelCase ): _UpperCamelCase : int = ['''image_processor''', '''tokenizer'''] _UpperCamelCase : int = '''CLIPImageProcessor''' _UpperCa...
308
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
"""simple docstring""" def a__ ( snake_case__ , snake_case__ , snake_case__ ) -> list: lowerCamelCase = len(__A ) lowerCamelCase = [[0] * n for i in range(__A )] for i in range(__A ): lowerCamelCase = y_points[i] for...
291
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")): raise OptionalDependenc...
311
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Any = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCLI...
42
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : str = 1_0_0 ): '''simple docstring''' lowerCAmelCase : int = n * (n + 1) * (2 * n + 1) / 6 lowerCAmelCase : Any = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squar...
108
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
0
"""simple docstring""" import argparse import json import os import re from collections import OrderedDict from os.path import basename, dirname import fairseq import torch from fairseq import hub_utils from fairseq.data.dictionary import Dictionary from transformers import FSMTConfig, FSMTForConditionalGenerat...
315
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __UpperCAmelCase ( _lowerCamelCase ): @require_torch def lowerCamelCase ...
42
0
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from...
310
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
0
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2Stru...
42
0
'''simple docstring''' def A__ ( UpperCAmelCase_ = 1_0_0_0 ): return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
83
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase : list[int] = [ord(letter)...
42
0
"""simple docstring""" import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 1_000_000 ) -> int: _snake_case = limit + 1 _snake_case = [0] * limit for first_term in range(1 , __A ): for n in range(__A , __A , __A ): _snake_case = first_term + n / first_term if commo...
42
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test_...
87
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization...
42
0
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blanks.csv"""] ) @pytest....
317
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { "facebook/xmod-base": "https://hugg...
308
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase : Optional[Any] = False class __...
42
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase : Tuple = { "configuration_ctrl": ["CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP", "CTRLConfig"], "tokenization_...
291
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 100 ) -> int: _snake_case = n * (n + 1) * (2 * n + 1) / 6 _snake_case = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solution() = }''')
42
0
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowercase ( __magic_name__ ): # picklable for mu...
311
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVeca...
42
0
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex lowerCAmelCase__ = logging.getLogger(__name__) class SCREAMING_SNAKE_CASE__ : """simple...
108
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/...
42
0
"""simple docstring""" from __future__ import annotations def _snake_case ( _snake_case : Dict ) -> int: '''simple docstring''' for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing t...
315
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
42
0
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDe...
310
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
42
0
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowercase__ ( _lowerCamelCase): UpperCamelCase_ ...
182
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowercase : List[str] = logging.get_logger("transformers.models.speecht5") def SCREAMING_SNAKE_CASE__ ( ...
42
0
'''simple docstring''' import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def A__ ( UpperCAmelCase_ = 3 ): if isinstance(__A , __A ): raise TypeError('number of qubits must be a integer.' ...
83
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
"""simple docstring""" import os import re import shutil import sys import tempfile import unittest import black __SCREAMING_SNAKE_CASE : Dict = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies #...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
42
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available()...
87
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, re...
317
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase ( _lowerCamelCase ): def lowerCamelCase ( self , lowerCAmelCase_ ): ""...
42
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_ver...
308
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
"""simple docstring""" from copy import deepcopy class __magic_name__ : '''simple docstring''' def __init__( self , _a = None , _a = None ): """simple docstring""" if arr is None and size is not None: lowerCamelCase = siz...
291
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate...
311
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Any = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCLI...
42
0
"""simple docstring""" import os lowerCAmelCase__ = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000} def a__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : Optional[Any] = 0 lowerCAmelCase : ...
108
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
0
"""simple docstring""" from math import pow def _snake_case ( _snake_case : Dict , _snake_case : Tuple , _snake_case : Tuple , _snake_case : Optional[int] , _snake_case : Optional[int] , ) -> tuple[int, int]: ...
315
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __UpperCAmelCase ( _lowerCamelCase ): @require_torch def lowerCamelCase ...
42
0
import re def _A ( _lowercase ) -> str: """simple docstring""" if len(re.findall('[ATCG]' , __A ) ) != len(__A ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) ...
310
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
0
import datasets from .evaluate import evaluate __UpperCamelCase : List[str] = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMN...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2Stru...
42
0
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transform...
83
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase : list[int] = [ord(letter)...
42
0
"""simple docstring""" import os def _a ( _SCREAMING_SNAKE_CASE = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(__A ) , __A ) ) as input_file: snake_case_ = [ [int(__A ) for element in line.split(""",""" )] for l...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 1_000_000 ) -> int: _snake_case = limit + 1 _snake_case = [0] * limit for first_term in range(1 , __A ): for n in range(__A , __A , __A ): _snake_case = first_term + n / first_term if commo...
42
0
import tensorflow as tf from ...tf_utils import shape_list class snake_case_ ( tf.keras.layers.Layer ): def __init__( self : Dict , lowercase_ : Optional[Any] , lowercase_ : Union[str, Any] , lowercase_ : List[Any] , lowercase...
87
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization...
42
0
def lowercase ( SCREAMING_SNAKE_CASE__ : str ) -> str: _snake_case : int = 1 _snake_case : Dict = 2 while i * i <= n: _snake_case : Union[str, Any] = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i +...
317
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase...
308
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase : Optional[Any] = False class __...
42
0
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) class ...
291
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 100 ) -> int: _snake_case = n * (n + 1) * (2 * n + 1) / 6 _snake_case = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solution() = }''')
42
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @r...
311
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVeca...
42
0
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer...
108
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/...
42
0
"""simple docstring""" import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class lowercase_ ( _lowerCamelCase ): '''simple docstring''' @require_torch def lowerCA...
315
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
42
0
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torc...
310
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
42
0
from __future__ import annotations def A ( _lowercase ): SCREAMING_SNAKE_CASE : List[Any] = len(__A ) # We need to create solution object to save path. SCREAMING_SNAKE_CASE : Dict = [[0 for _ in range(__A )] for _ in range(__A ...
182
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowercase : List[str] = logging.get_logger("transformers.models.speecht5") def SCREAMING_SNAKE_CASE__ ( ...
42
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils...
83
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __A (unittest.TestCase): '''simple docstrin...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
42
0
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__name__) Uppe...
87
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
def lowercase ( SCREAMING_SNAKE_CASE__ : int ) -> List[Any]: _snake_case : Union[str, Any] = [0] * len(__A ) _snake_case : str = [] _snake_case : Optional[Any] = [1] * len(__A ) for values in graph.values(): for i in values: indegree[i] +=...
317
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase ( _lowerCamelCase ): def lowerCamelCase ( self , lowerCAmelCase_ ): ""...
42
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, S...
308
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
"""simple docstring""" import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noq...
291
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
'''simple docstring''' 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 ( AlbertToken...
311
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Any = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCLI...
42
0
"""simple docstring""" from __future__ import annotations def a__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' lowerCAmelCase : int = list(range(len(__...
108
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
0
"""simple docstring""" import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import requi...
315
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __UpperCAmelCase ( _lowerCamelCase ): @require_torch def lowerCamelCase ...
42
0
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets __snake_case = datasets.logging.get_logger(__name__) __snake_case = "\\n@InProceedings{moosavi2019minimum,\n auth...
310
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
0
from __future__ import annotations def A ( _lowercase , _lowercase , _lowercase ): if (voltage, current, resistance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if resistance < 0: raise ValueError('''Resistance cannot ...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2Stru...
42
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeat...
83
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase : list[int] = [ord(letter)...
42
0
"""simple docstring""" 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_avail...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 1_000_000 ) -> int: _snake_case = limit + 1 _snake_case = [0] * limit for first_term in range(1 , __A ): for n in range(__A , __A , __A ): _snake_case = first_term + n / first_term if commo...
42
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerConfig", "Blip2VisionConfig...
87
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization...
42
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a__ = { "configuration_blip": [ "BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "BlipConfig", ...
317
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
from __future__ import annotations from collections.abc import MutableSequence class _A : def __init__( self : List[str] , _A : str , _A : Union[str, Any] ) -> Optional[Any]: """simple docstring""" if len(l...
308
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowercase : Optional[Any] = False class __...
42
0
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __magic_name__ ( unittest.TestCase ): '''simple docstring''' ...
291
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A = 100 ) -> int: _snake_case = n * (n + 1) * (2 * n + 1) / 6 _snake_case = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solution() = }''')
42
0
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration a : Any = 5_00_00 a : str = 50_00 a : List[Any] = os.path.split(__file__) a : List[str] = os.path.join(RESULTS_BASEPATH, "results",...
311
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVeca...
42
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : List[Any] ): '''simple docstring''' lowerCAmelCase : Tuple = [] lowerCAmelCase : Tuple = [] lowerCAmelCase : Any = { "^": 3, "*": 2, "/":...
108
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/...
42
0
"""simple docstring""" import math def _snake_case ( _snake_case : Optional[int] ) -> list: '''simple docstring''' _A = [True] * n _A = False _A = False _A = True for i in range(3 , int(...
315
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfor...
42
0
__snake_case = "Input must be a string of 8 numbers plus letter" __snake_case = "TRWAGMYFPDXBNJZSQVHLCKE" def _A ( _lowercase ) -> bool: """simple docstring""" if not isinstance(__A , __A ): __UpperCamelCase = ...
310
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
42
0
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path __UpperCamelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) __UpperCamelCase : list[int] = [ord(letter) for l...
182
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowercase : List[str] = logging.get_logger("transformers.models.speecht5") def SCREAMING_SNAKE_CASE__ ( ...
42
0
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A__ ( UpperCAmelCase_ ): # vision encoder if "img_encoder.pos_embed" in name: _UpperCamelCase : Union[...
83
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
"""simple docstring""" from __future__ import annotations __SCREAMING_SNAKE_CASE : Union[str, Any] = 10 def _a ( _SCREAMING_SNAKE_CASE ) -> list[int]: snake_case_ = 1 snake_case_ = max(__A ) while placement <= max_digit: # declar...
347
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
42
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class snake_case_ (...
87
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
from __future__ import annotations def lowercase ( SCREAMING_SNAKE_CASE__ : int ) -> list[int]: # This function is recursive _snake_case : List[Any] = len(__A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
317
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCAmelCase ( _lowerCamelCase ): def lowerCamelCase ( self , lowerCAmelCase_ ): ""...
42
0
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...ut...
308
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
"""simple docstring""" import os import unicodedata 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 SPIECE_UNDERLINE, logging lowerCAmelCase : Dict ...
291
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
'''simple docstring''' import argparse import logging import pickle from collections import Counter logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO ) a : Union[str, Any] = logging.getLogger(__name__) if __name__ ==...
311
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : Any = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCLI...
42
0
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", ...
108
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
0
"""simple docstring""" import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...te...
315
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __UpperCAmelCase ( _lowerCamelCase ): @require_torch def lowerCamelCase ...
42
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer __snake_case = logging.get_logger(__name__) __snake...
310
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
0
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transforme...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase : List[str] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2Stru...
42
0
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel snake_case_ : List[str] ...
83
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase : list[int] = [ord(letter)...
42
0