code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings SCREAMING_SNAKE_CASE__ : int = log...
643
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
1
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class _SCREAMING_SNAKE_CASE : __SCREAMING_SNAKE_CASE = 42 # [batch_size x 3] __SCREAMING_SNAKE_CASE = 42 # [batch_size x 3] __SCREAMING_SNAKE_CASE = 42 ...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _SCREAMING_SNAKE_CASE ( A ): def __snake_case( self , A_ ): return 0.0 def a__ ( snake_case__ : np.nda...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_...
643
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
643
1
def a__ ( snake_case__ : str ): _UpperCAmelCase : Any = 0 # if input_string is "aba" than new_input_string become "a|b|a" _UpperCAmelCase : Dict = """""" _UpperCAmelCase : Dict = """""" # append each character + "|" in new_string for...
643
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : List[Any] = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytor...
643
1
import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...test_con...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
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__ : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ ...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
import pprint import requests SCREAMING_SNAKE_CASE__ : List[Any] = 'https://zenquotes.io/api' def a__ ( ): return requests.get(API_ENDPOINT_URL + """/today""" ).json() def a__ ( ): return requests.get(API_ENDPOINT_URL + """/random""" ).json() if __name__ == "__...
643
from PIL import Image def a__ ( snake_case__ : Image , snake_case__ : int ): _UpperCAmelCase : Optional[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(snake_case__ : int ) -> int: return int(128 + factor * (c - 128) ...
643
1
import os import string import sys SCREAMING_SNAKE_CASE__ : List[str] = 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, '...
643
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] =...
643
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ : Any = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Conv...
643
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE...
643
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
643
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
1
from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=A ): __SCREAMING_SNAKE_CASE = ['''torch''', '''transformers''', '''onnx'''] def __init__( self , *A_ , **A_ ): requires_backends(self , ["""torc...
643
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
1
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
643
from random import randint, random def a__ ( snake_case__ : int , snake_case__ : int , snake_case__ : int , snake_case__ : bool = False , snake_case__ : bool = False , snake_case__ : int = 5 , ): _Upper...
643
1
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def a__ ( snake_case__ : ...
643
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__...
643
1
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast SCREAMING_SNAKE_CASE__ : Tuple = datasets.utils.logging.get_logger(__name__) @dataclass class _SCREAMI...
643
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__ : Optional[i...
643
1
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def a__ ( snake_case__ : Any ): if not is_accelerate_available(): return method _UpperCAmelCase : Optional[Any] = version.parse(acceler...
643
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
643
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ : Optional[int] = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership functi...
643
import os import string import sys SCREAMING_SNAKE_CASE__ : List[str] = 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, '...
643
1
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkou...
643
import copy 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 from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ : Optional[int] = log...
643
1
import random def a__ ( snake_case__ : int , snake_case__ : float , snake_case__ : bool = False ): _UpperCAmelCase : dict = {i: [] for i in range(snake_case__ )} # if probability is greater or equal than 1, then generate a complete ...
643
SCREAMING_SNAKE_CASE__ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr...
643
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = ['''image_processor''', '''tokenizer'''] __SCREAMING_SNAKE_CASE = '''CLIPImageProcessor''...
643
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...
643
1
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') SCREAMING_SNAKE_CASE__ : Optional[int] = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) SCREAMING_SNAKE_CASE__ : ...
643
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...
643
1
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def a__ ( snake_case__ : Tuple ...
643
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
643
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging SCREAMING_SNAKE_CASE__ : int = logging.get_logger(...
643
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer from .tokeniz...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
1
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter SCREAMING_SNAKE_CASE__ : List[str] ...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py SCREAMING_SNAKE_CASE__ : List[Any] = '.' if __name__ == "__main__": SCREAMING_SNAKE_CASE__ : Dict = os.path.join(REPO_PATH,...
643
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
643
1
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def a__ ( snake_case__ : str , snake_case__ : str ): # ===== initialization ===== _UpperCAmelCase : List[str] ...
643
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : List[Any] = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytor...
643
1
def a__ ( snake_case__ : float ): return 10 - x * x def a__ ( snake_case__ : float , snake_case__ : float ): # Bolzano theory in order to find if there is a root between a and b if equation(snake_case__ ) * equation(snake_case__ ) >= 0: ...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
1
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .token...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
643
from PIL import Image def a__ ( snake_case__ : Image , snake_case__ : int ): _UpperCAmelCase : Optional[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(snake_case__ : int ) -> int: return int(128 + factor * (c - 128) ...
643
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def a__ ( snake_case__ : str , snake_case__ : complex , snake_case__ : str = "x" , snake_case__ : float = 10**-10 , snake_case__ : int = 1 ...
643
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] =...
643
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : int = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class ...
643
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE...
643
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ : int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : ...
643
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ : List[Any] = {} try: if not is_sentencepiece_available(): raise Optional...
643
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
1
import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Dict = logging.get_logger(__nam...
643
from random import randint, random def a__ ( snake_case__ : int , snake_case__ : int , snake_case__ : int , snake_case__ : bool = False , snake_case__ : bool = False , snake_case__ : int = 5 , ): _Upper...
643
1
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel from transf...
643
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__...
643
1
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline SCREAMING_SNAKE_CASE__ : Optional[int] = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value net...
643
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__ : Optional[i...
643
1
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_common...
643
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
643
1
import colorsys from PIL import Image # type: ignore def a__ ( snake_case__ : float , snake_case__ : float , snake_case__ : int ): _UpperCAmelCase : int = x _UpperCAmelCase : str = y for step in range(snake_case__ ...
643
import os import string import sys SCREAMING_SNAKE_CASE__ : List[str] = 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, '...
643
1
def a__ ( snake_case__ : int , snake_case__ : int ): if not isinstance(snake_case__ , snake_case__ ): raise ValueError("""iterations must be defined as integers""" ) if not isinstance(snake_case__ , snake_case__ ) or not number >= 1: raise V...
643
import copy 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 from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ : Optional[int] = log...
643
1
from datetime import datetime as dt import os from github import Github SCREAMING_SNAKE_CASE__ : List[str] = [ 'good first issue', 'good second issue', 'good difficult issue', 'feature request', 'new model', 'wip', ] def a__ ( ): _UpperCAmelCase : int ...
643
SCREAMING_SNAKE_CASE__ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr...
643
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
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...
643
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # ...
643
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...
643
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ : Union[str, Any] = { 'configuration_layoutlmv3': [ ...
643
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
643
1
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): def __snake_case( self ): _UpperCAmelCase : int = inspect.getfil...
643
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
1
def a__ ( snake_case__ : float , snake_case__ : float ): return price * (1 + tax_rate) if __name__ == "__main__": print(F'{price_plus_tax(100, 0.25) = }') print(F'{price_plus_tax(125.50, 0.05) = }')
643
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE__ : Union[str, Any] = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBert...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_param...
643
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
643
1
def a__ ( snake_case__ : int = 50 ): _UpperCAmelCase : Tuple = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ways_number[row_length] += ...
643
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : List[Any] = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytor...
643
1
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel SCREAMING_SNAKE_CASE__ : Dict = HfApi() SCREAMING_SNAKE_CASE__ : Dict = {} # fmt: off SCREAMING_SNAKE_CASE__ : List[str] = torch.tensor([ -0.7_515, -1.6_883, 0...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def a__ ( ): _UpperCAmelCase : int = [randint(-1000 , 1000 ) for i in range(10 )] _UpperCAmelCase : Optional[int] = randint(-5000...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
from __future__ import annotations from typing import Any def a__ ( snake_case__ : list[Any] ): create_state_space_tree(snake_case__ , [] , 0 ) def a__ ( snake_case__ : list[Any] , snake_case__ : list[Any] , snake_case__ :...
643
from PIL import Image def a__ ( snake_case__ : Image , snake_case__ : int ): _UpperCAmelCase : Optional[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(snake_case__ : int ) -> int: return int(128 + factor * (c - 128) ...
643
1
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration SCREAMING_SNAKE_CASE__ : List[Any] = 500_000 SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : Dict = os.path.split(__file__) SCREAMING_SNAK...
643
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] =...
643
1
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...
643
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE...
643
1
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impor...
643
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ : Union[str, Any] = { 'configuration_resnet': ['RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Re...
643
from random import randint, random def a__ ( snake_case__ : int , snake_case__ : int , snake_case__ : int , snake_case__ : bool = False , snake_case__ : bool = False , snake_case__ : int = 5 , ): _Upper...
643
1
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class _SCREAMING_SNAKE_CASE ( A ): # to overwrite at feature extractactor specific tests ...
643
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__...
643
1
from math import sqrt def a__ ( snake_case__ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number are...
643
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__ : Optional[i...
643
1
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModel...
643
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
643
1
SCREAMING_SNAKE_CASE__ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr...
643
import os import string import sys SCREAMING_SNAKE_CASE__ : List[str] = 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, '...
643
1
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class _SCR...
643
import copy 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 from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ : Optional[int] = log...
643
1
from __future__ import annotations import typing from collections import Counter def a__ ( snake_case__ : int ): _UpperCAmelCase : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(snake_case__ , ...
643
SCREAMING_SNAKE_CASE__ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr...
643
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = (DDPMScheduler,) def __snake_case( self , **A_ ): _UpperCAmelCase : Union[str, An...
643
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...
643
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _SCREAMING_SNAKE_CASE ( A ): def __snake_case( self , A_ ): with open(A_ , encoding="""utf-8""" ) as input_file: _UpperCAmelCase :...
643
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...
643
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__...
643
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
643
1
from __future__ import annotations def a__ ( snake_case__ : list[int] , snake_case__ : int ): _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Dict = len(snake_case__ ) - 1 while i < j: if nums[i] + nums[j] == target: retur...
643
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ : List[str] = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig']} try: if not is_visi...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
1
import os from distutils.util import strtobool def a__ ( snake_case__ : Optional[Any] , snake_case__ : Tuple ): for e in env_keys: _UpperCAmelCase : Union[str, Any] = int(os.environ.get(snake_case__ , -1 ) ) if val >= 0: return...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEncoder, ...
643
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
643
1
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : List[Any] = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytor...
643
1
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device SCREAMING_SNAKE_CASE__ : Tuple = False class _SCREAMING_SNAKE_CASE ( unittest.T...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
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 fro...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
import torch from diffusers import DiffusionPipeline class _SCREAMING_SNAKE_CASE ( A ): def __init__( self , A_ , A_ ): super().__init__() self.register_modules(unet=A_ , scheduler=A_ ) def __call__( self ): _UpperCAmelC...
643
from PIL import Image def a__ ( snake_case__ : Image , snake_case__ : int ): _UpperCAmelCase : Optional[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(snake_case__ : int ) -> int: return int(128 + factor * (c - 128) ...
643
1
# This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests from os.path import join...
643
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] =...
643
1
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTester fr...
643
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE...
643
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time SCREAMING_SNAKE_CASE__ : Union[str, Any] = Lock() def a__ ( snake_case__ : List[Any] , snake_case__ : List[str] , snake_case__...
643
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExtractio...
643
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
1
def a__ ( snake_case__ : str ): return "".join(chr(ord(snake_case__ ) - 32 ) if """a""" <= char <= """z""" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
643
from random import randint, random def a__ ( snake_case__ : int , snake_case__ : int , snake_case__ : int , snake_case__ : bool = False , snake_case__ : bool = False , snake_case__ : int = 5 , ): _Upper...
643
1
# Imports import numpy as np class _SCREAMING_SNAKE_CASE : def __init__( self , A_=None , A_=None , A_=None , A_=None , A_=None ): self.set_matricies(red=A_ , green=A_ , blue=A_ , red_edge=A_ , nir=A_ ...
643
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ : List[str] = logging.get_logger(__...
643
1
from __future__ import annotations def a__ ( snake_case__ : list[float] , snake_case__ : str ): print(f'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(snake_case__ ): print(f'''{i}\t\t{d}''' ) def a__ ( snake_case__ ...
643
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__ : Optional[i...
643
1
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__ : str = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resampling.B...
643
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
643
1
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = (IPNDMScheduler,) __SCREAMING_SNAKE_CASE = (('''num_inference_steps''', 5_0),) de...
643
import os import string import sys SCREAMING_SNAKE_CASE__ : List[str] = 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, '...
643
1
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice...
643
import copy 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 from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ : Optional[int] = log...
643
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Dict = { 'SenseTime/deformable-detr': 'https://huggingf...
643
SCREAMING_SNAKE_CASE__ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr...
643
1
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask fr...
643
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...
643
1
def a__ ( snake_case__ : int , snake_case__ : int ): if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _UpperCAmelCase : Union[str, Any] = str(bin(snake_case__ ) )[2:] # remove the leading "0b" _UpperCAm...
643
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...
643
1
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def a__ ( snake_case__ ...
643
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyN...
643
1
import numpy as np def a__ ( snake_case__ : np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
643
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ : List[Any] = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ : List[Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import...
643
1
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional im...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return x if y == 0 else greatest_common_divisor(snake_case__ , x % y ) def a__ ( snake_case__ : int , snake_case__ : int ): return (x * y) // greatest_common_divisor(sna...
643
1
SCREAMING_SNAKE_CASE__ : Tuple = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } def a__ ( snake_case__ : dict , snake_case__ : int , snake_case__...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
643
1
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def a__ ( snake_case__ : np.ndarray , snake_case__ : np.ndarray ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(snake_case__ , snake_case__ ) ...
643
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : List[Any] = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytor...
643
1
def a__ ( snake_case__ : Optional[int] , snake_case__ : Optional[Any] , snake_case__ : List[Any] , snake_case__ : Optional[int] , snake_case__ : Dict , snake_case__ : Dict ): if index == r: for j in range(...
643
def a__ ( snake_case__ : int , snake_case__ : int ): return 1 if input_a == input_a else 0 def a__ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 , 1 ...
643
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ : int = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mobile...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, ...
643
from PIL import Image def a__ ( snake_case__ : Image , snake_case__ : int ): _UpperCAmelCase : Optional[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(snake_case__ : int ) -> int: return int(128 + factor * (c - 128) ...
643
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): __SCREAMING_SNAKE_CASE ...
643
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] =...
643
1
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start_docstrings_...
643
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE...
643
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): def __snake_case( self ): _UpperCAmelCase : Optional[int] = [ """safety_checker/pytorch_model.bin""", ...
643
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=A ) class _SCREAMING_SNAKE_CASE ( A ): __SCREAMING_SNAKE_CASE = field(default='''image-clas...
643
1
import math import flax.linen as nn import jax.numpy as jnp def a__ ( snake_case__ : jnp.ndarray , snake_case__ : int , snake_case__ : float = 1 , snake_case__ : float = 1 , snake_case__ : float = 1.0e4 , snake_case__ ...
643
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
1