code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
299
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin i...
299
1
'''simple docstring''' import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __snake_case = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
361
'''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 # # Un...
219
0
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __UpperCamelCase , unittest.TestCase ): ...
20
import glob import os import random from string import ascii_lowercase, digits import cva __A ="" __A ="" __A ="" __A =1 # (0 is vertical, 1 is horizontal) def a ( ): '''simple docstring''' __UpperCAmelCase , __UpperCAmel...
226
0
'''simple docstring''' from __future__ import annotations from random import random class lowercase : def __init__( self , UpperCamelCase_ = None ): '''simple docstring''' UpperCamelCase__ :Tuple = value UpperCamelCase__ :Any = ra...
354
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''distilbert-base-unc...
219
0
from __future__ import annotations import numpy as np def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' return np.maximum(0 , lowerCAmelCase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
101
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransformer,...
101
1
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( _lowercase ) -> bool: return len(set(_lowercase ) ) == len(_lowercase ) if __name__ == "__main__": import doctest doctest.testmod()
354
'''simple docstring''' 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, SkipBatchSampl...
338
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCAmelCase__ = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
11
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''facebook/dpr-ctx_encoder-single-nq-base''': ( '''https://huggingface.co/facebook/dpr-ctx_encoder-...
108
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer _UpperCamelCase = logging.get_lo...
16
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enab...
16
1
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCamelCase__ : """simple docstring""" __a = 42 # [batch_size x 3] __a = 42 # [batch_size x 3] __a =...
115
import socket def __SCREAMING_SNAKE_CASE ( ) -> Optional[int]: """simple docstring""" SCREAMING_SNAKE_CASE__ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) SCREAMING_SNAKE_CASE__ = socket.gethostname() SCREAMING_SNAKE_CASE...
219
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging ...
352
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 transformers import TFCamembertModel @requi...
306
0
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, 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_...
65
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": __lowerCamelCase : str = input('''Enter image url: ''').strip() print(F"""Downloading image from {url} ...""") __lowerCamelCase : Any = BeautifulSoup(requests.get(url).conten...
219
0
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __lowerCamelCase (UpperCAmelCase__ : str ): SCREAMING_SNAKE_CASE = [ "encoder.version", "decoder.version"...
206
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer _lowerCamelCase : Union[str, Any] = logging.get_logger(__nam...
206
1
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __lowercase : List[Any] = 4 __lowercase : Dict = 3 class __low...
318
from ...processing_utils import ProcessorMixin class lowercase_ ( UpperCamelCase_ ): """simple docstring""" UpperCAmelCase_ : List[Any] = ["""image_processor""", """feature_extractor"""] UpperCAmelCase_ : Optional[int] = """TvltImageProcessor""" UpperCAmelC...
338
0
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[int] = logging.get_logger(__name__) lowerCamelCase : Dict = { '''huggingface/inform...
358
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for...
208
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCAmelCase_ = log...
16
"""simple docstring""" import argparse import os # New Code # 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_sched...
16
1
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ ( __lowerCAmelCase ): '''simple docstring''' UpperCAmelCase : Union[str, Any] = (PNDMScheduler,) UpperCAmelCase : ...
271
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging a = ...
271
1
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class __lowercase ( tf.keras.layers.Layer ): def __init__(self , ...
318
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, Aut...
318
1
"""simple docstring""" import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase=None ) -> Optional[int]: '''simple...
355
"""simple docstring""" from __future__ import annotations import numpy as np def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: '''simple docstring''' lowercase_ , lowercase_ = np.shape(__lowerCAmelCase ) if rows !...
313
0
'''simple docstring''' from __future__ import annotations import time lowerCamelCase :Tuple = list[tuple[int, int]] lowerCamelCase :Optional[Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0],...
206
'''simple docstring''' import argparse import struct import unittest class _lowerCAmelCase : def __init__(self , lowercase ): A_ : List[str] = data # Initialize hash values A_ : Tuple = [ 0X6A09_E667, 0XBB67_AE85, 0X3C6E_F3...
206
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 lowercase__ : List[An...
190
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowercase__ : Dict = { '''linear''': PIL.Image.Resampling.BILINE...
190
1
"""simple docstring""" import torch from transformers import AutoModel class UpperCamelCase ( torch.nn.Module ): def __init__( self, lowerCAmelCase__="sayef/fsner-bert-base-uncased") -> List[Any]: super(lowerCAmelCase__, self).__init__() snak...
69
'''simple docstring''' from collections.abc import Sequence def a_ ( _lowerCAmelCase ,_lowerCAmelCase ) -> float: return sum(c * (x**i) for i, c in enumerate(_lowerCAmelCase ) ) def a_ ( _lowerCAmelCase ,_lowerCAmelCas...
208
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCamelCase ...
360
import math def UpperCamelCase ( _A : float , _A : float )-> float: """simple docstring""" if ( not isinstance(_A , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("pow...
198
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def UpperCAmelCase_ (__a : Callable[[int | float], int | float] , __a : int | float , __a : int | float , __a : int = 1_0_0 , ): """simple docstring""" _a : ...
271
'''simple docstring''' import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class UpperCAmelCase__ ( unittest.TestCase ): """simple docstri...
271
1
"""simple docstring""" from __future__ import annotations def _snake_case ( lowercase__ , lowercase__ , lowercase__ ): if len(lowercase__ ) == 0: raise ValueError('find_max() arg is an empty sequence' ) if ( left >= len(lo...
12
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import A...
12
1
'''simple docstring''' import json import sys def lowerCamelCase (_SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CASE : int ): with open(_SCREAMING_SNAKE_CASE , encoding='utf-8' ) as f: __a : Optional[Any] = json.load(_S...
27
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableUnCL...
313
0
"""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, exec...
168
"""simple docstring""" import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met ...
168
1
'''simple docstring''' from math import pi, sqrt, tan def _lowerCAmelCase ( __snake_case : float ) -> float: if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 ...
190
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class SCREAMING_SNAKE_CASE (datasets.BuilderConfig ): lower...
190
1
"""simple docstring""" # Copyright (c) 2021-, NVIDIA CORPORATION. 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-...
370
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ViltForMaskedLM, ViltF...
94
0
import os import re import shutil import sys import tempfile import unittest import black snake_case : Any = 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 # noqa: E402 # This is the...
94
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): lowercase__ , lowercase__ : Optional[int] = [], [] while len(UpperCAmelCase ) > 1: lowercase__ , lowercase__ : List[str] = min(UpperCAmelCase ), max(UpperCAmelCase ) start.append(UpperCAme...
198
0
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONA...
361
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" return base * power(SCREAMING_SNAKE_CASE , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') ...
93
0
from __future__ import annotations def lowerCamelCase__ ( A__ : list[int | float] , A__ : int , A__ : int ): '''simple docstring''' if len(A__ ) == 0: raise ValueError("""find_max() arg is an empty sequence""" ) if (...
12
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version UpperCAmelCase_ ...
12
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer fr...
352
from __future__ import annotations UpperCAmelCase__ : List[str] = list[list[int]] # assigning initial values to the grid UpperCAmelCase__ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0]...
301
0
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def _A (lowerCAmelCase__ :float , lowerCAmelCase__ :float ) -> tuple: '''simple docstring''' if inductance <= 0: raise ValueError('Inductan...
168
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : Union[str, Any] = { "config...
168
1
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, tor...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { ...
40
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, 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, rando...
94
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeat...
16
'''simple docstring''' from ..utils import DummyObject, requires_backends class _A ( metaclass=__SCREAMING_SNAKE_CASE ): _SCREAMING_SNAKE_CASE : List[str] = ["sentencepiece"] def __init__( self , *__UpperCAmelCase , **__UpperCAmelCase ) -> ...
16
1
'''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 fro...
31
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentT...
93
0
"""simple docstring""" import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _lowercase ( pl.LightningModule ): """simple docstring""" def __init__(...
364
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock ...
85
0
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def _SCREAMING_SNAKE_CASE ( _lowercase : int = 200_0000 ) ->int: '''simple docstring''' a : list[int] = [0] a : int for id...
105
"""simple docstring""" import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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 ImagePr...
301
0
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_...
352
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_...
165
0
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_availabl...
56
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import ...
56
1
from __future__ import annotations A : List[str] = [-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0] A : Optional[Any] = [-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1] def __lowerCAmelCase ( a__ ) -> list[float]: __a ...
367
import sys def __lowerCAmelCase ( a__ ) -> Optional[int]: __a = len(a__ ) __a = [[0 for x in range(a__ )] for x in range(a__ )] __a = [[0 for x in range(a__ )] for x in range(a__ )] for chain_length in range(2 , a__ ): for...
33
0
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils im...
16
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __A ( unittest.TestCase ): '''simple docstring''' def UpperCAmelCase ( s...
16
1
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 ...utils im...
364
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> List[Any]: # A local function to see if a dot lands in the circle. def is_in_circle(lowerCamelCase__ , ...
113
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 imp...
78
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def UpperCamelCase_( snake_case : Any ): '''simple docstring''' if ( (cp >= 0X4E00 and cp...
85
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf a : Union[str, Any] ...
360
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extrac...
338
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscrete...
215
"""simple docstring""" from math import ceil def A ( snake_case__ , snake_case__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = list(range(0 , snake_case__ ) ) SCREAMING_SNAKE_CASE__ = [item for sublist in list(device_map.value...
165
0
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :Optional[int] = 1_0 , lowerCAmelCase__ :Tuple = 1_0_0_0 , lowerCAmelCase__ :str = True ) -> int: '''simple docstring''' assert ( isinstance(__snake_case , __snake_case ) and...
363
"""simple docstring""" import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCAmelCase : Tuple ={ """facebook/mask2former-swin-small-coco-instance""": ( ""...
32
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...
197
"""simple docstring""" def lowercase ( __snake_case : Optional[int] ): lowercase_ : int = 0 lowercase_ : Optional[Any] = len(__snake_case ) for i in range(n - 1 ): for j in range(i + 1 , __snake_case ): if arr[i] > arr[j]: ...
33
0
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, resize, to_channel_dime...
87
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
87
1
lowercase : dict[tuple[int, int, int], int] = {} def A_ ( A__ , A__ , A__ ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: return 0 # if we have ...
99
"""simple docstring""" import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __Upper...
113
0
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _SCREAMING_SNAKE_CASE = numpy.array([0, 0]) _SCREAMING_SNAKE_CASE = numpy.array([0.5, 0.8_6_6_0_2_5_4]) _SCREAMING_SNAKE_...
217
'''simple docstring''' import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, B...
217
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class A ( UpperCamelCase_ ): '''simple docstring''' def _...
298
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowercase_ ( unittest.TestCase ): ...
338
0
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get_f...
176
from math import pow def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase ,lowercase ,lowercase ,) -> tuple[int, int]: if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 ...
176
1
"""simple docstring""" from math import sqrt def _lowerCamelCase ( _UpperCamelCase = 100_0000 ): '''simple docstring''' __lowerCAmelCase = 0 __lowerCAmelCase = 0 __lowerCAmelCase = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shorte...
57
def SCREAMING_SNAKE_CASE_ ( __A : list[int] , __A : str ) -> list[int]: """simple docstring""" a_ : Any = int(__A ) # Initialize Result a_ : Tuple = [] # Traverse through all denomination for denomination ...
32
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node UpperCamelCase = 4 UpperCamelCase = 3 class snake_case_ ( __A ): pass ...
357
def lowercase_ ( _lowerCamelCase : int = 10 , _lowerCamelCase : int = 1000 , _lowerCamelCase : bool = True): assert ( isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerC...
333
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common imp...
87
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def lowercase_ ( _lower...
87
1
"""simple docstring""" import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import t...
364
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _UpperCamelCase = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_visio...
234
0
"""simple docstring""" from math import factorial __A = {str(d): factorial(d) for d in range(10)} def a__ ( __SCREAMING_SNAKE_CASE ) -> int: return sum(DIGIT_FACTORIAL[d] for d in str(__SCREAMING_SNAKE_CASE ) ) def a__ ( ) -> int: __lowerCAmelCas...
217
"""simple docstring""" def a__ ( __SCREAMING_SNAKE_CASE ) -> int: __lowerCAmelCase: Optional[Any] = 1 for i in range(1 , num + 1 ): fact *= i return fact def a__ ( __SCREAMING_SNAKE_CASE ) -> int: __lowerCAmelCase: List[str] ...
217
1
UpperCAmelCase_ = '''Tobias Carryer''' from time import time class lowerCamelCase__: def __init__( self: List[str] , UpperCamelCase_: List[str] , UpperCamelCase_: List[Any] , UpperCamelCase_: int , UpperCamelCase_: Any=int(time() ) ): # noqa: B...
369
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'n...
29
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } class lowercase__ ( _UpperCAmelCase ): ...
176
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_ver...
176
1
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim ...
246
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class _a : '''simple docstring''' def __init__( self, A ): '''simple docstring''' ...
246
1
__A : Dict = { 0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f', } def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> str: '''s...
138
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokeni...
333
0
'''simple docstring''' from __future__ import annotations __UpperCAmelCase :Tuple = "Muhammad Umer Farooq" __UpperCAmelCase :Tuple = "MIT" __UpperCAmelCase :Union[str, Any] = "1.0.0" __UpperCAmelCase :Optional[int] = "Muhammad Umer F...
240
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
240
1
"""simple docstring""" import numpy # List of input, output pairs lowercase__ : List[str] = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) lowercase__ : Optional[int] = (((5_1_5, 2_2,...
224
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_...
234
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: if no...
231
from __future__ import annotations import queue class UpperCamelCase_ : '''simple docstring''' def __init__( self : Optional[Any] , UpperCAmelCase__ : Dict) ->Any: '''simple docstring''' A__ = data A__ = None ...
231
1
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransformer, ...
18
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..model...
29
0
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 # noqa: F401 # Here to have a nic...
352
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor __A = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE ( snake_case ): """simple docstring""" def __init__( self: List[Any] , *__A: Union[str, An...
75
0
"""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, StableDiffusionLatentUpscalePipe...
246
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
1
'''simple docstring''' 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 diffus...
142
'''simple docstring''' from manim import * class _a ( __lowerCAmelCase ): def _lowercase ( self ) -> Optional[int]: _snake_case = Rectangle(height=0.5 ,width=0.5 ) _snake_case = Rectangle(height=0.4_6 ,width=0.4_6 ...
142
1
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Union[str, Any] = logging.get_logger(__name__) snake_case : Union[str, Any] = { '''huggingface/autoformer-tourism-monthly''': '''http...
240
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 : List[Any] = datasets.logging.get_logger(__name__) snake_case : List[str] = '''\ @InPro...
240
1
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCamelCase__ ( unittest.TestCase ): '''simple docstring''' def _lowerCAmelCase ( self ) -> List[Any]: _lowerCAmelCase ...
353
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { 'configuration_perceiver': ['PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP...
341
0
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() _A = [ "word_embeddings_layernorm.weight", "word_embeddings_...
231
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lowerCAmelCase ( __a , unittest.TestCase ): _lo...
231
1
"""simple docstring""" import itertools import os import re a : str = re.compile(R'''([A-Z]+)([A-Z][a-z])''') a : Any = re.compile(R'''([a-z\d])([A-Z])''') a : str = re.compile(R'''(?<!_)_(?!_)''') a : Optional[int] ...
362
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int = 50 ) ->int: '''simple docstring''' a : Any = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for ...
79
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandi...
89
'''simple docstring''' from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline a_ : Any = lo...
75
0
"""simple docstring""" def lowercase (SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> float: SCREAMING_SNAKE_CASE = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) ...
38
"""simple docstring""" from __future__ import annotations def lowercase (SCREAMING_SNAKE_CASE_ : list[int] ) -> bool: return len(set(SCREAMING_SNAKE_CASE_ ) ) == len(SCREAMING_SNAKE_CASE_ ) if __name__ == "__main__": import doctest doctest.testmod()
38
1
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 ConfigTester from .....
142
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _A : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): def __init__( self : Dict , *A : Any , **A : List[...
142
1
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 _a : Tuple= datasets.logging.get_logger(__name__) _a : Optional[int]= '\\n@InProceedings{moosavi2019minimum,\n author...
367
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_rofo...
95
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Any = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConf...
91
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], ...
341
0
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGen...
203
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer lowercase__ = logging.get_logger(__name__)...
203
1
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requir...
10
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = { '''configuration_time_series_transformer''': [ '''TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
79
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "Ch...
252
from itertools import count def UpperCamelCase ( _a = 5_0 ) -> int: '''simple docstring''' lowercase_ :Dict = [1] * min_block_length for n in count(_a ): fill_count_functions.append(1 ) for block_length in...
252
1
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, random_attention_mas...
38
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : int = { '''CarlCochet/trajectory-transformer-halfcheetah-medium-v2''': ( '''https://huggingface.co/CarlCoche...
38
1
"""simple docstring""" import random class _UpperCAmelCase : '''simple docstring''' @staticmethod def __lowerCAmelCase ( A ) -> tuple[list[int], list[int]]: _UpperCAmelCase : Dict = [ord(A ) for i in text] _UpperCAmelCase ...
68
"""simple docstring""" import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ....
68
1
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowerCAmelCase = Lock() def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCam...
37
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase : Optional[int] = { """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json"""...
95
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging a_ = logging.get_logger(__name__) a_ = r'\n Args:\n input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):\n ...
50
a_ = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' a_ = [{'type': 'code', 'content': INSTALL_CONTENT}] a_ = { '{processor_class}': 'FakeProcessorClass', '{model...
50
1
"""simple docstring""" import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __lowerCAmelCase ( lowercase : str ) -> Any: """simple docstring""" monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings"...
203
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _lowerCAmelCase ( unittest.TestCase ): __UpperCAmelCase : Union[str, Any] = JukeboxTokenizer __UpperCAmelCase : Union[str, Any] ...
203
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils imp...
362
'''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_ ( __snake_case : Any ) -> Tuple: """simple do...
6
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __lowercase ( a_ ): """simple docstring""" UpperCamelCase : Tuple = (EulerDiscreteScheduler,) UpperCamelCase : An...
252
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : List[str] = logging.get_logger(__name__) UpperCAmelCase : Tuple = { "vocab_file": "vocab.json", "merges_...
252
1
from math import isqrt def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int ) -> list[int]: """simple docstring""" SCREAMING_SNAKE_CASE__ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
370
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __snake_case ( unittest.TestCase ): def __a ( self : Dict ): """simple docstring""" ...
204
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """GroupViTOnnxCon...
68
import copy import random from transformers import CLIPTokenizer class a__ ( snake_case ): """simple docstring""" def __init__( self , *lowercase , **lowercase ) -> Union[str, Any]: '''simple docstring''' super().__init__(*lowercase , **lowe...
68
1
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel...
18
'''simple docstring''' # Copyright 2022 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 # # U...
18
1
_UpperCAmelCase : Dict = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDow...
50
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase=() , _UpperCAmelCase=None , _UpperCAmelCas...
50
1
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
365
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 _lowerCamelCase( unittest.TestCase ): def UpperCamelCase ( self) -> Tuple: ...
84
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __A ( lowerCAmelCase ): lowerCAmelCase_ : Tuple = (PNDMScheduler,) lowerCAmelCase_ : Optional[int] = (("num_inference...
138
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A( a ): snake_case_ = ['''image_processor''', '''tokenizer'''] snake_case_ = '''ChineseCLIPImageProcessor''' snake_case_ = ('''BertTokeni...
6
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor...
351
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transfor...
26
0
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_path...
59
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class A...
204
0
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowercase__ = TypeVar("T") class A_ ( Generic[T] ): ...
280
'''simple docstring''' import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig lowercase__ = { "facebook/maskformer-s...
280
1
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) def _snake_case ( lowerCAmelCase : Tuple ): """simple docstring"""...
18
import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ran...
18
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _a...
365
'''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 _a : List[str] = """▁""" _a : Optional[int] = {"""vocab_file""...
46
0