code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWith...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def UpperCAmelCase ( ) -> None: """simple docstring""" assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 ...
15
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
15
def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = [0] * len(a_ ) __A = [] __A = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(a_ ) ): ...
15
1
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils i...
15
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" return sum(param.float().sum...
15
1
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) SCREAMING_SNAKE_CASE :Union[s...
15
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
1
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, ra...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
1
import argparse import os import torch from transformers.utils import WEIGHTS_NAME SCREAMING_SNAKE_CASE :Optional[Any] = ['small', 'medium', 'large'] SCREAMING_SNAKE_CASE :Any = 'lm_head.decoder.weight' SCREAMING_SNAKE_CASE :Any = 'lm_head.weight' def UpperC...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging SCREAMING_SNAKE_CASE :str = logging.get_logger(__name__) def ...
15
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
1
from __future__ import annotations from collections.abc import Generator def UpperCAmelCase ( ) -> Generator[int, None, None]: """simple docstring""" __A = {} __A = 2 while True: __A = factor_map.pop(a_ , a_ ) if factor: __A ...
15
# 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 SCREAMING_SNAKE_CASE...
15
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProcesso...
15
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
15
1
SCREAMING_SNAKE_CASE :Tuple = {str(digit): digit**5 for digit in range(10)} def UpperCAmelCase ( a_ ) -> int: """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(a_ ) ) def UpperCAmelCase ( ) -> int: """simple do...
15
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
1
from __future__ import annotations import math from collections.abc import Callable def UpperCAmelCase ( a_ , a_ , a_ , a_ = 1_0_0 , ) -> float: """simple docstring""" __A = x_start __A = fnc(a_ ) __A = 0.0 for _ in range(a_ ): # A...
15
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
15
1
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
import numpy as np def UpperCAmelCase ( a_ , a_ , a_ = 1E-12 , a_ = 1_0_0 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(a_ )[0] == np.shape(a_ )[1] # Ensure proper dimensionality. assert np.shape(a_ )[0] == np.shape(a_ )[0] ...
15
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE :List[Any] = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LxmertCon...
15
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWith...
15
1
# 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 tak...
15
import math def UpperCAmelCase ( a_ , a_ = 0 , a_ = 0 ) -> list: """simple docstring""" __A = end or len(a_ ) for i in range(a_ , a_ ): __A = i __A = array[i] while temp_index != start and temp_index_value < array[temp_inde...
15
1
def UpperCAmelCase ( a_ ) -> List[Any]: """simple docstring""" __A = [] __A = set({"(", "[", "{"} ) __A = set({")", "]", "}"} ) __A = {"{": "}", "[": "]", "(": ")"} for i in range(len(a_ ) ): if s[i] in open_brackets: ...
15
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
15
1
from typing import Dict from .base import GenericTensor, Pipeline class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def UpperCamelCase_ ( self : int ,A : Optional[int]=None ,A : Tuple=None ,A : List[str]=None ,**A ...
15
SCREAMING_SNAKE_CASE :Any = 256 # Modulus to hash a string SCREAMING_SNAKE_CASE :Union[str, Any] = 100_0003 def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = len(a_ ) if p_len > t_len: ...
15
1
import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
15
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
1
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin SCREAMI...
15
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = {} __A = job["started_at"] __A = job["completed_at"] __A = date_parser.parse(a_ ) ...
15
1
import flax.linen as nn import jax import jax.numpy as jnp class UpperCAmelCase ( nn.Module ): '''simple docstring''' snake_case_ = 42 snake_case_ = jnp.floataa def UpperCamelCase_ ( self : int ): __A = nn.Conv( self.out_ch...
15
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" __A = args.pruning_method __A = args.threshold __A = args.mod...
15
1
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) SCREAMING_SN...
15
1
def UpperCAmelCase ( a_ , a_ , a_ ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def UpperCAmelCase ( a_ , a_ , a_ ) -> float: """simple docstring""" return round(float((moles * 0.0_821 * tempera...
15
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'): SCREAMING_SNAKE_CASE :Any = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resampl...
15
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.g...
15
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_available, is_torch_available ...
15
def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = [0] * len(a_ ) __A = [] __A = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(a_ ) ): ...
15
1
def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by not taking any element # hence True/1 for i in ...
15
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" return sum(param.float().sum...
15
1
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, get_...
15
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
1
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient SCREAMING_SNAKE_CASE :int = WebClient(token=os.environ['CI_SLACK_BOT_TOKEN']) def UpperCAmelCase ( a_ ) -> Un...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
1
import math class UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[int] ,A : Dict=0 ): # a graph with Node 0,1,...,N-1 __A = n __A = [ [math.inf for j in range(0 ,A )] for i in range(0 ,A ) ] # adjacenc...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
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 UpperCAmelCase ( datasets.BuilderConfig ): '''simple docstring''' snake_case_ = None...
15
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
1
def UpperCAmelCase ( a_ ) -> float: """simple docstring""" __A = 0 while len(a_ ) > 1: __A = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): __A = files.index(min(a_ ) ) temp...
15
# 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 SCREAMING_SNAKE_CASE...
15
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record SCREAMING_SNAKE_CASE :Optional[int] = '\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n ...
15
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
15
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def UpperCAmelCase ( a_ ) -> Optional[Any]: ...
15
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
1
class UpperCAmelCase : '''simple docstring''' def __init__( self : Any ): __A = {} # Mapping from char to TrieNode __A = False def UpperCamelCase_ ( self : List[str] ,A : list[str] ): for word in words: self.insert(A ) ...
15
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
15
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = {} __A = job["started_at"] __A = job["completed_at"] __A = date_parser.parse(a_ ) ...
15
import numpy as np def UpperCAmelCase ( a_ , a_ , a_ = 1E-12 , a_ = 1_0_0 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(a_ )[0] == np.shape(a_ )[1] # Ensure proper dimensionality. assert np.shape(a_ )[0] == np.shape(a_ )[0] ...
15
1
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...image_pr...
15
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWith...
15
1
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_config...
15
import math def UpperCAmelCase ( a_ , a_ = 0 , a_ = 0 ) -> list: """simple docstring""" __A = end or len(a_ ) for i in range(a_ , a_ ): __A = i __A = array[i] while temp_index != start and temp_index_value < array[temp_inde...
15
1
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Union[str, Any] = { 'vocab_file': 'vocab...
15
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
15
1
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) SCREAMING_SN...
15
SCREAMING_SNAKE_CASE :Any = 256 # Modulus to hash a string SCREAMING_SNAKE_CASE :Union[str, Any] = 100_0003 def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = len(a_ ) if p_len > t_len: ...
15
1
from sklearn.metrics import recall_score import datasets SCREAMING_SNAKE_CASE :Union[str, Any] = '\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives and...
15
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Any = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'studio-...
15
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = {} __A = job["started_at"] __A = job["completed_at"] __A = date_parser.parse(a_ ) ...
15
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available SCREAMING_SNAKE_CASE :Optional[int] = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): ra...
15
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" __A = args.pruning_method __A = args.threshold __A = args.mod...
15
1
from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCAmelCase ( ) -> Optional[int]: """simple docstring""" __A = ArgumentParser("Diffusers CLI tool" , usage="diffusers-cli <command> [<args>]" ) __A = parser.add_subparsers(help="diffusers-...
15
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) SCREAMING_SN...
15
1
def UpperCAmelCase ( a_ , a_ , a_ ) -> Optional[int]: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(a_ , n - 1 , a_ ) * a) % mod else: __A = binary_exponentiation(a_ , n / 2 , a_ ...
15
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'): SCREAMING_SNAKE_CASE :Any = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resampl...
15
1
def UpperCAmelCase ( a_ , a_ ) -> float: """simple docstring""" if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(a_ ) * abs(a_ ) if __name__ == "__main__": import doctest doctest.testmod(verbose=Tr...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split SCREAMING_SNAKE_CASE :str = datasets.load_iris() SCREAMING_SNAKE_CASE :Dict = np.array(data['data']) SCREAMING_SNAKE_CASE :Union[str, Any] ...
15
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15
1
def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" return x if y == 0 else greatest_common_divisor(a_ , x % y ) def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" return (x * y) // greatest_common_divisor(a_ , a_ ...
15
def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = [0] * len(a_ ) __A = [] __A = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(a_ ) ): ...
15
1
import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE :Dict = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE :int = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True...
15
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" return sum(param.float().sum...
15
1
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def UpperCAmelCase ( a_ ) -> np.ndarray: """simple docstring""" return input_array.reshape((input_array.size, 1) ) def UpperCAmelC...
15
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
1
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness SCREAMING_SNAKE_CASE :Dict = '\\n@misc{chen2021evaluating,\n title={Evaluating Larg...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
1
import argparse import collections import json import os import re import string import sys import numpy as np SCREAMING_SNAKE_CASE :Any = re.compile(R'\b(a|an|the)\b', re.UNICODE) SCREAMING_SNAKE_CASE :List[str] = None def UpperCAmelCase ( ) -> Any: """simple ...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = "EncodecFeatureExtractor" snake_case_ = ("T5To...
15
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
1
import argparse import os import re import packaging.version SCREAMING_SNAKE_CASE :int = 'examples/' SCREAMING_SNAKE_CASE :Dict = { 'examples': (re.compile(R'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(R'^__version...
15
# 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 SCREAMING_SNAKE_CASE...
15
1
SCREAMING_SNAKE_CASE :List[str] = '0.18.2' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_libro...
15
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
15
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() SCREAMING_...
15
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
1
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxMode...
15
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
15
1
from __future__ import annotations import time SCREAMING_SNAKE_CASE :Dict = list[tuple[int, int]] SCREAMING_SNAKE_CASE :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], [0, 0, 1, 0, 0, 0, 0], ...
15
import numpy as np def UpperCAmelCase ( a_ , a_ , a_ = 1E-12 , a_ = 1_0_0 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(a_ )[0] == np.shape(a_ )[1] # Ensure proper dimensionality. assert np.shape(a_ )[0] == np.shape(a_ )[0] ...
15
1
import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup SCREAMING_SNAKE_CASE :Tuple = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' ' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582' }...
15
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWith...
15
1
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation SCREAMING_SNA...
15
import math def UpperCAmelCase ( a_ , a_ = 0 , a_ = 0 ) -> list: """simple docstring""" __A = end or len(a_ ) for i in range(a_ , a_ ): __A = i __A = array[i] while temp_index != start and temp_index_value < array[temp_inde...
15
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,...
15
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
15
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
15
SCREAMING_SNAKE_CASE :Any = 256 # Modulus to hash a string SCREAMING_SNAKE_CASE :Union[str, Any] = 100_0003 def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = len(a_ ) if p_len > t_len: ...
15
1
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_common import ModelTesterMixin, ids_tensor, ra...
15
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
1
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @slow ...
15
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = {} __A = job["started_at"] __A = job["completed_at"] __A = date_parser.parse(a_ ) ...
15
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def UpperCAmelCase ( ) -> Dict: """simple docstring""" __A = ArgumentParser( description=( "PyTorch TPU dist...
15
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" __A = args.pruning_method __A = args.threshold __A = args.mod...
15
1
def UpperCAmelCase ( a_ = 1_0_0_0 ) -> int: """simple docstring""" __A = 2**power __A = 0 while n: __A , __A = r + n % 1_0, n // 1_0 return r if __name__ == "__main__": print(solution(int(str(input()).strip())))
15
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) SCREAMING_SN...
15
1
from __future__ import annotations def UpperCAmelCase ( a_ ) -> float: """simple docstring""" if not nums: raise ValueError("List is empty" ) return sum(a_ ) / len(a_ ) if __name__ == "__main__": import doctest doctest.testmod()
15
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'): SCREAMING_SNAKE_CASE :Any = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resampl...
15
1
import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = "M-CLIP" def __init__( self : Any ,A : int=10_24 ,A : Dict=7_68 ...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
import math def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = 0 __A = 0 while num > 0: __A = num % 8 __A = octal + (remainder * math.floor(math.pow(1_0 , a_ ) )) counter += 1 __A = math.floor(nu...
15
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15
1
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def UpperCAmelCase ( a_ ) -> Union[str, Any]: """simple docstring""" return getitem, k def UpperCAmelCase ( a_ , a_ ) -> Any: """simple doc...
15
def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = [0] * len(a_ ) __A = [] __A = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(a_ ) ): ...
15
1
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class UpperCAmelCase : '''simple docstring''' snake_case_ = 42 # [batch_size x 3] snake_case_ = 42 # [batch_size x 3] snake_case_ = 42 # [batch_siz...
15
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" return sum(param.float().sum...
15
1
SCREAMING_SNAKE_CASE :int = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def UpperCAmelCase ( ) -> None: """simple docstring""" __A = input("Enter message: " ) __A = input("Enter key [alphanumeric]: " ) __A = input("Encrypt/Decrypt [e/d]: " ) if m...
15
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
1
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL SCREAMING_SNAKE_CASE :str = version.parse(version.parse(torch.__version__).base_version) < version.parse('1.11') def UpperCAmelCase ( a_ ,...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
1
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def UpperCAmelCase ( a_ , a...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow SCREAMING_SNAKE_CASE :List[str] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classif...
15
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
1
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
# 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 SCREAMING_SNAKE_CASE...
15
1
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
15
1
from typing import Dict, Iterable, 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_forma...
15
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
1
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class UpperCAmelCase ( enum.Enum ): ...
15
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
15
1
from __future__ import annotations from collections import deque class UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[Any] ,A : list[str] ): __A = [] self.adlist.append( {"value": "", "next_states": [], "fail_state": 0, "ou...
15
import numpy as np def UpperCAmelCase ( a_ , a_ , a_ = 1E-12 , a_ = 1_0_0 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(a_ )[0] == np.shape(a_ )[1] # Ensure proper dimensionality. assert np.shape(a_ )[0] == np.shape(a_ )[0] ...
15
1
from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=__SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = ["torch", "scipy"] def __init__( self : List[Any] ,*A : Any ,**A : int ): requires_backe...
15
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWith...
15
1
SCREAMING_SNAKE_CASE :int = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} SCREAMING_SNAKE_CASE :Optional[Any] = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCAmelCase ( a_ , a_ , a_ ) -> list[int]: """simple docstring""" __A ...
15
import math def UpperCAmelCase ( a_ , a_ = 0 , a_ = 0 ) -> list: """simple docstring""" __A = end or len(a_ ) for i in range(a_ , a_ ): __A = i __A = array[i] while temp_index != start and temp_index_value < array[temp_inde...
15
1
from __future__ import annotations from fractions import Fraction def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def UpperCAmelCase ( a_ ) -> l...
15
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
15
1
import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECORDS_FILENAME, RealmRetriev...
15
SCREAMING_SNAKE_CASE :Any = 256 # Modulus to hash a string SCREAMING_SNAKE_CASE :Union[str, Any] = 100_0003 def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = len(a_ ) if p_len > t_len: ...
15
1
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = SwinConfig(image_size=1_9_2 ) if "base" in mo...
15
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
1
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 ...utils import logging fro...
15
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = {} __A = job["started_at"] __A = job["completed_at"] __A = date_parser.parse(a_ ) ...
15
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE :int = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDependency...
15
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" __A = args.pruning_method __A = args.threshold __A = args.mod...
15
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging SCREAMING_SNAKE_CASE :List[str] = logging.get_logger(__name__) def UpperCAmelCase ( a_=None , a_=None ) -> Any: ...
15
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :List[Any] = logging.get_logger(__name__) SCREAMING_SN...
15
1
def UpperCAmelCase ( a_ , a_ , a_ ) -> int: """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: __A = _modexpt(a_ , exponent // 2 , a_ ) % modulo_value return (x * x) % modulo_value else: return (base *...
15
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'): SCREAMING_SNAKE_CASE :Any = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resampl...
15
1
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property from ...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline SCREAMING_SNAKE_CASE :Tuple = argparse.ArgumentParser('Stable Diffusion script with intel optimization', add_help=False) parser.add_argument('--dpm', ac...
15
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15
1
import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE :Optional[int] = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' SCREAMING_SNAKE_CASE :Tuple = ...
15
def UpperCAmelCase ( a_ ) -> Optional[int]: """simple docstring""" __A = [0] * len(a_ ) __A = [] __A = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(a_ ) ): ...
15
1
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 :Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase ( a_ ) -> List[str]: """simple docstring""" return sum(param.float().sum...
15
1
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_tokenization_commo...
15
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 :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CA...
15
1
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE :Dict = get_tests_dir('fixtures/spiec...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return [tuple(a_ )] __A = [] def generate(a_ , a_ ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 , ...
15
1
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = (KDPMaDiscreteScheduler,) snake_case_ ...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
from __future__ import annotations from typing import Any def UpperCAmelCase ( a_ ) -> int: """simple docstring""" if not postfix_notation: return 0 __A = {"+", "-", "*", "/"} __A = [] for token in postfix_notation: if token in operations: ...
15
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
1
from typing import List import numpy as np def UpperCAmelCase ( a_ ) -> int: """simple docstring""" __A = {key: len(a_ ) for key, value in gen_kwargs.items() if isinstance(a_ , a_ )} if len(set(lists_lengths.values() ) ) > 1: raise RuntimeError...
15
# 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 SCREAMING_SNAKE_CASE...
15
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 UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''si...
15
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE :List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
15
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ ...
15
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
1
from maths.prime_check import is_prime def UpperCAmelCase ( a_ ) -> int: """simple docstring""" if not isinstance(a_ , a_ ): __A = F'''Input value of [number={number}] must be an integer''' raise TypeError(a_ ) if is_prime(a_ ) and is_prime(n...
15
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
15
1