code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter, ...
257
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class UpperCAmelCase_ ( nn.Module ): '''simple docstring''' def __init__( self , _A = 16 , _A = 88 , _A = None , _A...
257
1
"""simple docstring""" 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 __snake_case = logging.get_logger(__name__) __snake_case ...
359
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCAmelCase ( ...
112
0
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers...
174
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class UpperCAmelCase_ ( UpperCamelCase_ ): '''simple docstring''' def __init__( self , _A , _A , _A ): ...
257
0
from collections.abc import Iterable from typing import Any class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : str , __A : int | None = None ): snake_case__ : Tuple = value snake_case__ : Node | None =...
356
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def SCREAMING_SNAKE_CASE ( snake_case_ : str ): snake_case__ : Optional[Any] = [ "encoder.version", "decoder.version", "model.encoder.ve...
286
0
def UpperCamelCase__( UpperCamelCase__ : int , UpperCamelCase__ : bool = False )->bool: if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check last digit ...
193
a__: Dict = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} a__: str = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCamelCase__( UpperCamelCase__ : dict[int, list[int]] , UpperCamelCase__ : int , UpperCamelCase__ : list...
193
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) def _snake_case ( _snake_case : Union[tf.Tensor, np.ndarray] ): if isi...
371
"""simple docstring""" from math import sqrt def _snake_case ( _snake_case : int ): assert isinstance(_snake_case , _snake_case ) and ( number >= 0 ), "'number' must been an int and positive" lowerCAmelCase : Dict = True # 0 and 1 are none...
314
0
'''simple docstring''' import torch from torch import nn class SCREAMING_SNAKE_CASE ( nn.Module ): """simple docstring""" def __init__( self : List[Any] , UpperCamelCase__ : Dict , UpperCamelCase__ : List[Any] , UpperCamel...
28
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class SCREAMING_SNAKE_CASE ( lowerCamelCase__ ): __lowerC...
302
0
SCREAMING_SNAKE_CASE : int = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} SCREAMING_SNAKE_CASE : str = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> list[int]: _lowerca...
84
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : Optional[int] = 299792458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[int] = symbols("c...
84
1
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _SCREAMING_SNAKE_CASE ( _lowerCame...
232
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) U...
112
0
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/license...
147
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : list ): if len(__lowerCamelCase ) <= 1: return lst lowercase_ :Optional[Any] = 1 while i < len(__lowerCamelCase ): if lst[i - 1] <= lst[i]: i += 1 else: ...
147
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from ...
3
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers lowerCamelCase_ : List[str] = [int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def UpperCAmelCase__ ( ): """simple docstring""" A_ : Union[str, Any] = os...
286
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
366
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils impo...
281
0
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import Backb...
13
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def UpperCAmelCase_ ( ): '''simple docstring''' raise RuntimeError('''CUDA out of memory.''' ) class ...
314
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : List[Any] = logging.get_logger(__name__) lowerCAmelCase : Optional[Any] = { """facebook/nllb-moe-54B""": """https://huggingface...
168
"""simple docstring""" import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", exist_ok=True) def a...
168
1
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging __UpperCAm...
84
"""simple docstring""" from PIL import Image def _snake_case ( lowercase__ : Image , lowercase__ : float ) -> Image: '''simple docstring''' def brightness(lowercase__ : int ) -> float: return 1_2_8 + level + (c - 1_2_8) if n...
84
1
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : List[Any] = len(__lowerCAmelCase ) _UpperCAmelCase : Tuple = sum(__lowerCAmelCase ) _UpperCAmelCase : List[Any] = [[False for x in range(s + 1 )] for y in ra...
322
'''simple docstring''' from __future__ import annotations from collections.abc import Callable lowerCamelCase__ = list[list[float | int]] def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : int = len(__lowerCAmelCase ) _Up...
322
1
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) a : Dict = ...
147
from __future__ import annotations from typing import Any class _a : def __init__(self, SCREAMING_SNAKE_CASE_ = 6 ) -> None: UpperCAmelCase_: Node | None = None UpperCAmelCase_: Node | None = None self.create_linked_list(...
147
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKI...
140
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def A_ ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , ) -> list[float]: UpperCamelCase , UpperCamel...
140
1
class A_ : def __init__( self : List[str] , UpperCAmelCase : Optional[int] ) -> Union[str, Any]: __lowerCAmelCase: Tuple = size __lowerCAmelCase: Union[str, Any] = [0] * size __lowerCAmelCase: int = [0] * size @st...
322
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokenizer...
281
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotA...
363
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import...
125
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAn...
168
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(impo...
168
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 from ...
165
import argparse _SCREAMING_SNAKE_CASE = """docs/source/_static/js/custom.js""" def lowercase( UpperCamelCase_ ) -> Union[str, Any]: '''simple docstring''' with open(UpperCamelCase_ , encoding="""utf-8""" , newline="""\n""" ) as f: UpperCamelCase = f....
165
1
def _a ( SCREAMING_SNAKE_CASE : str ) -> Union[str, Any]: """simple docstring""" __lowerCAmelCase: str = len(SCREAMING_SNAKE_CASE ) __lowerCAmelCase: List[Any] = sum(SCREAMING_SNAKE_CASE ) __lowerCAmelCase: str = [[False for x in range(s + 1 )...
322
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
322
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __A : int = logging.get_logger(__name__) class __UpperCamelCase ( lowercase__ ): def __init__( self :str ,*_UpperCamelCase :Unio...
8
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.d...
8
1
def UpperCamelCase ( __lowercase : int = 10_00 ): '''simple docstring''' A_ : Tuple = 2**power A_ : Any = 0 while n: A_ , A_ : Optional[int] = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(...
140
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor _UpperCAmelCase = logging.get_logger(__name__) class UpperCAmelCase ( __A ): '''simple docstring''' def __init__( self , *lowercase , **lowe...
140
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Tuple ={ "configuration_pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"], } try: if not is_torch_available(): raise Opti...
266
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowercase : List[Any] ={} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass ...
266
1
"""simple docstring""" import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index,...
165
'''simple docstring''' 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_...
125
0
"""simple docstring""" import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_atten...
126
"""simple docstring""" from ..utils import DummyObject, requires_backends class __A ( metaclass=SCREAMING_SNAKE_CASE_ ): _UpperCamelCase : Optional[Any] = ["sentencepiece"] def __init__( self , *a__ , **a__ ): requires_backends(self , ["""se...
126
1
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A ( snake_case__ ): '''simple docstring''' if "img_encoder.pos_embed" in name: SCREAMING_SNAKE_C...
165
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMix...
165
1
from math import isqrt def __UpperCamelCase ( _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Any = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , _lowerCA...
115
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __UpperCamelCase ( ) -> Tuple: """simple docstring""" A , A : Tuple = 9, 14 # noqa: F841 A : Optional[int] = [ [0, ...
115
1
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class snake_case_ ( __A ): '''simple docstring''' def __init__( self : Tuple , *_UpperCamelC...
8
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): snake_case_ = [] if len(SCREAMING_SNAKE_CASE__ ) == 1: return [nums.copy()] for _ in range(len(SCREAMING_SNAKE_CASE__ ) ): snake_case_ = nums.pop(0 ) snake_case_ ...
8
1
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowerCamelCase ( SCREAMING_SNAKE_CASE : Union[str, Any] ): '''simple docstring''' __UpperCamelCase :List[...
359
import os import pytest from transformers.dynamic_module_utils import get_imports __lowercase = ''' import os ''' __lowercase = ''' def foo(): import os return False ''' __lowercase = ''' def foo(): def bar(): if True: import os return False r...
105
0
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" try: __A = float(__UpperCamelCase ) except ValueError: raise ValueError('''Please enter a valid number''' ) __A = decimal - int(__UpperCamelCase ) if fractional_part ==...
266
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extracti...
266
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class snake_case_ ( datasets.BeamBasedBuilder ): def UpperCAmelCase__ ( self ...
356
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[list[int]] ) -> bool: __lowerCAmelCase : Tuple = len(SCREAMING_SNAKE_CASE ) # We need to create solution object to save path. __lowerCAmelCase : str = [[0 for _ in ra...
232
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ...
126
"""simple docstring""" 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, To...
126
1
def lowercase__ ( __snake_case : int , __snake_case : int ): '''simple docstring''' return int(input_a == input_a == 0 ) def lowercase__ ( ): '''simple docstring''' print('Truth Table of NOR Gate:' ) prin...
145
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap __UpperCAmelCase = 'Usage of script: script_name <size_of_canvas:int>' __UpperCAmelCase = [0] * 100 + [1] * 10 random.shuffle(choice) ...
145
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceCl...
308
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class a ( lowercase__ ): """simple docstring""" a : List[str] = 'MCTCTFeatureExtractor' a : str = 'AutoTokenizer' def __init...
114
0
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ..ut...
354
'''simple docstring''' import math import qiskit def __snake_case( _lowerCAmelCase = 1 , _lowerCAmelCase = 1 , _lowerCAmelCase = 1 ) -> qiskit.result.counts.Counts: if ( isinstance(_lowerCAmelCase , _lowerCAmelCase ) or isinstance(_low...
43
0
import argparse import collections import json import os import re import string import sys import numpy as np snake_case : int = re.compile(R'''\b(a|an|the)\b''', re.UNICODE) snake_case : Optional[Any] = None def __lowerCamelCase ( ): """simple docstrin...
94
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : float , _lowercase : float ) ->float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(100, 0.25) = }''') ...
105
0
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A ( __UpperCAmelCase ): __snake_case = ...
167
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <host...
167
1
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _UpperCamelCase ( ...
112
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.hug...
232
0
from __future__ import annotations def __snake_case ( SCREAMING_SNAKE_CASE__ : int ) -> list[int]: '''simple docstring''' _UpperCAmelCase : Optional[int] = 2 _UpperCAmelCase : List[str] = [] while i * i <= n: i...
367
"""simple docstring""" 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 D...
202
0
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np __a = re.compile(R'\b(a|an|the)\b', re.UNICODE) __a = None def __UpperCAmelCase ( ): _UpperCAmelCase : Dict = argparse.Ar...
145
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __a = logging.get_logger(__name__) class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Dict , *lo...
145
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black UpperCamelCase_ : int = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_...
362
'''simple docstring''' def __a ( _UpperCamelCase: int ) -> None: """simple docstring""" _snake_case = generate_pascal_triangle(_UpperCamelCase ) for row_idx in range(_UpperCamelCase ): # Print left spaces for _ in range(num_rows - ...
142
0
"""simple docstring""" A__ : Any = { 'Pillow': 'Pillow', 'accelerate': 'accelerate>=0.11.0', 'compel': 'compel==0.1.8', 'black': 'black~=23.1', 'datasets': 'datasets', 'filelock': 'filelock', 'flax': 'flax>=0.4.1', 'hf-doc-builder': 'hf-doc-builder>=0.3.0', ...
144
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() __lowercase...
43
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer,...
135
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_availabl...
135
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase : Dict...
167
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
167
1
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __a ( ) -> int: """simple docstring""" with offline...
142
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : int = logging.get_logger(__name__) UpperCamelCase_ : Tuple = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-ba...
142
1
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : str ) -> str: return " ".join( ''.join(word[::-1] ) if len(__snake_case ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod...
183
"""simple docstring""" from __future__ import annotations def __magic_name__ ( __snake_case : list[int] ) -> list[int]: if len(__snake_case ) == 0: return array lowercase , lowercase : Tuple = min(__snake_case ), max(__snake_...
202
0
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def UpperCAmelCase__ (): '''simple docstring''' ...
370
"""simple docstring""" import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) def UpperCAmelCase__ (lowerCAmelCase_ ...
195
0
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import A...
9
import argparse import os import re import packaging.version _A : Optional[int] = 'examples/' _A : str = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULT...
142
0
'''simple docstring''' import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_...
357
'''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_bert import BertTokenizer __SCREAMING_SNAKE_CASE :List[str] = logging.g...
156
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { '''configuration_electra''': ['''ELECTRA_PRETRAINED_CONFIG_ARCHIV...
135
"""simple docstring""" def lowercase_ ( _lowerCamelCase: str , _lowerCamelCase: str ) -> List[str]: '''simple docstring''' assert x is not None assert y is not None __lowerCamelCase : Optional[int] = len(_lowerCamelCase ...
135
1
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging __snake_case : List[str] = """\ """ __snake_case : str = """ Perplexity (PPL...
122
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : Dict = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} tr...
122
1
import datasets from .evaluate import evaluate _A : Optional[int] = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016...
142
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def _a ( UpperCAmelCase ) -> str: """simple docstring""" lower...
142
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase_ ) class __lowercase ( UpperCAmelCase_ ): """simple docstring""" _UpperCAmelCase...
127
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 ( Efficie...
127
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 lowercase_ = logging.get_logger(__name__) lowercase_ = { 'facebook/le...
205
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging UpperCAmelCase = logging.get_logger(__name__) def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = r'\w+[.]\d+' ...
195
0
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Ra...
167
def __UpperCamelCase ( _A ): lowerCAmelCase_ = [int(_A ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(_A ) == 4 and all(0 <= int(_A ) <= 254 for octet in octets ) if __name__ == "__main__": _A = input().strip() _A = '''va...
167
1
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester fro...
26
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_ava...
156
0
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ......
259
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mode...
259
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowerCamelCase__ ( a__ : int ) -> Tuple: if "cls_token" in name: UpperCamelCase_ = name.replace("""cls_token...
122
_A = [0, 2, 4, 6, 8] _A = [1, 3, 5, 7, 9] def lowerCamelCase__ ( a__ : int , a__ : int , a__ : list[int] , a__ : int ) -> int: if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return ...
122
1
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
371
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, PathLi...
198
0
from typing import Dict, Optional import numpy as np import datasets _SCREAMING_SNAKE_CASE : List[str] = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (...
127
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, ...
127
1
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_util...
222
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determini...
222
1
"""simple docstring""" import numpy as np def lowercase_ ( _UpperCAmelCase ): """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
167
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : int = { 'transfo-xl-wt103': 'https://huggingface.co/transfo-xl-wt103/resolve/m...
167
1
"""simple docstring""" import string def lowerCamelCase_ (UpperCamelCase__ : str ): _UpperCAmelCase : Tuple = '''''' for i in sequence: _UpperCAmelCase : Union[str, Any] = ord(UpperCamelCase__ ) if 65 <= extract <= 90: ...
68
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _UpperCAmelCase : '''simple docstring''' a__ ...
68
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """distilbert-base-uncased""": """https://hug...
259
def _A ( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : list[int] ): UpperCamelCase :Tuple = len(SCREAMING_SNAKE_CASE__ ) print('''The following activities are selected:''' ) # The first activity is always selected UpperCamelCase ...
259
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, ...
368
from __future__ import annotations def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' __snake_case : str = [] ...
20
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _a = {'tokenization_bertweet': ['BertweetTokenizer']} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys _a = _LazyModule(__name__, globals()...
61
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_confi...
198
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWit...
359
from __future__ import annotations def lowerCAmelCase_ ( __a , __a ) -> List[Any]: """simple docstring""" print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(__a ): print(F"""{i}\t\t{d}""" ) def lowerCAmelCase_ ( __a , ...
273
0
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common im...
222
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Union[str, Any] = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBlipQFor...
222
1
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __a ( lowerCAmelCase_ : str ,lowerCAmelCase_ : str ,lowerCAmelCase_ : Optional[str] = None ) -> str: '''simple docstring''' i...
277
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo __A = '''\ @misc{wu2016googles, title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author={Yonghui Wu and Mike Schu...
277
1
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowerCAmelCase__ ( ) -> Optional[Any]: '''simple docstring''' raise RuntimeError("CUDA out of memory....
68
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json""", } class a_...
68
1
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) class UpperCamelCase ( _UpperCAmelCas...
198
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, PathLi...
198
1
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, ...
106
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def _snake_case( SCREAMING_SNAKE_CASE__ ) -> Optional[Any]: if "cls_token" in name: lowercase : List[Any] = ...
20
0
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __snake_case ( unittest.TestCase ): def UpperCAmelCase__ ( self ) -> None: '''simple docstring''' UpperCAmelCase ...
78
import colorsys from PIL import Image # type: ignore def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase )-> float: '''simple docstring''' UpperCAmelCase : Any =x UpperCAmelCase : List[str] =y for ...
78
1
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A_ ( a_ , unittest.TestCase ): '''simple docstring''' _UpperCamelCase : Tuple ...
195
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, AutoModelForMultipleCho...
273
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { """shi-la...
357
class UpperCamelCase__ : '''simple docstring''' def __init__( self : int ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE = {} def SCREAMING_SNAKE_CASE__ ( self : List[Any] ) -> ...
193
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import...
277
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType a_ ...
277
1
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = None )-> str: """simple docstring""" if version.parse(h...
60
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, Diff...
60
1
'''simple docstring''' from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer ...
198
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_confi...
198
1
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCAmelCase_ = collections.namedtuple("_Datasets"...
332
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def __magic_name__ ( A , A , A ) -> Any: # Initialise PyTorch model snake_c...
332
1
"""simple docstring""" def _lowerCAmelCase ( ): UpperCAmelCase = [] UpperCAmelCase = 1 while len(lowercase_ ) < 1e6: constant.append(str(lowercase_ ) ) i += 1 UpperCAmelCase = ''.join(lowerc...
78
"""simple docstring""" 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 snake_case_ = logging.get_logger(__name__) snake...
78
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { '''configuration_xlm_roberta_xl''': [ '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMRobertaXLConfig''', '''XLMRobertaXLOnnxConfig''', ], }...
356
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = {'''vocab_file''': '''spiece...
173
0
'''simple docstring''' import requests UpperCamelCase = 'YOUR API KEY' def SCREAMING_SNAKE_CASE( __lowercase , __lowercase = giphy_api_key ) -> list: A: Optional[Any] = '''+'''.join(query.split() ) A: Tuple = F"""ht...
319
import random def UpperCamelCase__( UpperCamelCase__ : list , UpperCamelCase__ : List[Any] )->tuple: A__ , A__ , A__ = [], [], [] for element in data: if element < pivot: less.append(UpperCamelCase__...
193
0
"""simple docstring""" import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( _lowerCAmelCase ): a__ : Optional[int] = (DDPMParallelScheduler,) def a ( self : Any , ...
86
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": _lowercase : int = pd.read_csv('sample_data.csv', hea...
86
1
"""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_bert import BertTokenizer snake_case__ : int = logging.get_logger(__name__) ...
60
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() snake_cas...
60
1
def A_ ( ): SCREAMING_SNAKE_CASE_: Optional[Any] = 0 for i in range(1 , 10_01 ): total += i**i return str(_UpperCAmelCase )[-10:] if __name__ == "__main__": print(solution())
127
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPENA...
127
1
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _lowercase : List[str] = col...
332
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
1
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbon...
244
"""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 ( Auto...
244
1
'''simple docstring''' lowerCamelCase : List[str] = "\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://...
47
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.p...
173
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __A = logging.get_logger(__name__) class UpperCAmelCase (_UpperCAmelCase ): """simple docstring""" def __init__( self , *_UpperCAme...
359
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model ...
2
0
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : Tuple = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def __lowerCAmelCase ...
86
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = {"""configuration_fnet""": ["""FNET_PRETRAINED_CONFIG_ARCHIVE_M...
86
1
"""simple docstring""" import math def A ( snake_case :int ) -> int: if not isinstance(snake_case , snake_case ): __UpperCamelCase = f'Input value of [number={number}] must be an integer' raise TypeError(snake_case ) if number < 1: __UpperCamelCase = f'Input ...
359
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def A ( snake_case :str , snake_case :str = "cpu" , snake_case :Union[str, None] = None ) -> None: __UpperCamelCase = torch.load(snake_case , map_location=snake_case ) ...
263
0
import math import sys def UpperCAmelCase__ (UpperCamelCase_ ): """simple docstring""" if number != int(UpperCamelCase_ ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value ...
127
_SCREAMING_SNAKE_CASE : Optional[Any] = tuple[float, float, float] _SCREAMING_SNAKE_CASE : Optional[Any] = tuple[float, float, float] def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ): """simple docstring""" snake_case = end_po...
127
1
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets __A : int = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifica...
326
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return "\n".join( f'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "...
326
1
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord import VideoReader if i...
244
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_tf ...
244
1
'''simple docstring''' def _lowerCAmelCase ( lowercase ) -> int: __lowerCAmelCase = [1] __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = 0, 0, 0 __lowerCAmelCase = ugly_nums[ia] * 2 __lowerCAmelCase = ugly_nums[ia] * 3 ...
46
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tenso...
46
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings A_ :Tuple = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model ...
71
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants lowerCamelCase : str = Mapping[str, np.ndarray] lowerCamelCase : List[Any] = Mapping...
2
0
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 impor...
292
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
292
1