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
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCamelCase__ = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', ...
86
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from...
9
0
from __future__ import annotations from collections.abc import Generator def UpperCAmelCase__ ( ): lowercase :dict[int, int] = {} lowercase :List[Any] = 2 while True: lowercase :Dict = factor_map.pop(lowerCamelCase, lowerCamelCase ) if factor: lower...
158
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging _Uppe...
158
1
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class _a : _a : Dict = None def UpperCAmelCase__( self : Union[str, Any] )-> int: lowerCAmelCase__ : str =...
131
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( _lowercase): _a : Union[str, Any] = ['''image_processor''', '''tokenizer'''] _a : List[Any] = '''ChineseCLIPImageProcess...
131
1
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { 'nvidia/segforme...
194
from __future__ import annotations def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : List[Any] = str(SCREAMING_SNAKE_CASE__ ) return len(SCREAMING_SNAKE_CASE__ ) == 9 and set(SCREAMING_SNAKE_CASE__ ) == set('123456789' ) def UpperCamelCase__ ...
194
1
snake_case_ = { "joule": 1.0, "kilojoule": 1000, "megajoule": 1000000, "gigajoule": 1000000000, "wattsecond": 1.0, "watthour": 3600, "kilowatthour": 3600000, "newtonmeter": 1.0, "calorie_nutr": 4186.8, "kilocalorie_nutr": 4186800.00, "electronvolt"...
24
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_pr...
24
1
'''simple docstring''' import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : Optional[Any] = logging.get_logger(__name__) lowercase__ : ...
359
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline 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 ...
287
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_av...
8
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): snake_case_ = [] if len(SCREAMING_SNAKE_CASE__ ) == 1: return [nums.copy()] for _ in range(len(SCREAMING_SNAKE_CASE__ ) ): snake_case_ = nums.pop(0 ) snake_case_ ...
8
1
'''simple docstring''' import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn fr...
220
'''simple docstring''' import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_t...
220
1
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_MO...
18
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class a__ ( yaml.SafeLoader ): def __UpperCamelCase ( self : str,_A : List[str] ): """simple docstring""" SCREAMING_SNAKE_CASE_...
18
1
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : Dict , __UpperCamelCase : str ): """simple docstring""" __UpperCamelCase =(boundary[1] - boundary[0]) / steps __UpperCamelCase =boundary[0] __UpperCamelCase =boundary[1] __UpperCa...
360
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : str ): """simple docstring""" __UpperCamelCase =0 # if input_string is "aba" than new_input_string become "a|b|a" __UpperCamelCase ='''''' __UpperCamelCase ='''''' # append eac...
85
0
'''simple docstring''' from collections import namedtuple A__: List[Any] = namedtuple('''from_to''', '''from_ to''') A__: Union[str, Any] = { '''cubicmeter''': from_to(1, 1), '''litre''': from_to(0.001, 1000), '''kilolitre''': from_to(1, 1), ...
276
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available lowerCAmelCase_ = logging.getLogger(__name__) @dataclass class ...
279
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json", } class UpperCAmelCase_ ( A__): lowerCamelCase__ ...
351
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ...
300
0
from __future__ import annotations from typing import Any class UpperCAmelCase : def __init__(self : str , snake_case__ : int ) -> None: '''simple docstring''' snake_case : str = num_of_nodes snake_case :...
59
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbed...
59
1
import argparse import struct import unittest class lowercase : '''simple docstring''' def __init__(self , __a ) -> None: """simple docstring""" UpperCAmelCase__ = data # Initialize hash values UpperCAmelCase__ = [ ...
335
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
335
1
'''simple docstring''' import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp ...
56
'''simple docstring''' import re def __magic_name__ ( __UpperCAmelCase ) -> bool: '''simple docstring''' snake_case_ = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(__UpperCAmelCase, __U...
56
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Tuple = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try...
360
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def a_ ( __lowercase : np.ndarray , __lowercase : np.ndarray , __lowercase : np.ndarray , __lowercase : int , __lowercase : int ) -> np.ndarray: _snake_case ...
130
0
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_comm...
152
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __SCREAMING_SNAKE_CASE ( lowerCamelCase ): snake_case_ = ["""image_processor""", """tokenizer"""] snake_case_ ...
152
1
'''simple docstring''' def __lowerCamelCase ( _lowercase , _lowercase , _lowercase ) -> float: return round(float(moles / volume ) * nfactor ) def __lowerCamelCase ( _lowercase , _lowercase , _lowercase ) -> float: return round(float((mo...
338
'''simple docstring''' import numpy as np class UpperCamelCase_ : def __init__( self ) -> int: UpperCAmelCase : str = (0, 0) UpperCAmelCase : Union[str, Any] = None UpperCAmelCase : Any = 0 UpperCAmelC...
338
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def A_ ( _lowerCAmelCase ) -> Optional[int]: if "cls_token" in name: UpperCamelCase : Union[str, Any] = name.replace("cls_toke...
52
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging lowerCAmelCase : Tuple = logging.get_logger(__name__) ...
291
0
'''simple docstring''' def UpperCamelCase ( a = 1000 ) -> int: '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
98
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils ...
98
1
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = ...
86
"""simple docstring""" import os import pytest from attr import dataclass lowerCamelCase__ = """us-east-1""" # defaults region @dataclass class A__ : A_ : str A_ : Union[str, Any] = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' A_ : ...
86
1
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : Dict ): A__ = len(UpperCAmelCase_ ) A__ = sum(UpperCAmelCase_ ) A__ = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in rang...
69
"""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, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSD...
69
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase__ ( lowercase ): '''simple docstring''' lowerCamelCase__ = ["""image_processor...
96
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrog...
256
0
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaX...
7
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets snake_case_ : Dict = "\\n@inproceedings{snover-etal-2006-study,\n title = \"A Study of Translation Edit Rate with Targeted Human Annotation\",\n author = \"Snover, Matthew and\n Dorr, ...
7
1
'''simple docstring''' from __future__ import annotations def a_ ( __snake_case : list[list[int]] ) -> bool: """simple docstring""" lowerCamelCase_ =len(__snake_case ) # We need to create solution object to save path. lowerCamelCa...
75
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase : Optional[int] = logging.get_logger(__name__) __UpperCAmelCase : Optional[int] ...
111
0
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _lowerCamelCase : Dict = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", ...
249
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( A__ ) -> int: """simple docstring""" UpperCamelCase = len(A__ ) // 2 # choose the middle 3 elements UpperCamelCase = lst[m - 1 : m + 2] ...
249
1
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor,...
278
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenize...
326
0
from typing import Any class _lowercase : """simple docstring""" def __init__(self , lowerCamelCase_ ): """simple docstring""" a = data a = None def __repr__(self ): """simple docstring""" return F'''Node({self.data})''' clas...
350
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
71
0
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class SCREAMING_SNAKE_CASE ( lowerCamelCase__ , unittest.TestCase ): __lowerCamelCase : Any =DownBlockaD...
302
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig lowerCamelCase__ = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albert-large-v1""": """https://huggin...
302
1
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked bef...
307
import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose, ) if i...
307
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCAmelCase : Union[str, Any] =logging.get_logger(__name__) __lowerCAmelCase : Dict ={ 'google/bit-50': 'https://h...
9
"""simple docstring""" from ...configuration_utils import PretrainedConfig class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :str = "bert-generation" def __init__( self , __A=5_0358 , __A=1024 , __A=24 , __A=16 ...
84
0
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_CLA...
351
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging a =logging.get_logger(__name__) def SCREAMING_SNAK...
113
0
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from ...
103
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(import...
321
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=lowercase_ ): """simple docstring""" _SCREAMING_SNAKE_CASE = ["""torch""", """torchsde"""] def __init__( ...
289
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mod...
289
1
from __future__ import annotations __UpperCAmelCase = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } ...
119
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 OnnxConfigWithPast, PatchingSpec from ......
119
1
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common ...
140
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Tuple = logging.get_logger(__name__) class A__ ( __snake_case ): _UpperCAmelCase :List[Any] = 'timm_backbone' def __init__( self , A_=None , ...
140
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class __magic_name__ ( _UpperCamelCase ): ...
89
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB 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/lice...
89
1
'''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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
8
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase ( lowerCamelCase_ :Dict , ...
8
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow, ...
180
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): """simple docstring""" lowerCamelCase :Tuple = JukeboxTokenizer lowerCamelCase :str = { '''artist...
180
1
class _snake_case : def __init__( self: Union[str, Any] , __lowerCamelCase: str = "" , __lowerCamelCase: bool = False ) -> None: # Mapping from the first character of the prefix of the node __UpperCAmelCase : dict[str, RadixNode] = ...
342
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _UpperCamelCase ( snake_case__ ) -> Tupl...
342
1
"""simple docstring""" 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 .....
86
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class A__ ( _lowerCamelCase): A_ : Any = ['image_processor', 'tokenizer'] A_ : Optional[Any] = 'AutoImageProcessor' A_ : ...
86
1
"""simple docstring""" import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet fr...
363
"""simple docstring""" import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_m...
149
0
def __lowerCamelCase ( lowerCamelCase__ : list[list[int]] , lowerCamelCase__ : int , lowerCamelCase__ : int , lowerCamelCase__ : set ): '''simple docstring''' lowerCamelCase , lowerCamelCase = len(lowerCamelCase__ ), len(grid[0] ) i...
252
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : List[str] = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", "XCLIPVisionConfig...
252
1
"""simple docstring""" def _a ( lowerCamelCase: List[Any] ) -> str: '''simple docstring''' stooge(_snake_case , 0 , len(_snake_case ) - 1 ) return arr def _a ( lowerCamelCase: List[Any] , lowerCa...
369
from ..utils import DummyObject, requires_backends class A_ ( metaclass=_lowerCamelCase ): lowerCAmelCase__ = ["""speech"""] def __init__(self :Optional[int] , *_UpperCamelCase :int , **_UpperCamelCase :List[str] )-> List[str]:...
250
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig class lowerCAmelCase_ ( lowerCAmelCase ): """simple docstring""" _lowerCAmelCase : Tuple = """bert-generation""" def __init__( self , lowerCAmelCase=5_03_58 , lowerCAmelCase=10_24 ...
150
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conve...
150
1
"""simple docstring""" from __future__ import annotations def _UpperCAmelCase ( __lowerCamelCase : list[int] , __lowerCamelCase : int ) -> list[int]: _snake_case = 0 _snake_case = len(__lowerCamelCase ) - 1 while i < j: if nums[i] + nums[j] == target: ...
40
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCAmelCase__ : __a = 42 __a = 42 class lowerCAmelCase__ : ...
40
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCond...
21
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> str: lowerCamelCase__ : Optional[int] = [ 'encoder.version', 'decoder.version', ...
50
0
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional ...
235
from math import ceil def lowerCamelCase__ ( _lowercase = 1001 ): '''simple docstring''' UpperCAmelCase_ : Optional[Any] = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): UpperCAmelCase_ : List[Any] = 2 * i +...
235
1
"""simple docstring""" import os import string import sys __lowercase = 1 << 8 __lowercase = { """tab""": ord("""\t"""), """newline""": ord("""\r"""), """esc""": 27, """up""": 65 + ARROW_KEY_FLAG, """down""": 66 + ARROW_KEY_FLAG, """...
40
def _a ( UpperCAmelCase , UpperCAmelCase ) -> Union[str, Any]: """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(UpperCAmelCase , int(b / 2 ) ) * actual_power(UpperCAmelCase , int(b / 2 ) ) else: r...
142
0
"""simple docstring""" from math import sqrt def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> int: SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(SCREAMING_SNAKE_CASE_ ) + 1 ) ): if n % i == 0 and i != sqrt(SCREAMING_SNAKE...
366
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = {'''vocab_file''': '''vocab.json'''} __Upp...
38
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : Union[str, Any] ) -> list[list[int]]: """simple docstring""" A__ : int =[] if len(lowercase__ ) == 1: return [nums.copy()] for _ in range(len(lowercase__...
134
from math import isqrt def _lowerCamelCase( lowercase__ ) -> bool: '''simple docstring''' return all(number % divisor != 0 for divisor in range(2 , isqrt(lowercase__ ) + 1 ) ) def _lowerCamelCase( lowercase__ = 1_0**6 ) -> int: '''simple docstring''' __...
295
0
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a :Union[str, Any] = get_tests_dir("fixtu...
56
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import...
56
1
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup __lowerCamelCase : Any = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deformable_detr/cuda/ms_defo...
219
'''simple docstring''' from __future__ import annotations def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =[True] * limit __lowercase =False __lowercase =False __lowercase =True for i in range(3 , int(...
166
0
"""simple docstring""" from math import factorial, pi def UpperCAmelCase__ ( lowerCAmelCase__ :float , lowerCAmelCase__ :int = 3_0 ) -> float: '''simple docstring''' if not isinstance(lowerCAmelCase__ , (int, float) ): raise ValueError("""maclaur...
361
"""simple docstring""" import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __lowerCAmelCa...
32
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase_ ...
104
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class lowerCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__(self , *_lowerCamelCase , **_lowerCamelCase ): """simple docstring""" super().__init__(*_...
171
0
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that ther...
78
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 __snake_case = logging.get_logger(__name__) __snake_case = { '''google/efficient...
78
1
'''simple docstring''' import qiskit def snake_case_ (_a : int , _a : int ): UpperCAmelCase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register UpperCAmelCase = qiskit.QuantumCircuit(_a ...
34
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructu...
317
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'vocab_file': 'vocab.json', 'merg...
238
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): ...
238
1
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput UpperCAmelCase__ = "scheduler_config.json" class lowercase_ ( lowercase ): ...
0
"""simple docstring""" import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import fr...
290
0
import numpy as np def __lowerCAmelCase ( a__ ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A : Optional[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDepend...
33
0
'''simple docstring''' lowerCamelCase = range(2, 20 + 1) lowerCamelCase = [10**k for k in range(ks[-1] + 1)] lowerCamelCase = {} def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): """simple doc...
166
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProc...
166
1
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformer...
226
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConf...
226
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase__ : int = { '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''], } try: if not is_torch_available(): r...
338
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ ( UpperCamelCase_ ): """simple docstring""" UpperCAmelCase_ : str = (DDPMScheduler,) def SCREAMING_SNAKE_CASE_ ( self , **__SCREA...
338
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ = { "configuration_data2vec_audio": ["DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP", "Data2VecAudioConfig"], "configuration_data2vec_text": [ ...
350
'''simple docstring''' import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase_ = { ...
111
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Wav2Vec2Config"""], ...
317
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Wav2Vec2Config"""], ...
317
1
def UpperCamelCase__( UpperCamelCase__ : Tuple )->bool: if num < 0: return False A__ = num A__ = 0 while num > 0: A__ = rev_num * 10 + (num % 10) num //= 10 return num_copy ...
368
def UpperCamelCase__( UpperCamelCase__ : int = 1_00 )->int: A__ = (n * (n + 1) // 2) ** 2 A__ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F"{solution() = }")
39
0
import argparse import os # New Code # 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 ...
14
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 : Optional[Any]...
50
0
from ..utils import DummyObject, requires_backends class a ( metaclass=_A ): '''simple docstring''' lowerCAmelCase : List[str] = ['flax', 'transformers'] def __init__( self : Tuple , *__snake_case : str , **__s...
177
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/data2vec-text...
177
1
import re import subprocess import sys a_ : Tuple = subprocess.check_output('git merge-base main HEAD'.split()).decode('utf-8') a_ : Tuple = ( subprocess.check_output(f"""git diff --diff-filter=d --name-only {fork_point_sha}""".split()).decode('utf-8').split() ) a_ : ...
137
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Tuple = logging.get_logger(__name__) lowercase__ : Any = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface...
224
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Any =logging.get_logger(__name__) A__ : Dict ={ '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/confi...
354
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, ...
220
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 ) ->Union[str, Any]: """simple docstring""" lowerCAmelCase__ :Union[str, Any] = length or len(_a ) lowerCAmelCase__ :List[str] = False for i in range(length - ...
293
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try: if not ...
131
0
from math import factorial class _UpperCAmelCase : """simple docstring""" def __init__( self : Union[str, Any] , lowerCAmelCase_ : List[Any] , lowerCAmelCase_ : Tuple ) -> Tuple: __lowerCAmelCase = real if isinstance(lowerCAmelCase_ , lowerCAm...
359
from functools import lru_cache @lru_cache def a_ ( lowerCAmelCase_ : 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__": import doctest doctest.testmod()
207
0
from __future__ import annotations from functools import lru_cache from math import ceil __lowerCamelCase : str = 100 __lowerCamelCase : Any = set(range(3, NUM_PRIMES, 2)) primes.add(2) __lowerCamelCase : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if pri...
52
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, nes...
9
0
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : int = 1_0_0_0 ): '''simple docstring''' _UpperCAmelCase : Optional[Any] =-1 _UpperCAmelCase : Optional[Any] =0 for a in range(1 , n // 3 ): # Sol...
363
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_fl...
242
0
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 from transformers.utils imp...
216
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import ...
216
1
from random import randint from tempfile import TemporaryFile import numpy as np def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ )-> Dict: """simple docstring""" UpperCamelCase_ = 0 if start < end: Upper...
60
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> list: """simple docstring""" if len(SCREAMING_SNAKE_CASE_ ) <= 1: return lst UpperCamelCase_ = 1 while i < len(SCREAMING_SNAKE_CASE_ ): if lst[i - 1] <= lst[i]: i += 1 else: ...
60
1
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging A = logging.get_logger(__name__) # TODO: upload to AWS A = { '''yjernite/retribert-base-uncased''': ( '''https://huggingface.co/yjernite/retrib...
160
def __lowercase ( _UpperCamelCase = 4000000 ) ->int: """simple docstring""" lowercase : int = [] lowercase , lowercase : str = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_UpperCamelCase ) ...
337
0
"""simple docstring""" __A = 6_5_5_2_1 def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: lowercase__: Optional[Any] = 1 lowercase__: Dict = 0 for plain_chr in plain_text: lowercase__: Optional[int] = (a + ord(__UpperCAmelCase )) % M...
364
"""simple docstring""" import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __A = get_tests_dir("fixtu...
2
0
'''simple docstring''' import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_ten...
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices ...
180
0
def UpperCamelCase ( _A : str )-> str: """simple docstring""" return " ".join( "".join(word[::-1] ) if len(_A ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(rever...
351
import datasets from .evaluate import evaluate UpperCAmelCase_ : List[Any] = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},...
198
0
'''simple docstring''' __lowercase = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] __lowercase = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] __lowercase = { 0: '''Sunday''', 1: '''Monday''', 2: '''Tuesday''', 3: '''Wednesday''', 4: '''Thursday''', 5: '''Friday''', 6: '''Sat...
272
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowercase = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], } try: if not is_to...
272
1
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logg...
155
"""simple docstring""" import math import sys def __lowercase ( _a ): if number != int(_a ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value of input must not be a negative number''' ) if number == ...
155
1
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class a__ ( snake_case__ ): _a : List[Any] =...
92
'''simple docstring''' import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files" , [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "dataset_inf...
22
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE :List[Any] = { """configuration_convnext""": ["""CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
364
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE :int = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not is_torch_avai...
124
0
'''simple docstring''' class lowerCAmelCase_ : '''simple docstring''' def __init__( self : List[str] , SCREAMING_SNAKE_CASE_ : int ) -> Tuple: '''simple docstring''' A: Optional[Any] = s...
319
from pathlib import Path import fire def UpperCamelCase( __UpperCamelCase : str ,__UpperCamelCase : str ,__UpperCamelCase : int ): lowerCAmelCase_ : List[str] = Path(__UpperCamelCase ) lowerCAmelCase_ : Union[str, Any] = Path(__UpperCamelCase ) d...
103
0
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
60
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokeniz...
60
1
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils....
340
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass a_ = (3, 9, -11, 0, 7, 5, 1, -1) a_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class lowercase__ : a_ =42 a_ =42 class lowercase__ : def __init__( ...
340
1
from math import factorial _UpperCAmelCase = {str(d): factorial(d) for d in range(10)} def UpperCamelCase ( __lowercase : int ): '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(__lowercase ) ) def UpperCamelCase ( ): ...
192
_UpperCAmelCase = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" def UpperCamelCase ( ): '''simple docstring''' A_ : Tuple = input('Enter message: ' ) A_ : int = input('Enter key [alphanumeric]: ' ) A_ : Optional[Any] = input('Encr...
192
1
def _a ( SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : list[int] ): __lowerCAmelCase = len(SCREAMING_SNAKE_CASE_ ) print("The following activities are selected:" ) # The first activity is always selected __lowerCAmelC...
92
def __lowercase ( a__ ) -> bool: return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number or not...''') lowerCAmelCase__ : Optional[Any] =int(input(''...
257
0
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __lowercase = 299_792_458 # Symbols __lowercase , __lowercase , __lowercase , __lowercase = symbols('''ct x y z''') def lowerCAmelCase (__UpperCamelCas...
369
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def lowerCAmelCase (__UpperCamelCase : Tuple ): ...
85
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device _A : Union[str, Any] =False class _lowe...
41
from PIL import Image def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : Image , _lowerCamelCase : int) -> Image: '''simple docstring''' __UpperCamelCase : str = (259 * (level + 255)) / (255 * (259 - level)) def contrast(_lowerCamel...
232
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERendere...
246
'''simple docstring''' import math def lowercase__( __UpperCamelCase: float ,__UpperCamelCase: float ): """simple docstring""" return math.pow(__UpperCamelCase ,2 ) - a def lowercase__( __UpperCamelCase: float ): """s...
246
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import...
249
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
1
import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECORDS...
355
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
292
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class _snake_case ( UpperCamelCase_ ): snake_...
135
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTeste...
199
0
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __A : List[str] = logging.getLogger(__name__) def __UpperCamelCase ( ) ->int: """simple docstring""" lowerCamelCase_ ...
371
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _SCREAMING_SNAKE_CASE ( lowerCAmelCase__): def __init__( self , _SCRE...
49
0
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional ...
124
import re def SCREAMING_SNAKE_CASE__ ( lowercase ) -> str: if len(re.findall("""[ATCG]""" ,lowercase ) ) != len(lowercase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) ) if __name__ ==...
124
1
"""simple docstring""" import numpy as np import datasets SCREAMING_SNAKE_CASE_ = """ Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of th...
371
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class UpperCamelCase__ ( lowerCAmelCase...
193
0
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, ...
345
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def _lowerCAmelCase ( ) -> None: """simple docstring""" assert or_gate(0 , 0 ...
230
0
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import ...
351
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch...
298
0