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
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" snake_case_ = ['''image_processor''', '''tokenizer'''] snake_case...
90
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __snake_case : _a : int _a : TreeNode | None= None _a : TreeNode | None= None lowercase : Dict = namedtuple("""CoinsDistribResult""",...
20
0
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def A_ ( A__ ) -> List[str]: a__ : List[Any] = {} a__ : Optional[Any] = tokenizer(ex...
225
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS...
225
1
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow...
87
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 snake_case_ ( __A ): __A :...
87
1
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreT...
369
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase ) class _lowercase ( lowerCAmelCase ): """simple docstring""" __A = ...
71
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( lowerCAmelCase_ )-> int: '''simple docstring''' if not nums: return 0 _UpperCAmelCase : Optional[Any] = nums[0] _UpperCAmelCase : Dict = 0 ...
215
def __A ( __lowerCamelCase , __lowerCamelCase ) -> str: if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise ValueError("""iterations must be defined as integers""" ) if not isinstance(__lowerCamelCase , __lowerCamelCase ) or not number >= 1: ...
228
0
'''simple docstring''' def _a( UpperCamelCase__ : Optional[Any] ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] =len(UpperCamelCase__ ) while cur > 1: # Find the maximum number in arr SCREAMING_SNAKE_CASE__ ...
364
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'], } try: if not is_torch_availabl...
222
0
import copy import re class __lowerCamelCase : """simple docstring""" UpperCamelCase__ = "hp" UpperCamelCase__ = {} UpperCamelCase__ = None @classmethod def UpperCamelCase ( cls , UpperCAmelCase ...
39
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { '''distilbert-base-uncased''': '''https://huggingface.co/...
39
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: ...
366
'''simple docstring''' import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_...
101
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : int = logging.get_logger(__name__) _lowerCamelCase : List[A...
28
"""simple docstring""" # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def _UpperCAmelCase ( __lowerCamelCase : str ) -> List[Any]: ret...
288
0
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowercase ( nn.Module ): """simple docstring""" UpperCAmelCase = 42 Uppe...
369
'''simple docstring''' from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class ...
349
0
"""simple docstring""" import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowercase ( lowerCAmelCase__ : Dataset , lowerCAmelCase__ :...
45
"""simple docstring""" def lowercase ( lowerCAmelCase__ : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: __a = set() # Replace all the whitespace in our sentence __a = input_str.replace(''' ''' , '''''' ) for a...
45
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase_ ) class lowercase ( UpperCamelCase_ ): lowercase_ : str =field(default='''automatic-speech-rec...
362
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ :Optional[int] = logging.get_logger(__name__) lowercase__ :List[Any] = { "camembert-base": "https://huggingfac...
97
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import...
46
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate impor...
228
0
"""simple docstring""" 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 transformer...
354
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __lowerCAmelCase ( lowercase : Union[str, Any] , lowercase : Optional[int]=False ) -> Union[str, Any]: """simple docstrin...
112
0
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_ = { '''google/bigbird-roberta-base''': '''https://huggingface.co/google/...
214
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self , a , a , a = 0): lowercase__ , lowercase__ : Dict = row, column lowercase__ : Optional[Any] = [[default_va...
214
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, 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,...
363
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers....
98
0
import os def UpperCAmelCase_ ( __UpperCAmelCase : str = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(__UpperCAmelCase ) , __UpperCAmelCase ) ) as input_file: SCREAMING_SNAKE_CASE_ = [ [int(__UpperCAmel...
225
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def UpperCAmelCase_ ( __UpperCAmelCase : bytes , __UpperCAmelCase : int ) -> np.array: SCREAMING_SNAKE_CASE_ = f"{sampling_rate}" SCREAMING_SN...
225
1
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''vocab_file''': '''vocab.json''', '''...
296
"""simple docstring""" import warnings from ..trainer import Trainer from ..utils import logging A_ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( UpperCamelCase ): def __init__( self : Optional[int] , snake_case : List[str]=None , ...
296
1
"""simple docstring""" def _snake_case ( lowercase__ : list[int] ) -> list[list[int]]: '''simple docstring''' lowerCAmelCase_ :Optional[Any] = [] if len(lowercase__ ) == 1: return [nums.copy()] for _ in range(len(lowercase__ ) ): ...
84
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
71
0
"""simple docstring""" import numpy as np class lowerCAmelCase : '''simple docstring''' def __init__( self ) -> Dict: SCREAMING_SNAKE_CASE = (0, 0) SCREAMING_SNAKE_CASE = None SCREAMING_SNAKE_CASE ...
38
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = {'''configuration_opt''': ['''OP...
38
1
from __future__ import annotations from math import gcd def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = 2 , SCREAMING_SNAKE_CASE = 1 , SCREAMING_SNAKE_CASE = 3 , ): if num < 2: raise ValueError('''The input value cannot be less than 2''' ) # Because of the relat...
186
def A ( lowercase ) -> list: '''simple docstring''' UpperCamelCase = len(lowercase ) for i in range(1 , lowercase ): UpperCamelCase = collection[i] UpperCamelCase = 0 UpperCamelCase = i - 1 while low <= high: UpperCamelCase = (low + hig...
222
0
import argparse from collections import defaultdict def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> Dict: """simple docstring""" A : List[str] = f'''{file}_{class_name}_{...
367
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Tuple = 2 A : List[Any] = [] while i * i <= n: if n % i: i += 1 else: n //= i ...
115
0
'''simple docstring''' a__ : Union[str, Any] = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _UpperCamelCase ( __A ) -> int: '''simple docstring''' UpperCamelCase__ = 0 while number: # In...
80
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import StableDiff...
101
0
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransf...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def lowerCAmelCase_ ( snake_case__ , snake_case__ ): '''simple docstring''' return math.sqrt(sum(pow(a - b , 2 ) for a,...
3
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_ten...
349
0
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : int , __lowerCamelCase : int ) -> int: return number | (1 << position) def _UpperCAmelCase ( __lowerCamelCase : int , __lowerCamelCase : int ) -> int: return number & ~(1 << position) def ...
371
"""simple docstring""" import os import sys import unittest UpperCAmelCase__ = 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_dummies # noqa: E402 from check_dummies import create_dummy_files, ...
40
0
"""simple docstring""" 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 <us...
54
'''simple docstring''' import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def a (...
97
0
'''simple docstring''' from manim import * class _lowerCamelCase ( __snake_case ): '''simple docstring''' def __lowerCAmelCase ( self : Any ) -> Any: __magic_name__ : int = Rectangle(height=0.5 , width=0.5 ) __magic_name__ : int ...
352
'''simple docstring''' 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 DD...
275
0
def UpperCAmelCase__ ( _A : List[str] , _A : List[Any] , _A : Dict , _A : int=None ): '''simple docstring''' a__ =(path or []) + [u] for v in graph[u]: if visited_edge[u][v] is False: a__ =True, True a__ =dfs(_lowerCamelCase , ...
188
'''simple docstring''' import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
112
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
304
0
'''simple docstring''' from math import sqrt def __snake_case ( UpperCAmelCase_ : int ): assert isinstance(UpperCAmelCase_ , UpperCAmelCase_ ) and ( number >= 0 ), "'number' must been an int and positive" lowerCamelCase_ = True # 0 and 1 are none p...
55
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : int = logging.get_logger(__name__) lowerCAmelCase__ : str = { 'facebook/xglm-564M': 'https://huggingface.co/facebook/xglm-564M/resolve/main/config.json', # ...
98
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @...
143
# Lint as: python3 import itertools import os import re UpperCamelCase__ = re.compile(R'([A-Z]+)([A-Z][a-z])') UpperCamelCase__ = re.compile(R'([a-z\d])([A-Z])') UpperCamelCase__ = re.compile(R'(?<!_)_(?!_)') UpperCamelCase__ = re.compile(R'(_{2,})') UpperCamelCas...
143
1
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging a_ ...
330
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modelin...
330
1
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCase : Optional[int] ...
362
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase...
200
0
import math UpperCAmelCase_ : List[str] = 10 UpperCAmelCase_ : Optional[Any] = 7 UpperCAmelCase_ : Optional[Any] = BALLS_PER_COLOUR * NUM_COLOURS def SCREAMING_SNAKE_CASE_ ( __magic_name__ : int = 20 ) -> str: """simple docstring"""...
38
from collections.abc import Generator from math import sin def SCREAMING_SNAKE_CASE_ ( __magic_name__ : bytes ) -> bytes: """simple docstring""" if len(__magic_name__ ) != 32: raise ValueError("""Input must be of length 32""" ) UpperCamelCase :int =...
38
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github __A = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def _lowerCamelCase()...
341
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available(): raise Opti...
341
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 diffusers.util...
58
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class lowerCamelCase__ ( unittest.TestCase ): """sim...
115
0
"""simple docstring""" from math import isclose, sqrt def _lowerCAmelCase ( UpperCAmelCase__ : float, UpperCAmelCase__ : float, UpperCAmelCase__ : float ) ->tuple[float, float, float]: A__ : List[Any] = point_y / 4 / point_x A__ : ...
363
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP...
296
0
"""simple docstring""" import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin,...
263
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { '''facebook/xlm-...
37
0
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand a : int = ( '4S 3H 2C 7S 5H', '9D 8H 2C 6S 7H', '2D 6D 9D TH 7D', 'TC 8C 2S JH 6C', 'JH 8S TH AH QH', 'TS KS 5S 9S AC', 'KD 6S 9D...
72
'''simple docstring''' import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_C...
72
1
"""simple docstring""" import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel snake_case__ : Optional[Any] = False snake_case__ : Union[str, Any] = True snake_case__ : Dict = False ...
60
"""simple docstring""" from itertools import permutations def lowercase ( A_ )-> bool: '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False...
40
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { 'google/pix2struct-textcaps-base': ( 'https://h...
366
"""simple docstring""" import re from filelock import FileLock try: import nltk UpperCAmelCase__ = True except (ImportError, ModuleNotFoundError): UpperCAmelCase__ = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def _Upper...
40
0
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lowerCamelCase ( lowercase__ , uni...
331
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase :Union[str, Any] = { '''configuration_vision_encoder_decoder''': ['''VisionEncode...
331
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWith...
370
from __future__ import annotations from collections import deque class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , __lowerCamelCase : list[str] ): UpperCamelCase :list[dict] = [] self.adlist.append( {"""value""": """""", """next_states""": [], ...
62
0
"""simple docstring""" import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDataset...
96
"""simple docstring""" from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils impor...
286
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import c...
84
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCamelCase( _a ): def __init__( self, lowerCamelCase, lowerCamelCase) -...
84
1
import sys def UpperCamelCase__ ( A__ ) -> Optional[int]: snake_case__ : int = len(A__ ) snake_case__ : Union[str, Any] = [[0 for x in range(A__ )] for x in range(A__ )] snake_case__ : int = [[0 for x in range(A__ ...
143
import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase__ ( A__ , A__=1000 ) -> Optional[int]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd snake_case__ : List[Any] = n - 1 snake_case...
143
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=_UpperCamelCase): __UpperCamelCase = ['torch', 'scipy'] def __init__( self : str , *a__ : Tuple , **a__ : str ) -> Optional[Any]: ...
163
"""simple docstring""" from collections.abc import Generator from math import sin def a__ ( __lowercase ) -> bytes: if len(__lowercase ) != 32: raise ValueError("Input must be of length 32" ) _A = B"" for i in [3, 2, 1, 0]: littl...
163
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''microsoft/biogpt''': '''https://huggingface.co/microsoft/biogpt/resolve/main/config.json''', # See all BioGPT models at https://hugg...
8
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class lowercase__ ( unittest.TestCase ): '''simple docstring''' def UpperCAmelCase_ ( self ): _SCREAMING_SNAKE_CASE : str = [10, 20, 30, 40, 50, 60] ...
200
0
'''simple docstring''' # using dfs for finding eulerian path traversal def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__=None ): '''simple docstring''' A : Optional[int] = (path or []) + ...
359
'''simple docstring''' from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def lowerCAmelCase_ ( snake_case__ = "laptop" ): '''simple docstring''' A : Tuple = F'https://www.amazon.i...
311
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _snake_case = { 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTCo...
294
"""simple docstring""" import unittest import numpy as np def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = None , ): '''simple docstring''' _a : List[Any] = np.shape(UpperCame...
294
1
'''simple docstring''' from statistics import mean import numpy as np def SCREAMING_SNAKE_CASE__ ( __A , __A , __A , __A ) -> list: _snake_case = 0 # Number of processes finished _snake_case = 0 # Displays the finished process. ...
160
'''simple docstring''' import torch from transformers import AutoModel class __UpperCAmelCase ( torch.nn.Module ): def __init__( self , lowerCAmelCase_="sayef/fsner-bert-base-uncased" ): """simple docstring""" super(lowerCAmelCase_ , self )....
160
1
def _lowercase ( lowercase__ , lowercase__ ): __lowerCAmelCase : Dict = len(_SCREAMING_SNAKE_CASE ) print('''The following activities are selected:''' ) # The first activity is always selected __lowerCAmelCase : Union[str, Any] = 0 ...
275
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.im...
296
0
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
217
'''simple docstring''' def _lowerCAmelCase ( lowerCamelCase_ : str , lowerCamelCase_ : str ): __lowercase = len(lowerCamelCase_ ) + 1 __lowercase = len(lowerCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefi...
217
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
72
"""simple docstring""" def snake_case_ ( A_ : list[int], A_ : str ): '''simple docstring''' _lowerCamelCase : Tuple = int(A_ ) # Initialize Result _lowerCamelCase : Dict = [] # Traverse through all deno...
72
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__ ( ) -> Optional[Any]: """simple docstring""" with offli...
357
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" UpperCAmelCase_ : str = len(_SCREAMING_SNAKE_CASE ) for _ in range(_SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 ...
67
0
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def _snake_case ( _snake_case : int = 1000000 , _snake_case : int = 10 ): lowerCAmelCase : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 , (t_limit //...
60
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase ...
40
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Dict = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } try: if not is_tor...
259
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.append(_UpperCamelCase ) __...
259
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMS...
63
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 _A = collections.namedtuple('_Datasets', ['train', 'validation', 'test'...
62
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging lo...
252
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenize...
252
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar __UpperCAmelCase = TypeVar('T') class _SCREAMING_SNAKE_CASE ( Generic[T] ): def __init__( self , __A ...
84
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def _snake_case ( ) -> Generator[int, None, None]: '''simple docstring''' lowerCAmelCase_ :dict[int, int] = {} lowerCAmelCase_ :int ...
84
1
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_collator...
257
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
257
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A ={ 'configuration_clip': ...
163
'''simple docstring''' def _UpperCamelCase ( UpperCamelCase__ ): if isinstance(UpperCamelCase__ , UpperCamelCase__ ): raise TypeError("""'float' object cannot be interpreted as an integer""" ) if isinstance(UpperCamelCase__ , UpperCamelCase__ ): ...
163
1
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class UpperCamelCase ( __SCREAMING_SNAKE_CASE ): """simple docstring""" def SCREAMING_SNAKE_CASE_ ( self : Union[str, Any]): ...
364
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig UpperCamelCase : Optional[Any] = logging.getLogger(__name__) class UpperCamelCase ( a_ ): """simple docstring""" A : Tuple = "masked_bert" ...
345
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 lowercase ( unittest.TestCase ): """simple docstring""" def lowerCAmelCase__ ( self ): '''simple ...
97
'''simple docstring''' from jiwer import compute_measures import datasets a : List[Any] = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improve...
311
0
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...imag...
360
'''simple docstring''' def _lowerCAmelCase ( lowerCamelCase_ : str , lowerCamelCase_ : str ): __lowercase = len(lowerCamelCase_ ) + 1 __lowercase = len(lowerCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefi...
217
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...
160
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { '''configuration_git''': ['''GIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GitConfig''', '''GitVisionConfig'''], '''processi...
160
1
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 ...
330
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration UpperCamelCase__ : Any = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers...
330
1
"""simple docstring""" import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import requ...
217
"""simple docstring""" from numpy import exp, pi, sqrt def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0.0 , __SCREAMING_SNAKE_CASE = 1.0 ) -> int: return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": imp...
217
1
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. a_ = 10 def __lowercase ( snake_case_ : int ,snake_case_...
369
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import _LazyModule a_ = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys a_ = _LazyModule(__name__, globals()["""...
291
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__UpperCAmelCase ) class _A ( __UpperCAmelCase ): # `task` is not a ClassVar since we want it to be part of the `asdict` output ...
49
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
67
0
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( UpperCamelCase_ ): for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(snake_case_ ) ): matrix[i][0] +=...
368
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ = False ): 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 return False if n > 3_3170_4406_4679_8873_8596_1981 a...
255
0
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, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import...
259
from math import factorial __snake_case = {str(digit): factorial(digit) for digit in range(10)} def _A ( SCREAMING_SNAKE_CASE__ : int ): if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise TypeError('''Parameter number must be int''' ...
259
1
"""simple docstring""" from __future__ import annotations import math class A__ : def __init__( self , _SCREAMING_SNAKE_CASE ): __lowerCAmelCase : List[Any] = size # approximate the overall size of segment tree with given value __lowerCAmelCase : List[...
182
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
182
1
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_processor import VaeImageProcessor from diffusers.pipe...
252
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerat...
252
1
"""simple docstring""" __A = "\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://github.com/huggingf...
2
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger __A = "<<<<<<< This should probably be modified because it mentions: " __A = "=...
2
1
def __lowercase ( a__ , a__ ) -> int: return int((input_a, input_a).count(0 ) != 0 ) def __lowercase ( ) -> None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gat...
257
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece...
257
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase = { 'configuration_blenderbot': [ ...
366
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" if len(_SCREAMING_SNAKE_CASE ) < 2: return collection def circle_sort_util(_SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE ...
187
0
'''simple docstring''' import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter lowercase...
58
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _snake_case ( __snake_case , unittest.TestCase ): '''simple docstring''' A...
345
0
from __future__ import annotations lowerCamelCase_ : Union[str, Any] = 1.6021E-19 # units = C def A__ ( lowerCamelCase , lowerCamelCase , lowerCamelCase , ) -> tuple[str, float]: if (conductivity, electron_conc, mobility).count(0 ) != 1: ...
351
def A__ ( lowerCamelCase ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowerCamelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("""doctest""").testmod()
223
0
'''simple docstring''' 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, ...
93
"""simple docstring""" from numpy import exp, pi, sqrt def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0.0 , __SCREAMING_SNAKE_CASE = 1.0 ) -> int: return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": imp...
217
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : List[Any] = logging.get_logger(__name__) A_ : str = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json', 'microsoft/markuplm-large...
370
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A_ : List[str] = '.' if __name__ == "__main__": A_ : Dict = os.path.join(REPO_PATH, 'utils/documentation_tests.txt') ...
292
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...
330
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @slow @requ...
330
1
import warnings from functools import wraps from typing import Callable def __a ( lowerCAmelCase_ : Callable ) -> Callable: '''simple docstring''' @wraps(lowerCAmelCase_ ) def _inner_fn(*lowerCAmelCase_ : List[Any] ,**lowerCAmelCase_ : Tuple ...
277
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...te...
277
1
def A_ ( _lowerCAmelCase ) -> str: UpperCamelCase : Tuple = 0 # if input_string is "aba" than new_input_string become "a|b|a" UpperCamelCase : Any = "" UpperCamelCase : List[Any] = "" # append each character + "|" in new_string for range(0, length-1)...
52
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, T...
266
0
"""simple docstring""" 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 TFModelTest...
341
"""simple docstring""" 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 SPIECE_UNDERLINE, logging __A = logging.get_l...
341
1
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICATI...
118
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfi...
255
0
"""simple docstring""" def __lowercase ( _a ): snake_case_ : str = [int(UpperCAmelCase_ ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(UpperCAmelCase_ ) == 4 and all(0 <= int(UpperCAmelCase_ ) <= 254 for octet in octets ) if __name__ == "__main__":...
357
"""simple docstring""" import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __lowercase ( _a = 3 ): if isinstance(_a , _a ): raise TypeError('''number of qubits must be a integer.''' ) if num...
155
0
def A ( _lowercase = 10**9 ): SCREAMING_SNAKE_CASE : Dict = 1 SCREAMING_SNAKE_CASE : str = 2 SCREAMING_SNAKE_CASE : str = 0 SCREAMING_SNAKE_CASE : str = 0 SCREAMING_SNAKE_CASE : ...
182
import math def A ( _lowercase ): return math.sqrt(_lowercase ) * math.sqrt(_lowercase ) == num def A ( _lowercase ): SCREAMING_SNAKE_CASE : Dict = 0 SCREAMING_SNAKE_CASE : Tuple = n while left <= right: ...
182
1
"""simple docstring""" from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(...
371
"""simple docstring""" def lowerCamelCase (a_ :list , a_ :list , a_ :int , a_ :int , a_ :int) -> int: if index == number_of_items: return 0 lowercase :Optional[int] = 0 lowercase :str = 0 lowercase ...
172
0
'''simple docstring''' lowerCamelCase : Union[str, Any] = '\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 gi...
2
'''simple docstring''' import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
2
1
import os from datetime import datetime as dt from github import Github __UpperCAmelCase : int = [ "good first issue", "feature request", "wip", ] def A__ ( ) -> Any: __snake_case: List[Any] = Github(os.environ["""GITHUB_TOKEN"""]) __sn...
371
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
293
0
'''simple docstring''' import re def a_ ( lowerCamelCase : Union[str, Any] ): if len(re.findall('[ATCG]' , _A ) ) != len(_A ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) ) if __name__ ==...
4
from __future__ import annotations lowercase__ : str = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowerCamelCase__ ( _A , _A , _A , _A , _A , ): '''simple docstring''' snake_case_...
187
0
from __future__ import annotations def __A ( __lowerCamelCase , __lowerCamelCase ) -> int: print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(__lowerCamelCase ): print(f'{i}\t\t{d}' ) def __A ( __lowerCamelCase , ...
347
__UpperCamelCase : Dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def __A ( ) -> None: a = input("""Enter message: """ ) a = input("""Enter key [alphanumeric]: """ ) a = input("""Encrypt/Decrypt [e/d]: """ ) if mode.lower().startswit...
347
1
"""simple docstring""" import operator as op def lowercase ( A_ )-> Any: '''simple docstring''' a : Tuple = [] a : int = lambda A_ , A_ : int(x / y ) # noqa: E731 integer division operation a...
40
'''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 : Dict ...
223
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch...
360
'''simple docstring''' from importlib import import_module from .logging import get_logger __a = get_logger(__name__) class A__ : """simple docstring""" def __init__( self : List[str] , lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : O...
17
0
class UpperCAmelCase_ : '''simple docstring''' def __init__( self : List[str] , UpperCamelCase__ : Union[str, Any] , UpperCamelCase__ : Tuple ) -> List[Any]: """simple docstring""" __magic_name__ = name ...
88
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : Union[str, Any] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig...
292
0
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) class __snake_case (_a ): def __init__( self : str , *_UpperCAmelCase : Any , **_UpperCAmel...
369
from collections import namedtuple import requests from lxml import html # type: ignore _lowerCamelCase : Dict = namedtuple("covid_data", "cases deaths recovered") def _UpperCAmelCase (UpperCamelCase_ : str = "https://www.worldometers.info/coronavirus/" ): '''simple docstring''' ...
159
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a_ :Any = logging.get_logger(__name__) a_ :Optional[Any] = ...
277
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeat...
277
1
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, )...
320
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase : Dict = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except Opt...
320
1