code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from math import factorial def __a ( lowerCAmelCase__ : int = 100 ): return sum(map(lowerCAmelCase__ , str(factorial(lowerCAmelCase__ ) ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
688
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( __magic_name__ :Union[str, Any] , __magic_na...
121
0
"""simple docstring""" # 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 TensorFormatte...
87
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class _UpperCAmelCase ( _snake_case): def __init__( self , snake_case_ , snake_case_ , snake_case_ ): _snake_c...
87
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common impor...
142
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase ( a ): """simple docstring""" __lowercase :Optional[int] = ["image_processor", "tokenizer"] __low...
142
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) snake_case_ : Union[str, Any] = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(...
253
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer snake_case_ : Union[str, Any] = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"} snake_...
253
1
"""simple docstring""" import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging a = logging.get_logger(__name__) def _snake_case ( _snake_case : List[str] , ...
7
"""simple docstring""" import math def _snake_case ( _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' if ( not isinstance(_snake_case , (int, float) ) or power_factor < -1 or power_fac...
7
1
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state i...
714
"""simple docstring""" 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 fro...
378
0
from functools import lru_cache @lru_cache def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": ...
416
def SCREAMING_SNAKE_CASE__ ( snake_case_ = 1_0_0_0 ) -> int: A__ : Any =3 A__ : Optional[Any] =0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: result -= a a += 1 return result ...
416
1
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class lowercase__ ( __lowerCAmelCase ): def __init__( self , __UpperCAmelCase , __UpperC...
718
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = logging.get_logger(__name__) a_ = {'''v...
115
0
"""simple docstring""" from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def lowercase ( ): '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase = 9, 14 # noqa: F841 _Up...
602
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : Optional[Any] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kineti...
602
1
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() _lowercase : Tuple = [ "word_emb...
30
'''simple docstring''' from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase : Optional[Any] = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say th...
30
1
"""simple docstring""" import argparse import json from tqdm import tqdm def a_ ( ): '''simple docstring''' lowercase__ : str = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=_lowerCAmelC...
599
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , a , a , a ) -> List[Any]: lowercase__ : List[str] = name lowercase__ : List[str] = value lowercase__ : Tup...
599
1
'''simple docstring''' def UpperCamelCase_ ( A__ : str ): '''simple docstring''' lowerCAmelCase_ : List[Any] = hex_num.strip() if not hex_num: raise ValueError("""No value was passed to the function""" ) lowerCAmelCase_ : ...
702
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A : Tuple = logging.get_logger(__nam...
398
0
"""simple docstring""" import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import...
29
'''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 ( AutoC...
444
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transfor...
700
"""simple docstring""" import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state ...
274
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ....
417
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __lowercase ( lowerCamelCase : str ): UpperCamelCase_ : Any ...
417
1
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ......
708
'''simple docstring''' import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase : List[Any] = get_tests_dir('fi...
9
0
import heapq import sys import numpy as np A_ : Optional[int] =tuple[int, int] class lowercase_ : """simple docstring""" def __init__( self ): """simple docstring""" a_ =...
483
'''simple docstring''' import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCamelCase( SCREAMING_SNAKE_CASE_ ,SCREAMING_SNA...
366
0
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class __magic_name__ : def __init__( self : str , ...
708
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 100 * 2**20, 900 * 2**20] ...
30
0
def lowerCAmelCase_ ( __a , __a ) -> float: """simple docstring""" _validate_point(__a ) _validate_point(__a ) if len(__a ) != len(__a ): raise ValueError("Both points must be in the same n-dimensional space" ) return float(sum(abs(a ...
59
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_...
59
1
'''simple docstring''' import qiskit def lowercase__ ( __UpperCamelCase = 2 )-> qiskit.result.counts.Counts: UpperCamelCase = qubits # Using Aer's simulator UpperCamelCase = qiskit.Aer.get_backend("""aer_simulator""" ...
711
'''simple docstring''' 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_availab...
35
0
def SCREAMING_SNAKE_CASE ( lowercase_=28_123 ) -> Union[str, Any]: """simple docstring""" A__ = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ...
87
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__...
560
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow a_ : Dict = False class UpperCamelCase ( unittest.TestCase ): def UpperCamelCase ( sel...
673
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ : Optional[Any] = logging.get_logger(__name__) a_ : Optional[Any] = {"vocab_file": "vocab.j...
673
1
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
556
from __future__ import annotations def lowerCAmelCase_ (lowerCAmelCase__: int | str ): """simple docstring""" UpperCAmelCase_: Optional[int] = str(lowerCAmelCase__ ) return n == n[::-1] def lowerCAmelCase_ (lowerCAmelCase__: int = 1_...
556
1
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowerCamelCase ( tf.keras.optimizers.schedules.LearningRateSchedule ...
703
import inspect import unittest from transformers import MobileNetVaConfig 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_configuration_common import ConfigTester fro...
166
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any] = logging.get_logger(__name__) _a : Dict = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://huggingface.co/m...
213
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _a : int = get_tests_dir('fixtures/test_sentencepiece_...
213
1
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...t...
715
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase_ ( UpperCamelCase ): lowercase = (CMStochasticIterativeScheduler,) lowercase = 10 def snake_case__( ...
307
0
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from ...
560
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) class __A ( A_ ): '''simple docstring''' lowerCAmelCase : int ...
560
1
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipelin...
710
class _lowercase : def __init__( self , a ): snake_case__ : Optional[int] =size snake_case__ : List[Any] =[0] * size snake_case__ : List[Any] =[0] * size @staticmethod def lowercase__ ( a ): ...
448
0
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> list: for i in range(len(lowerCAmelCase__ ) - 1 , 0 , -1 ): UpperCAmelCase__ : Optional[int] = False for j in range(lowerCAmelCase__ , 0 , -1 ): if unsorted[j...
75
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...tes...
75
1
'''simple docstring''' # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V an...
187
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class lowercase ( tf.keras.layers.Layer ): '''simple docstring''' def __init__( self : Union[str, Any] , __lowerCamelCase : str , __lowerCamelCase : in...
187
1
"""simple docstring""" import numpy class _lowerCamelCase : def __init__( self : Union[str, Any] , UpperCamelCase : numpy.ndarray , UpperCamelCase : numpy.ndarray ) -> Tuple: """simple docstring""" lowerCAmelCase__ : ...
299
import collections import os import re from pathlib import Path lowerCamelCase_ : Optional[Any] = """src/transformers""" # Matches is_xxx_available() lowerCamelCase_ : Union[str, Any] = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowerCamelCase_ : i...
548
0
'''simple docstring''' 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 fro...
719
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) __a = logging.getLo...
301
0
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def snake_case ( A__ ,A__ ,A__ = None ): if version.parse(hfh.__version__ ).release < version.parse("0.11.0" ).release: # old versions of h...
95
from torch import nn def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: str ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f'''Unsupported activation function:...
6
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, ...
705
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration A__: Dict = 5_0000 A__: Optional[int] = 5000 A__ , A__: Optional[int] = os.path.split(__file__) A__: ...
506
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file...
475
import doctest from collections import deque import numpy as np class __lowercase : """simple docstring""" def __init__( self ) -> None: snake_case : Any = [2, 1, 2, -1] snake_case : int = [1, 2, 3, 4] def...
587
0
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_ :Any = logging.get_logger(__na...
154
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def A ( a_ = "" ) -> dict[str, float]: __UpperCamelCase : Tuple =url or 'https://www.imdb.com/chart/top/?ref_=nv_mv_250' __UpperCamelCase : Optional[int...
154
1
# 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/LICENSE-2.0 # # Unless re...
519
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : int = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available(): r...
519
1
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __a = logging.get_logger(__name__) class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Dict , *lowerCAmelCase__ : Dict , **lower...
702
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": __a = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfe...
257
0
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lowerCAmelCase__ = """.""" # Internal TensorFlow ops that can be sa...
514
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: list ) -> list: '''simple docstring''' if len(SCREAMING_SNAKE_CASE_ ) <= 1: return [tuple(SCREAMING_SNAKE_CASE_ )] A__ = [] def generate(SCREAMING_SNAKE_CASE_: int , SCREAMING_SN...
514
1
from __future__ import annotations _lowercase : Dict =[-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowercase : str =[-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def __UpperCAmelCase ( UpperCamelCase__ :list[float] ) -> list[float]: ...
718
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def __UpperCAmelCase ( UpperCamelCase__ :Iterable[str] , UpperCamelCase__ :int ) -> Generator[tuple[str, ...], None, None]: snake_case__ : Union[str, Any] ...
574
0
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) __lowerCamelCase : List[Any] = ...
501
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import G...
501
1
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py _lowerCamelCase : List[Any] = """src/transformers""" _lower...
709
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_in...
308
0
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder A_ : str = datasets.utils.logging.get_logger(__name__) class _lowerCAmelCase( folder_based_builder.FolderBas...
57
lowercase__ : Dict = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)] def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: a = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared ...
515
0
_A = 8.314_4598 def lowercase_ ( A__ , A__ ) -> float: """simple docstring""" if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("Molar mass cannot be less than or equal to 0 kg...
294
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 _A = { # 1536-bit 5: { "prime": int( "FFFFFFFFF...
294
1
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 ( ...
234
from __future__ import annotations def a (_lowerCAmelCase ): SCREAMING_SNAKE_CASE_ = len(_lowerCAmelCase ) // 2 # choose the middle 3 elements SCREAMING_SNAKE_CASE_ = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[0...
234
1
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int = 1 , _lowerCamelCase: int = 1000 ) -> Optional[int]: '''simple docstring''' __lowerCamelCase : Optional[Any] = 1 __lowerCamelCase : Dict = 0 for divide_by_number in range...
711
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision ...
366
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformer...
50
'''simple docstring''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class __lowercase (__lowerCamelCase ...
596
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 ...image_utils import ( ...
707
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ( ...
472
0
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def __UpperCAmelCase ( ): __lowercase : Any = input('''Enter message: ''' ) __lowercase : Union[str, Any] = input('''Enter key [alphanumeric]: ''' ) __lowercase ...
76
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
1
def lowerCamelCase_ ( _a : float , _a : float , _a : int ): '''simple docstring''' if principal <= 0: raise Exception("""Principal borrowed must be > 0""" ) if rate_per_annum < 0: raise Exception("""Rate of interest must be >= 0""" ...
702
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionScheduler from ...utils...
322
0
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processo...
392
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokeni...
392
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase__ ( __A: str ,__A: int=False ): '''simple docstring''' __magic_name__ : List[Any] = OmegaConf.load(__A ) if displa...
501
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __lowerCamelCase : List[Any] = { '''configuration_speech_to_text''': ['''SPEECH_TO_...
501
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable _A : str = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXConfig"""]} try: if not is_to...
100
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowercase : List[str] = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not i...
142
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testi...
704
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule a : List[str] = {"""processing_wav2vec2_with_lm""": ["""Wav2Vec2ProcessorWithLM"""]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM ...
85
0
import torch from diffusers import DiffusionPipeline class lowerCamelCase_ ( _lowercase ): def __init__( self : Optional[int] , __A : Optional[Any] , __A : Dict ): super().__init__() self.register_modules(unet=__A , scheduler=_...
17
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask f...
542
0
from __future__ import annotations from decimal import Decimal from numpy import array def __lowercase ( _UpperCAmelCase ) -> list[list[float]]: '''simple docstring''' __lowercase = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only...
576
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = {'configuration_xglm': ['XGLM_PRETRAINED_CONFIG_ARC...
576
1
from maths.prime_factors import prime_factors def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> int: if not isinstance(_snake_case , _snake_case ): _A = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number <...
2
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar("""T""") def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> int: return (position - 1) // 2 def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> ...
2
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a__: Optional[Any] = logging.get_logger(__name__) a__: Tuple = {} class SCREAMING_SNAKE_CASE__ ( UpperCamelCase__ ): __SCREAMING_SNAKE_CASE = '''llama''' __S...
212
from ...configuration_utils import PretrainedConfig from ...utils import logging a__: Any = logging.get_logger(__name__) a__: List[str] = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.js...
212
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCAmelCase : ...
58
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_t...
58
1
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def __snake_case ( lowercase : Union[str, Any] ): for param in module.parameters(): snake_case_ = False def __snake_case ( ): snake_case_ = "cu...
721
'''simple docstring''' import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import Batch...
420
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import ...
113
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EX...
113
1
'''simple docstring''' import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock i...
714
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transfor...
347
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def __lowerCAmelCase( ...
27
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/ch...
554
0
def a__ ( snake_case ) -> bool: """simple docstring""" if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('''Input series is not valid, valid series - [2, 4, 6]''' ) if len(__lowerCAmelCase ) == 0: raise ValueError('''Input l...
712
from math import pi, sqrt def a__ ( snake_case ): """simple docstring""" if num <= 0: raise ValueError('''math domain error''' ) if num > 171.5: raise OverflowError('''math range error''' ) elif num - int(snake_case ) not in (0, 0.5): raise NotImplemen...
131
0
"""simple docstring""" import os from math import logaa def lowercase__ ( snake_case_ :str = "base_exp.txt" ): __UpperCAmelCase = 0 __UpperCAmelCase = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(snake_case_ ) , snake_case_ ) ...
49
"""simple docstring""" from collections import deque class _UpperCAmelCase : def __init__( self : List[Any] , _lowercase : str , _lowercase : int , _lowercase : int ): __UpperCAmelCase = process_name # process name _...
49
1
"""simple docstring""" def __lowerCamelCase ( SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE,) -> float: """simple docstring""" _UpperCAmelCase = [redshift, radiation_density, matter_density, dark...
494
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timestep...
494
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class ...
39
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _a : Optional[Any] = logging.get_logger(__name__) class UpperCamelCase_ ( __UpperCamelCase ): """simple docstring""" def __init__( self , *UpperCAmelCase...
479
0
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging _lowercase = logging.get_logger(__name__) def _A (UpperCamelCase : Dict , UpperCamelCase : Optional[int] ) ->Tuple: '''simp...
717
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging _lowercase = logging.get_logger(__name__) def _A (UpperCamelCase : Dict , UpperCamelCase : Optional[int] ) ->Tuple: '''simp...
96
0
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_uti...
95
def lowercase_( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) lowerCamelCase : List[str] = str(bin(SCREAMING_SNAKE_CASE_ ) )[2:] # remo...
340
0
'''simple docstring''' import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _lowerCamelCase ( unittest.TestCase ): '''s...
540
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device f...
540
1
'''simple docstring''' from torch import nn class __lowerCAmelCase ( nn.Module ): def __init__(self , lowerCAmelCase__ , lowerCAmelCase__ ): super().__init__() _UpperCAmelCase : Union[str, Any] = class_size ...
414
'''simple docstring''' from __future__ import annotations from random import random class __lowerCAmelCase : def __init__(self , lowerCAmelCase__ = None ): _UpperCAmelCase : List[Any] = value _UpperCAmelCase : Optional...
414
1
a__: int = '\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/huggingface/transfo...
718
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor a__: Optional[int] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( UpperCamelCase__ ): def __init__( self,*__lowerCamelCase,**__lowerCamelCa...
212
0
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transforme...
27
# Copyright 2022 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 r...
27
1
'''simple docstring''' import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase_...
178
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase__ : Tuple = logging.get_logger(__name__) UpperCamelCase__ : List[str] = { '''t5-...
178
1
from collections import namedtuple import requests from lxml import html # type: ignore A_: List[str] = namedtuple('covid_data', 'cases deaths recovered') def __lowerCAmelCase ( _A = "https://www.worldometers.info/coronavirus/" ): """simple docstring""" _lowercase ...
398
'''simple docstring''' from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class _SCREAMING_SNAKE_CASE : """simple docstring""" pass
316
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/G...
44
'''simple docstring''' from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _lowercase ( yaml.SafeLoader ): def UpperCamelCase ( self , A__ ) -> List[str]: snake_case =...
44
1
'''simple docstring''' import re def _SCREAMING_SNAKE_CASE (A ) -> bool: """simple docstring""" lowercase__ = re.compile(R'''^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$''' ) if match := re.search(A , A ): return match.string == phone return F...
460
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _SCREAMING_SNAKE_CASE (A ) -> Dict: """simple docstring""" lowercase__ = os.path.join(args.tf_model_dir , ''...
460
1
"""simple docstring""" import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowercase : List[str] = logging.get_logger(__name__) __lowercase : Union[str, ...
93
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowercase : Dict = { "configuration_vision_text_dual_encoder": ["Visi...
93
1
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin...
96
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transforme...
96
1
"""simple docstring""" from typing import Dict, List, Optional, Tuple, 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, re...
93
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from ...
93
1
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.r...
625
from __future__ import annotations import requests UpperCamelCase_ = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories c...
625
1
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase ...
709
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
447
0
from __future__ import annotations UpperCamelCase = 8.9_88e9 # units = N * m^s * C^-2 def __lowerCamelCase ( __lowerCAmelCase : float , __lowerCAmelCase : float , __lowerCAmelCase : float , __lowerCAmelCase : f...
269
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blen...
269
1
'''simple docstring''' __UpperCamelCase : Tuple = """0.18.2""" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffu...
270
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Optional[int] ...
270
1
def _UpperCAmelCase ( a : int ): if num <= 0: raise ValueError("""Input must be a positive integer""" ) snake_case__ = [True] * (num + 1) snake_case__ = 2 while p * p <= num: if primes[p]: for...
654
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( lowercase_ ): """simple docstring""" _lowercase : int = (IPNDMScheduler,) _lowercase : int = (('''num_inference_steps''', 50...
654
1
"""simple docstring""" from typing import Dict, List, Optional, Tuple, 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...
711
"""simple docstring""" import math import qiskit def __snake_case ( UpperCamelCase = 1 , UpperCamelCase = 1 , UpperCamelCase = 1 ) -> qiskit.result.counts.Counts: """simple docstring""" if ( isinstance(UpperCamelCase , UpperCamelCase ) or isinstance(UpperCam...
158
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : List[str] = logging.get_logger(__name__) UpperCamelCase__ : Any = { "microsoft/wavlm-base": "https://huggingface.co/microsoft/...
591
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig, ) def a__...
74
0
__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", "huggingface-hub": ...
708
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges fi...
241
0
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') lowerCAmelCase : List[Any] = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) ...
3
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Union[str, Any] = { 'configuration_git': ['GIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GitConfig', 'GitVisionConfig'], 'processing_...
3
1
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_checkpoin...
336
import math import random def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase = False ) ->float: """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowercase...
336
1
import math from datetime import datetime, timedelta def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : int ): UpperCamelCase_ : Tuple = year % 19 UpperCamelCase_ : Optional[int] = year % 4 UpperCamelCase_ : int = year % 7 UpperCamelCase_ ...
635
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor lowerCamelCase = logging.get_logger(__name__) class A ( UpperCamelCase_ ): def __init__( self : Optional[Any] , *lowercase_ : str , **lowercase_ : List[Any] ) ...
464
0
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.p...
199
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: from ...util...
199
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class Up...
5
"""simple docstring""" import argparse 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 import ...
123
0
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json d...
705
__magic_name__ : List[str] = tuple[float, float, float] __magic_name__ : Optional[int] = tuple[float, float, float] def lowercase__ ( _UpperCamelCase , _UpperCamelCase) -> Vectorad: """simple docstring""" UpperCamelC...
410
0
def _a ( lowerCamelCase ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], }, { 0: [6], 1: [9], 2: [4, 5], ...
681
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merge...
606
0
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : str , lowercase_ : str ): def get_matched_characters(lowercase_ : str , lowercase_ : str ) -> str: lowercase = [] lowercase = min(len(_stra...
653
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : int , lowercase_ : int , lowercase_ : list[list[int]] ): def update_area_of_max_square(lowercase_ : int , lowercase_ : int ) -> int: # BASE CASE if row >= r...
653
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffu...
361
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @requir...
361
1
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transform...
666
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE_ ) class SCREAMING_SNAKE_CASE (...
666
1
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowerCAmelCase_ ( __a ) -> int: """simple docstring""" lowerCamelCase__: Any =os.path.join(args.tf_model_dir , "parameters...
59
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_...
43
0
def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> str: """simple docstring""" __UpperCamelCase = len(a_ ) for i in range(length - 1 ): __UpperCamelCase = i for k in range(i + 1 , a_ ): if collection[k] < collection[leas...
705
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { "RWKV/rwkv-4-169m-pile": "https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json", "RWKV/rwkv-4-430m-pile": "https://huggingface.co/RWKV/rwkv-4-430m-pi...
375
0