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 typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ : Union[str, Any] = { 'configuration_llama': ['LLAMA_PRE...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : str = logging.get_logger(__name__) lowerCAmelCase__ : ...
632
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
1
"""simple docstring""" def a_ ( lowerCamelCase ): UpperCAmelCase__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def a_ ( lowerCamelCase ): UpperCAmelCase__ = 0 while number > 0: UpperCAmelCase__ = number %...
632
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
1
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : Any = { 'configuration_mctct': ['MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MCTCTConfig'], 'feature_extraction_mctct': ['MCTCTFeatu...
632
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor lowerCAmelCase__ : Any = logging.get_logger(__name__) class snake_case ( __UpperCAmelCase ): """simple docstring""" def __init__( ...
632
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
1
"""simple docstring""" from math import ceil def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = list(range(0 , lowerCamelCase ) ) UpperCAmelCase__ = [item for sublist in list(device_map.values() ) for item in sublist] # Duplicate check ...
632
"""simple docstring""" # 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 # #...
632
1
"""simple docstring""" from copy import deepcopy class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[int] | None = None ,lowerCamelCase__ : int | None = None ): if arr is None and size is not None: ...
632
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
1
"""simple docstring""" import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_stag...
632
"""simple docstring""" import warnings from functools import wraps from typing import Callable def a_ ( lowerCamelCase ): @wraps(lowerCamelCase ) def _inner_fn(*lowerCamelCase , **lowerCamelCase ): warnings.warn( (f'''\'{fn.__name__}\' is experimental and might ...
632
1
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_c...
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
"""simple docstring""" import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.nump...
632
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_co...
632
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : int = { 'configuration_upernet': ['UperNetConfig'], } try: if not is_torch_available(): raise OptionalDependencyN...
632
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def a_ ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def a_ ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] lowerCAme...
632
1
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformer...
632
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): """simple docstring""" snake_case__ = [("size...
632
1
"""simple docstring""" def a_ ( lowerCamelCase = 5_0 ): UpperCAmelCase__ = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ...
632
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as ...
632
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ : int = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['...
632
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase__ : Union[str, Any] = False class ...
632
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCAmelCase__ : int = logging.get_logger(__name__) # pylint: disable=invalid-name class s...
632
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
632
1
"""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__ : Optional[Any] = logging.get_logger(__name__) class snake_case : ...
632
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spe...
632
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ : Tuple = logging.get_logger(__name__) lowerCAmelCase__ : List[Any] ...
632
"""simple docstring""" import socket def a_ ( ): UpperCAmelCase__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase__ = socket.gethostname() UpperCAmelCase__ = 1_2_3_1_2 sock.connect((host, port) ) sock.send(b'Hello server!'...
632
1
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def a_ ( lowerCamelCase ): UpperCAmelCase__ = test_file.split(os.path.sep ) if compo...
632
"""simple docstring""" from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[list[int]] ): UpperCAmelCase__ = TypeError( 'Matrices must be formed from a list of z...
632
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = len(lowerCamelCase ) print('The following activities are selected:' ) # The first activity is always selected UpperCAmelCase__ = 0 print(lowerCamelCase , end=','...
632
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ : int = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['...
632
1
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
"""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 lowerCAmelCase__ : Optional[int] = False class snake_case ( ...
632
1
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCAmelCase__ : str = 10 def a_ ( lowerCamelCase , lowerCamelCase ...
632
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_number...
632
1
"""simple docstring""" lowerCAmelCase__ : str = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) lowerCAmelCase__ : ...
632
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneratio...
632
1
"""simple docstring""" def a_ ( lowerCamelCase ): if not isinstance(lowerCamelCase , lowerCamelCase ) or number < 0: raise ValueError('Input must be a non-negative integer' ) UpperCAmelCase__ = 0 while number: # This way we arrive at next set bit (next 1) ...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset lowerCAmelCase__ : Tuple = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4:...
632
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
1
"""simple docstring""" def a_ ( lowerCamelCase ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence UpperCAmelCase__ = gray_code_sequence_string(lowerCamelCa...
632
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
1
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def a_ ( ): UpperCAmelCase__ = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) UpperCAmelCase__ = parser.add_subparsers(help='diffusers-...
632
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dp...
632
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
1
"""simple docstring""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) lowerCAmelCas...
632
"""simple docstring""" # 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 # #...
632
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : str = logging.get_logger(...
632
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
1
"""simple docstring""" import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datas...
632
"""simple docstring""" import warnings from functools import wraps from typing import Callable def a_ ( lowerCamelCase ): @wraps(lowerCamelCase ) def _inner_fn(*lowerCamelCase , **lowerCamelCase ): warnings.warn( (f'''\'{fn.__name__}\' is experimental and might ...
632
1
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common impo...
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
"""simple docstring""" import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase__ : int = ...
632
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_co...
632
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Tens...
632
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def a_ ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def a_ ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] lowerCAme...
632
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMA...
632
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): """simple docstring""" snake_case__ = [("size...
632
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : Any = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft...
632
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as ...
632
1
"""simple docstring""" import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import ver...
632
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase__ : Union[str, Any] = False class ...
632
1
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def a_ ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = 0 if start < end: UpperCAmelCase__ = randint(lowerCamelCase ...
632
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
632
1
"""simple docstring""" import itertools import math def a_ ( lowerCamelCase ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes r...
632
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spe...
632
1
"""simple docstring""" import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase = "AAPL" ): UpperCAmelCase__ = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' UpperCAmelCase__ = BeautifulSoup(requests.get(lowerCamelCase ).text , 'html.par...
632
"""simple docstring""" import socket def a_ ( ): UpperCAmelCase__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase__ = socket.gethostname() UpperCAmelCase__ = 1_2_3_1_2 sock.connect((host, port) ) sock.send(b'Hello server!'...
632
1
"""simple docstring""" from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import flo...
632
"""simple docstring""" from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[list[int]] ): UpperCAmelCase__ = TypeError( 'Matrices must be formed from a list of z...
632
1
"""simple docstring""" def a_ ( lowerCamelCase ): if not isinstance(lowerCamelCase , lowerCamelCase ): raise TypeError('only integers accepted as input' ) else: UpperCAmelCase__ = str(abs(lowerCamelCase ) ) UpperCAmelCase__ = [list(lowerCamelC...
632
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ : int = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['...
632
1
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
632
"""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 lowerCAmelCase__ : Optional[int] = False class snake_case ( ...
632
1
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_number...
632
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_number...
632
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneratio...
632
1
"""simple docstring""" import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin cla...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings lowerCAmelCase__ : ...
632
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
1
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils ...
632
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import He...
632
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
1
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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_...
632
"""simple docstring""" # 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 # #...
632
1
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics ...
632
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
1
"""simple docstring""" import socket def a_ ( ): UpperCAmelCase__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase__ = socket.gethostname() UpperCAmelCase__ = 1_2_3_1_2 sock.connect((host, port) ) sock.send(b'Hello server!'...
632
"""simple docstring""" import warnings from functools import wraps from typing import Callable def a_ ( lowerCamelCase ): @wraps(lowerCamelCase ) def _inner_fn(*lowerCamelCase , **lowerCamelCase ): warnings.warn( (f'''\'{fn.__name__}\' is experimental and might ...
632
1
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resi...
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
"""simple docstring""" # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position lowerCAmelCase__ : Any = '2.13.1' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < v...
632
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_co...
632
1
"""simple docstring""" from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_singl...
632
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def a_ ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def a_ ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] lowerCAme...
632
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging lowerCAmelCase__ : int = lo...
632
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): """simple docstring""" snake_case__ = [("size...
632
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as ...
632
1
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer lowerCAmelCase__ : int = logging.get_logger(__name__) lowerCAmelCase__ : Optio...
632
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase__ : Union[str, Any] = False class ...
632
1
"""simple docstring""" def a_ ( lowerCamelCase = 1_0 ): if not isinstance(lowerCamelCase , lowerCamelCase ) or n < 0: raise ValueError('Invalid input' ) UpperCAmelCase__ = 1_0**n UpperCAmelCase__ = 2_8_4_3_3 * (pow(2 , 7_8_3_0_4_5_7 , lower...
632
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
632
1
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def...
632
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spe...
632
1
"""simple docstring""" import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def a_ ( ): ...
632
"""simple docstring""" import socket def a_ ( ): UpperCAmelCase__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase__ = socket.gethostname() UpperCAmelCase__ = 1_2_3_1_2 sock.connect((host, port) ) sock.send(b'Hello server!'...
632
1
"""simple docstring""" from math import pi def a_ ( lowerCamelCase , lowerCamelCase ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
632
"""simple docstring""" from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[list[int]] ): UpperCAmelCase__ = TypeError( 'Matrices must be formed from a list of z...
632
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return int((input_a, input_a).count(0 ) != 0 ) def a_ ( ): assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 ...
632
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ : int = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['...
632
1
"""simple docstring""" import math def a_ ( lowerCamelCase ): if not isinstance(lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = f'''Input value of [number={number}] must be an integer''' raise TypeError(lowerCamelCase ) if number < 1: UpperCA...
632
"""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 lowerCAmelCase__ : Optional[int] = False class snake_case ( ...
632
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusi...
632
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_number...
632
1
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets lowerCAmelCase__ : str = '\\n@inproceedings{snover-etal-2006-study,\n title = "A Study of Translation Edit Rate with Targeted Human Annotation",\n author = "Snover, Matthe...
632
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneratio...
632
1
"""simple docstring""" # Function to print upper half of diamond (pyramid) def a_ ( lowerCamelCase ): for i in range(0 , lowerCamelCase ): for _ in range(0 , n - i - 1 ): # printing spaces print(' ' , end='' ) for _ in range(0 , i + 1...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) lowerCAmelCase__ : Any = pytest.mark.integration @pytest.mark.parame...
632
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
1
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultiste...
632
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
1
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowerCAmelCase__ : Tuple = '%20'.join(argv[1:]) if len(argv) > 1 else quote(st...
632
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
1
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when...
632
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): if not (isinstance(lowerCamelCase , lowerCamelCase ) and isinstance(lowerCamelCase , lowerCamelCase )): raise ValueError('longest_common_substring() takes two strings for inputs' ) UpperCAmelCa...
632
"""simple docstring""" # 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 # #...
632
1
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments lowerCAmelCase__ : Dict = logging.getLogger(__name__) @dataclass class snake_case ( __Uppe...
632
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) class snake_case ( __UpperCAmelCase ): """simple docstring""" snake_case__ = "enc...
632
"""simple docstring""" import warnings from functools import wraps from typing import Callable def a_ ( lowerCamelCase ): @wraps(lowerCamelCase ) def _inner_fn(*lowerCamelCase , **lowerCamelCase ): warnings.warn( (f'''\'{fn.__name__}\' is experimental and might ...
632
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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...
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward fro...
632
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_co...
632
1
"""simple docstring""" from manim import * class snake_case ( __UpperCAmelCase ): """simple docstring""" def __lowerCAmelCase ( self : Any ): UpperCAmelCase__ = Rectangle(height=0.5 ,width=0.5 ) UpperCAmelCase__ = Rectangle...
632
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def a_ ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def a_ ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] lowerCAme...
632
1
"""simple docstring""" # This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def a_ ( lowerCamelCase ...
632
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): """simple docstring""" snake_case__ = [("size...
632
1
"""simple docstring""" import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute...
632
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as ...
632
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return int(input_a == input_a == 0 ) def a_ ( ): print('Truth Table of NOR Gate:' ) print('| Input 1 | Input 2 | Output |' ) print(f'''| 0 | 0 | {nor_gate(0 , 0 )}...
632
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase__ : Union[str, Any] = False class ...
632
1
"""simple docstring""" import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class snake_case ( __UpperCAme...
632
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
632
1
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ : Union[str, Any] = logging.get_logger(__nam...
632
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spe...
632
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase__ : Dict = { 'configuration_resnet': ['RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP...
632
"""simple docstring""" import socket def a_ ( ): UpperCAmelCase__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase__ = socket.gethostname() UpperCAmelCase__ = 1_2_3_1_2 sock.connect((host, port) ) sock.send(b'Hello server!'...
632
1
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def a_ ( ): UpperCAmelCase__ = ArgumentParser( description=( 'PyTorch TPU distributed ...
632
"""simple docstring""" from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[list[int]] ): UpperCAmelCase__ = TypeError( 'Matrices must be formed from a list of z...
632
1
"""simple docstring""" import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils impo...
632
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ : int = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['...
632
1
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar lowerCAmelCase__ : Any = TypeVar('T') class snake_case ( Generic[T] ): """simple docstring""" snake_case__ = 42 # Ca...
632
"""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 lowerCAmelCase__ : Optional[int] = False class snake_case ( ...
632
1
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class snake_case ( __UpperCAmelCase ): """simple docstring""" def __init__( self : int ,*lowerCamelCase__ : int ,**lowerCamelCase__ : str ): super()._...
632
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_number...
632
1
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf,...
632
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneratio...
632
1
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
"""simple docstring""" import os import sys lowerCAmelCase__ : List[str] = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, ...
632
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
1
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class snake_case ( __UpperCAmelCase ): """simple docstring""" ...
632
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
1
"""simple docstring""" 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 snake_case ( unittest.TestCase ): """simple docstring""...
632
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
632
1
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __UpperCAmelCase ): """simple docstring""" snake_case__ = (PNDMScheduler,) snake_case__ = (...
632
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any = logging.get_logger(__name__) lowerCAmelCase__ : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class snake_case ( __Up...
632
1
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): ...
632
"""simple docstring""" # 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 # #...
632
1
"""simple docstring""" def a_ ( lowerCamelCase ): UpperCAmelCase__ = current_set.copy() for row_index, row in enumerate(lowerCamelCase ): UpperCAmelCase__ = row[0] for column_index, column in enumerate(lowerCamelCase ): if magnitude == 0: ...
632
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): return x if y == 0 else greatest_common_divisor(lowerCamelCase , x % y ) def a_ ( lowerCamelCase , lowerCamelCase ): return (x * y) // greatest_common_divisor(lowerCamelCase , lowe...
632
1
"""simple docstring""" import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import d...
632
"""simple docstring""" import warnings from functools import wraps from typing import Callable def a_ ( lowerCamelCase ): @wraps(lowerCamelCase ) def _inner_fn(*lowerCamelCase , **lowerCamelCase ): warnings.warn( (f'''\'{fn.__name__}\' is experimental and might ...
632
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
632
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowerCAmelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowerCAmelCase__ : list[int] = [ord(l...
632
1
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneratio...
632
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_co...
632
1
"""simple docstring""" # 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 # #...
632
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def a_ ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def a_ ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] lowerCAme...
632
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING lowerCAmelCase__ : str = logging.get...
632
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): """simple docstring""" snake_case__ = [("size...
632
1