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
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', # See all Cvt models at https://h...
60
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
0
from __future__ import annotations from collections.abc import Callable def _A ( lowerCAmelCase_ : Callable[[int | float], int | float] , lowerCAmelCase_ : int | float , lowerCAmelCase_ : int | float , lowerCAmelCase_ : int = 100 , ): """simple docstri...
61
# 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
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine impo...
62
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
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowerCamelCase__ ( __lowerCamelCase : int ): __UpperCAmelCase : Optional[Any] = prime_factors(__lowerCamelCase ) if is_square_free(__lowerCamelCase ...
63
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
0
lowercase_ : str = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
64
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
0
"""simple docstring""" import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def lowerCAmelCase ( __UpperCamelCase ): '''simple docstring''' ...
65
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
0
import os import pytest from attr import dataclass UpperCamelCase = "us-east-1" # defaults region @dataclass class lowerCAmelCase_ : _UpperCamelCase : str _UpperCamelCase : int = "arn:aws:iam::558105141721:role/sagemaker_execution_role" _UpperCamelCas...
66
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
0
class A_ : """simple docstring""" def __init__( self : int ,__A : List[str] ,__A : Tuple ,__A : Union[str, Any] ) -> Optional[Any]: _lowercase = name _lowercase ...
67
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
0
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSch...
68
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
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[Any] = logging.get_logger(__name__) a : List[str] = {} class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): __SCREAMING_SNAKE_CASE...
69
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
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : Union[str, Any] = { "asapp/sew-tiny-100k": "https://huggingface...
70
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
0
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : int ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for...
71
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
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : List[Any] = logging.get_logger(__name__) _UpperCAmelCase : Optional[int] = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json'...
72
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
0
import numpy as np import datasets a_ : str = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was introduced by Prof...
73
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
0
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
74
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
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__a ) class lowerCamelCase_ ( __a ): lowerCAmelCase__ = field(default='language-modeling...
75
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
0
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): if not isinstance(__UpperCamelCase , __UpperCamelCase ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) __lowercase : Optional[int] = 0 while number: ...
76
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
0
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging A = loggi...
77
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_: Tuple ={'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP'...
78
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
0
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class UpperCAme...
79
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
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Ac...
80
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
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _snake_case : Optional[Any] = False class a (unittest.TestCase ): """simple docstrin...
81
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
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_p...
82
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
0
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow lowerCAmelCase__ = logging.getLogger() @unittest.skip("T...
83
# 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
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, temp...
84
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
0
# 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 #...
85
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
0
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class _a ( snake_case_ , snake_case_ ): """simple docstring""" @register_to_con...
86
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
0
import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig if TYPE_CHECKING: from ... import Pr...
87
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
0
"""simple docstring""" def _snake_case ( __snake_case : str , __snake_case : list[str] ): """simple docstring""" _lowerCamelCase : int = """""" for word_or_phrase in separated: if not isinstance(__snake_case , __snake_ca...
88
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
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _lowerCamelCase( unittest.TestCase ): def UpperCamelCase ( ...
89
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
0
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __UpperCAmelCase = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''...
90
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
0
"""simple docstring""" import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from tr...
91
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
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available()...
92
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
0
"""simple docstring""" import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
93
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
0
'''simple docstring''' import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('p...
94
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
0
"""simple docstring""" from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
95
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
0
"""simple docstring""" def a ( __UpperCAmelCase : list[int] , __UpperCAmelCase : int ) -> bool: __magic_name__: Optional[int] = len(__UpperCAmelCase ) __magic_name__: str = [[False] * (required_sum + 1) for _ in ra...
96
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
0
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_ten...
97
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
0
'''simple docstring''' from __future__ import annotations def a__ ( lowercase : list, lowercase : int ) -> List[Any]: """simple docstring""" if len(lowercase ) <= 1 or n <= 1: return insert_next(lowercase, n - 1 ) rec_insertion_sort(low...
98
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
0
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 ...
99
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
0
def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> Tuple: SCREAMING_SNAKE_CASE__ = [0 for i in range(r + 1 )] # nc0 = 1 SCREAMING_SNAKE_CASE__ = 1 for i in range(1 , n + 1 ): # to compute current row from previous row. ...
100
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
0
import re from filelock import FileLock try: import nltk lowerCAmelCase__ : List[str] =True except (ImportError, ModuleNotFoundError): lowerCAmelCase__ : Union[str, Any] =False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('...
101
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
0
"""simple docstring""" import qiskit def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): UpperCamelCase : Union[str, Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register ...
102
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
0
"""simple docstring""" snake_case = 6_5_5_2_1 def snake_case ( lowerCAmelCase_ ) -> int: _snake_case = 1 _snake_case = 0 for plain_chr in plain_text: _snake_case = (a + ord(lowerCAmelCase_ )) % MOD_ADLER _snake_case = ...
103
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
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = ...
104
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
0
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, BertEmbeddings, BertLay...
105
# 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
0
def lowerCamelCase_ ( lowerCAmelCase__ : list[int] ) -> int: '''simple docstring''' if not numbers: return 0 if not isinstance(lowerCAmelCase__ , (list, tuple) ) or not all( isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) for numb...
106
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
0
'''simple docstring''' import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( Autoencod...
107
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
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __a: Any = TypeVar('''T''') class SCREAMING_SNAKE_CASE__ ( Generic[T] ): '''simple docstring''' _lowerCamelCase = 42 # Cache store of keys _lowerCamelCase ...
108
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
0
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __a ( unittest.TestCase ): def UpperCAmelCase__ ( self : Any ): '''simple docstring...
109
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
0
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVPr...
147
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
0
def lowerCamelCase__ ( a : list[int] , a : list[int] , a : int ) -> Union[str, Any]: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(snake_case__ ) ) def lowe...
395
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
0
'''simple docstring''' import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup _A : Union[str, Any] = logging.get_logger(__...
427
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
0
# 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 ...
556
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
0
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
579
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase: int ={ 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_...
607
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
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ....
494
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
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' __A = JukeboxTokenizer __A = { '''artist''': '''Zac Brown Band''', '''genres''...
547
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
0
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : float ): '''simple docstring''' return 10 - x * x def lowercase ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float ): '''simple...
602
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
0
from __future__ import annotations def a__ (__lowercase :list[float] , __lowercase :str ) -> Dict: print(f"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(snake_case__ ): print(f"""{i}\t\t{d}""" ) def a__ (__lowercase ...
206
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { 'configuration_layoutlmv3': [ 'LAYOUTLMV3_PRETRA...
586
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
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', 'Conv...
147
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
0
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 lowerCamelCase__ ( a ...
395
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
0
'''simple docstring''' import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging _A : List[str] = logging.get_logger(__name__) _A : Any = R'\n Args:\n inp...
427
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
0
from PIL import Image def lowerCAmelCase_ (lowerCAmelCase__: Image , lowerCAmelCase__: int ): """simple docstring""" UpperCAmelCase_: Optional[Any] = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(lowerCAmelCase__: int )...
556
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
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .test_pipelines...
579
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
0
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowerCAmelCase: Dict =HfApi() lowerCAmelCase: Dict ={} # fmt: off lowerCAmelCase: List[str] =torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0....
607
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
0
'''simple docstring''' import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_...
494
# 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
0
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_params ...
547
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
0
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): __A : str = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilin...
602
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
0
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__ (__lowercase :...
206
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
0
"""simple docstring""" import math import tensorflow as tf from packaging import version def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> Dict: lowercase__: Tuple = tf.convert_to_tensor(snake_case__ ) lowercase__: Optional[Any] = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2....
586
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
0
def _lowercase ( a__ : Optional[int] , a__ : Optional[Any] , a__ : List[Any] , a__ : Optional[int] , a__ : Dict , a__ : Dict ) -> List[str]: """simple docstring""" if index == r: for j in range(snake_case__ ...
147
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
0
from random import shuffle import tensorflow as tf from numpy import array def lowerCamelCase__ ( a : Tuple , a : str ) -> Dict: """simple docstring""" a__ :int = int(snake_case__ ) assert noofclusters < len(snake_case__ ) # Find out the ...
395
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
0
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' _SCREAMING_SNAKE_CASE : Optional[Any] = ["""image_...
427
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
0
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor...
556
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
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline SCREAMING_SNAKE_CASE = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value network 'scale_grad_by_st...
579
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
0
"""simple docstring""" def __snake_case ( __A ) -> Optional[Any]: 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()
607
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
0
'''simple docstring''' 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, logg...
494
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
0
def lowerCAmelCase__ ( a__ = 50 ) ->str: '''simple docstring''' _UpperCamelCase = [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] ...
547
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
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class _a ( metaclass=lowerCAmelCase): """simple docstring""" UpperCamelCase__ = ["""torch""", """transformers""", """onnx"""] def __init__( self : Optional[int] , *__UpperCamelC...
602
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
0
from math import pow, sqrt def a__ (*__lowercase :float ) -> int: _A : Any = len(snake_case__ ) > 0 and all(value > 0.0 for value in values ) return result def a__ (__lowercase :float , __lowercase :float ) -> Tuple: return ( ...
206
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
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer __A = logging.get_logger(__name__) __A ...
586
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
0
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tokenization_utils...
147
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
0
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...
395
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
0
'''simple docstring''' from __future__ import annotations from typing import Any def UpperCamelCase_ ( snake_case_ : list[Any] ) -> int: '''simple docstring''' create_state_space_tree(snake_case__ , [] , 0 ) def UpperCamelCase_ ( snake_case...
427
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
0
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate a : Any = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('', '|', '|'), ...
556
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class lowerCamelCase ( lowercase__ ): ...
579
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
0
"""simple docstring""" lowerCAmelCase: Tuple ={ 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } def __snake_case ( __A ,__A ,__A ) -> str: lowerc...
607
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
0
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def __UpperCAmelCase ( a_: List[Any], a_: List[Any] ): _UpperCAmelCase : int = k_size //...
494
# 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
0
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_to_...
547
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
0
"""simple docstring""" import random def lowercase ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : bool = False ): '''simple docstring''' _UpperCAmelCase = {i: [] for i in rang...
602
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
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaF...
206
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
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import 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_attentio...
586
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
0
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def _lowercase ( a__ : Any , a__ : Union[str, Any] , a__ : Tuple ) -> Union[str, Any]: """simple docstring""" _UpperCamelCase = AutoConfig....
147
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class lowerCAmelCase_ ( _a): ...
395
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
0
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class _lowercase ( unittest.TestCase ): '''simple docstring''' def a ( self : List[str] ) -> Tuple: __lowerCAmelCase = [10, 20, 30, 40, 50, 60] ...
427
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
556
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
0
from random import randint, random def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = False , __SCREAMING_SNAKE_CASE = False , __SCREAMING_SNAKE_CASE = 5 , ) -> Any: UpperCAmelCase_ ...
579
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
0
"""simple docstring""" 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_tes...
607
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
0