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
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCamelCase( _a ): lowercas...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
84
0
import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE : Union[str, Any] ...
363
def UpperCamelCase_( lowerCamelCase_ = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
84
0
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 SCREAMING_SNAKE_CASE : Optional[int] = get_tests_dir("...
364
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == ...
84
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : List[Any] = prime_factors(lowerCamelCase_ ) if is_square_free(lowerCamelCase_ ): return -1 if len(lowerCamelCase...
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
SCREAMING_SNAKE_CASE : Dict = { "a": "AAAAA", "b": "AAAAB", "c": "AAABA", "d": "AAABB", "e": "AABAA", "f": "AABAB", "g": "AABBA", "h": "AABBB", "i": "ABAAA", "j": "BBBAA", "k": "ABAAB", "l": "ABABA", "m": "ABABB", "n": "ABBAA", "o": "ABBAB", ...
366
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None ) -> list[list[str]]: _lowercase : Optional[Any] = word_bank or [] # create a table _lowercase : int = len(lowerCamelCase_ ) + 1 _lowercase : li...
84
0
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
0
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.tes...
368
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_log...
84
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Opt...
369
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
0
import os def UpperCamelCase_( lowerCamelCase_ = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(lowerCamelCase_ ) , lowerCamelCase_ ) ) as input_file: _lowercase : List[Any] = [ [int(lowerCamelCase_ ) for element in line.split(...
370
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
0
from math import isclose, sqrt def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> tuple[float, float, float]: _lowercase : Tuple = point_y / 4 / point_x _lowercase : Dict = 2 * normal_gradient / (1 + normal_gradient * norma...
371
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCamelCase( _a, unittest.TestCase ): lowercase_ : List[str] = CTRLTokenizer...
84
0
import unittest import numpy as np def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ = None , ) -> np.ndarray: _lowercase : int = np.shape(lowerCamelCase_ ) _lowercase : List[Any] = np.shape(l...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxC...
84
0
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> bool: _lowercase : Union[str, Any] = get_failure_array(lowerCamelCase_ ) # 2) Step through text searching for pattern _lowercase : List[str] = 0, 0 # index...
351
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = symbols("c...
84
0
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor fr...
352
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
84
0
class _lowerCamelCase: """simple docstring""" def __init__( self, lowerCamelCase) -> str: """simple docstring""" _lowercase : str = arr.split(',') def UpperCamelCase ( self) -> Optional[int]: """simple d...
353
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Union[str, Any] = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements _lowercase : Any = lst[m - 1 : m + 2] # if middle element is peak if three[1] >...
84
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return 1 if input_a == input_a else 0 def UpperCamelCase_( ) -> None: assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 a...
354
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase) -...
84
0
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging SCREAMING_SNAKE_CASE : Lis...
355
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, ...
84
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[Any] = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class _...
356
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = 1 _lowercase : Union[str, Any] = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == ...
84
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
357
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.test...
84
0
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers....
358
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = {name: getattr(transform...
84
0
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from data...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _lowerCamelCase( unittest.TestCase ): ...
360
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
0
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
361
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE : Tuple = "docs/source/en/_toctree.yml" def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = defaultdict(lowerCamelCase_ ) _lowercase : int = [] ...
84
0
def UpperCamelCase_( lowerCamelCase_ ) -> int: assert column_title.isupper() _lowercase : Tuple = 0 _lowercase : int = len(lowerCamelCase_ ) - 1 _lowercase : Any = 0 while index >= 0: _lowercase : Dict = (ord(col...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
84
0
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.spectrogram_diffusion import ...
363
def UpperCamelCase_( lowerCamelCase_ = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
84
0
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
364
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == ...
84
0
from statistics import mean import numpy as np def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> list: _lowercase : Dict = 0 # Number of processes finished _lowercase : Optional[Any] = 0 ...
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
def UpperCamelCase_( lowerCamelCase_ = 10 ) -> str: if not isinstance(lowerCamelCase_ , lowerCamelCase_ ) or n < 0: raise ValueError('Invalid input' ) _lowercase : Any = 10**n _lowercase : Any = 2_8433 * (pow(2 , 783_0457 , low...
366
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None ) -> list[list[str]]: _lowercase : Optional[Any] = word_bank or [] # create a table _lowercase : int = len(lowerCamelCase_ ) + 1 _lowercase : li...
84
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase=None, lowerCamelCase=True, lowerCamelCase=None...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalD...
368
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_log...
84
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import torch ...
369
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
0
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _lowerCamelCase: lowercase_ : List[str] lowercase_ : Optional[str] =...
370
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> str: _lowercase : Optional[Any] = [1] for i in range(2 , lowerCamelCase_ ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds" _lowercase : ...
371
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCamelCase( _a, unittest.TestCase ): lowercase_ : List[str] = CTRLTokenizer...
84
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : ...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxC...
84
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import c...
351
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = symbols("c...
84
0
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 from sagemaker.huggingface import...
352
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
84
0
from __future__ import annotations class _lowerCamelCase: """simple docstring""" def __init__( self, lowerCamelCase, lowerCamelCase) -> Union[str, Any]: """simple docstring""" _lowercase : Optional[Any] = text, pattern _lower...
353
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Union[str, Any] = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements _lowercase : Any = lst[m - 1 : m + 2] # if middle element is peak if three[1] >...
84
0
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 FlaxTimestepEmbedding, Fla...
354
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase) -...
84
0
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> list[tuple[int, int]]: _lowercase : Dict = position _lowercase : Optional[Any] = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), ...
355
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, ...
84
0
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase_( lowerCamelCase_ , low...
356
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = 1 _lowercase : Union[str, Any] = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == ...
84
0
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
357
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.test...
84
0
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None , lowerCamelCase_ = None , lowerCamelCase_ = False , ) -> tuple[int, float, str]: _lowercase : List[str] = cipher_alphabet or [chr(lowerCamelCase_ ) for ...
358
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = {name: getattr(transform...
84
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : Dict = { "configuration_time_series_transformer": [ "TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimeSeriesTransformerConfig", ...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
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_tensor,...
360
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
0
def UpperCamelCase_( lowerCamelCase_ ) -> bool: """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) _lowercase : Any = sorted(string.lower() ) return len(lowerCamelCa...
361
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE : Tuple = "docs/source/en/_toctree.yml" def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = defaultdict(lowerCamelCase_ ) _lowercase : int = [] ...
84
0
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort S...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
84
0
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from transformers impo...
363
def UpperCamelCase_( lowerCamelCase_ = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
84
0
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_sha...
364
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == ...
84
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: if len(lowerCamelCase_ ) != len(lowerCamelCase_ ): raise ValueError('String lengths must match!' ) _lowercase : Optional[Any] = 0 for chara, chara in zip(lowerCamelCase_ , lowerCam...
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 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 SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name_...
366
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None ) -> list[list[str]]: _lowercase : Optional[Any] = word_bank or [] # create a table _lowercase : int = len(lowerCamelCase_ ) + 1 _lowercase : li...
84
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = { "facebook/data...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
0
from math import factorial SCREAMING_SNAKE_CASE : List[str] = {str(d): factorial(d) for d in range(10)} def UpperCamelCase_( lowerCamelCase_ ) -> int: return sum(DIGIT_FACTORIAL[d] for d in str(lowerCamelCase_ ) ) def UpperCamelCase_( ) -> int: _lowercase ...
368
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_log...
84
0
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) class _lowerCamelCase: lowercase_ : List[Any] = None @experimental def UpperCa...
369
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
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 _lowerCamelCase( _a, unittest.TestCase ): lowe...
370
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
0
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils im...
371
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCamelCase( _a, unittest.TestCase ): lowercase_ : List[str] = CTRLTokenizer...
84
0
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNewTokensCriteria...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxC...
84
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _lowerCamelCase( _a ): lowercase_ : Tuple = (PNDMScheduler,) lowercase_ : str = (("""num_inference_steps""", 50),) def ...
351
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = symbols("c...
84
0
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 SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_logger(__name__) def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowerca...
352
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
84
0
from ...configuration_utils import PretrainedConfig class _lowerCamelCase( _a ): """simple docstring""" lowercase_ : List[Any] = """bert-generation""" def __init__( self, lowerCamelCase=5_03_58, lowerCamelCase=10_24, lowerCamelCase=24, lower...
353
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Union[str, Any] = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements _lowercase : Any = lst[m - 1 : m + 2] # if middle element is peak if three[1] >...
84
0
from __future__ import annotations from typing import Any class _lowerCamelCase( _a ): pass class _lowerCamelCase: def __init__( self, lowerCamelCase) -> None: """simple docstring""" _lowercase : Any = data _lowercase : ...
354
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase) -...
84
0
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute...
355
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, ...
84
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar SCREAMING_SNAKE_CASE : int = TypeVar("T") class _lowerCamelCase( Generic[T] ): lowercase_ : deque[T] # Cache store of keys lowercase_ : set[T] # R...
356
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = 1 _lowercase : Union[str, Any] = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == ...
84
0
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineT...
357
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.test...
84
0
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py SCREAMING_SNAKE_CASE : Tuple = "src/transformers" SCREAMING_SNAKE_CASE : ...
358
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = {name: getattr(transform...
84
0
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
0
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _lowerCamelCase( _a ): def __init__( self, lowerCamelCa...
360
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
361
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE : Tuple = "docs/source/en/_toctree.yml" def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = defaultdict(lowerCamelCase_ ) _lowercase : int = [] ...
84
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : Union[str, Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_av...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
84
0
def UpperCamelCase_( lowerCamelCase_ = 1 , lowerCamelCase_ = 1000 ) -> int: _lowercase : List[Any] = 1 _lowercase : List[str] = 0 for divide_by_number in range(lowerCamelCase_ , digit + 1 ): _lowercase : list[int] = [] ...
363
def UpperCamelCase_( lowerCamelCase_ = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
84
0
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _lowerCamelCase( yaml.SafeLoader ): def UpperCamelCase ( self, lowerCamelCase) -> List[str]: """simple docstring""" _lowercase : L...
364
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == ...
84
0
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Ar...
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 inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class _lowerCamelCase( unittest.TestCase ): def Upper...
366
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None ) -> list[list[str]]: _lowercase : Optional[Any] = word_bank or [] # create a table _lowercase : int = len(lowerCamelCase_ ) + 1 _lowercase : li...
84
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
0
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def UpperCamelCase_( lowerCamelCase_ ) -> List[str]: _lowercase : List[str] = os.path.join(args.tf_model_dir , 'parameters.json' ) _lower...
368
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_log...
84
0
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment, ...
369
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
0
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available fro...
370
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
0
import baseaa def UpperCamelCase_( lowerCamelCase_ ) -> bytes: return baseaa.aaaencode(string.encode('utf-8' ) ) def UpperCamelCase_( lowerCamelCase_ ) -> str: return baseaa.aaadecode(lowerCamelCase_ ).decode('utf-8' ) if __name__ == "__main__": import doctest...
371
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCamelCase( _a, unittest.TestCase ): lowercase_ : List[str] = CTRLTokenizer...
84
0
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCamelCase_( lowerCamelCase_ ) -> str: if not isinstance(lowerCamelCase_ , lowerCamelCase_ ): raise TypeError('Undefined for non-integers' ) elif precision < 1: raise ValueError('U...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxC...
84
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available,...
351
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = symbols("c...
84
0
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar SCREAMING_SNAKE_CASE : Optional[Any] = TypeVar("T") class _lowerCamelCase( Generic[T] ): def __init__( self, lowerCamelCase, lowerCamelCase) -> None: ...
352
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
84
0
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and n...
353
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Union[str, Any] = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements _lowercase : Any = lst[m - 1 : m + 2] # if middle element is peak if three[1] >...
84
0
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fro...
354
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase) -...
84
0
def UpperCamelCase_( lowerCamelCase_ ) -> list[list[int]]: _lowercase : List[str] = [] if len(lowerCamelCase_ ) == 1: return [nums.copy()] for _ in range(len(lowerCamelCase_ ) ): _lowercase : int = nums.pop(0 ) _lowercase : int...
355
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, ...
84
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regr...
356
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = 1 _lowercase : Union[str, Any] = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == ...
84
0
def UpperCamelCase_( lowerCamelCase_ ) -> Union[str, Any]: stooge(lowerCamelCase_ , 0 , len(lowerCamelCase_ ) - 1 ) return arr def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> int: if i >= h: retur...
357
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.test...
84
0
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE : List[str] = "src/transformers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE : Any = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} SCREAM...
358
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = {name: getattr(transform...
84
0
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ): return [ord(lowerCamelCase_ ) - 96 for elem in plain] def UpperCamelCase_( lowerCamelCase_ ): return "".join(chr(elem + 96 ) for elem in encoded ) def UpperCamelCase_( ): _lowercase : ...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> str: _lowercase : list[list[str]] = [[] for _ in range(lowerCamelCase_ )] _lowercase : str = key - 1 if key <= 0: raise ValueError('Height of grid can\'t be 0 or negative' ) if key...
360
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
0
from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCamelCase_( ) -> Dict: """simple docstring""" _lowercase : Union[str, Any] = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) _lowercase : ...
361
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE : Tuple = "docs/source/en/_toctree.yml" def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = defaultdict(lowerCamelCase_ ) _lowercase : int = [] ...
84
0
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if ...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
84
0
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassifica...
363
def UpperCamelCase_( lowerCamelCase_ = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
84
0
import os import string import sys SCREAMING_SNAKE_CASE : Union[str, Any] = 1 << 8 SCREAMING_SNAKE_CASE : str = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, "left": 68 ...
364
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == ...
84
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE : Optional[int] = symbols("ct x y z") def UpperCamelCase_( lowerCamelCase_ ) -> float: ...
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
def UpperCamelCase_( lowerCamelCase_ ) -> str: if not all(char in '01' for char in bin_string ): raise ValueError('Non-binary value was passed to the function' ) if not bin_string: raise ValueError('Empty string was passed to the function' ) _lowercase : Union[...
366
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ = None ) -> list[list[str]]: _lowercase : Optional[Any] = word_bank or [] # create a table _lowercase : int = len(lowerCamelCase_ ) + 1 _lowercase : li...
84
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
368
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_log...
84
0
SCREAMING_SNAKE_CASE : int = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} SCREAMING_SNAKE_CASE : str = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> list[int]: ""...
369
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
0
import math def UpperCamelCase_( lowerCamelCase_ = 100 ) -> int: _lowercase : int = sum(i * i for i in range(1 , n + 1 ) ) _lowercase : int = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squar...
370
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
0
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline SCREAMING_SNAKE_CASE : Optional[int] = version.parse(versi...
371
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCamelCase( _a, unittest.TestCase ): lowercase_ : List[str] = CTRLTokenizer...
84
0
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : int ): """simple docstring""" if not isinstance(__UpperCamelCase , __UpperCamelCase ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must ...
85
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
85
1
"""simple docstring""" import re def lowerCAmelCase (__UpperCamelCase : str ): """simple docstring""" __UpperCamelCase =re.compile(r'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' ) if match := re.search(__UpperCamelCase , __UpperCamelCase ): return match.str...
85
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowercase = { '''configuration_conditional_detr''': [ '''CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''C...
85
1