code stringlengths 82 54.1k | code_codestyle int64 0 699 | style_context stringlengths 111 35.6k | style_context_codestyle int64 0 699 | label int64 0 1 |
|---|---|---|---|---|
import argparse
import json
from pathlib import Path
import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor
from transformers.image_utils import PILImageResamp... | 0 |
"""simple docstring"""
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
lowerCAmelCase: str ={
"configuration_convbert": ["CONVBERT_PRETRAINE... | 607 | 0 |
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
__snake_case = '''▁'''
__snake_case = {'''vocab_file''': '''spiece.m... | 1 |
"""simple docstring"""
import re
def __snake_case ( __A ) -> str:
if len(re.findall("""[ATCG]""" ,__A ) ) != len(__A ):
raise ValueError("""Invalid Strand""" )
return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) )
if _... | 607 | 0 |
import json
import os
import re
import unittest
from transformers import CodeGenTokenizer, CodeGenTokenizerFast
from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, slow
from ...test_tokenization_common import Tokeni... | 2 |
"""simple docstring"""
import os
import random
import sys
from . import cryptomath_module as cryptoMath # noqa: N812
from . import rabin_miller as rabinMiller # noqa: N812
def __snake_case ( ) -> None:
print("""Making key files...""" )
make_key_files("""rsa""" ... | 607 | 0 |
'''simple docstring'''
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 .... | 3 |
"""simple docstring"""
from ... import PretrainedConfig
lowerCAmelCase: str ={
"sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json",
}
class lowerCamelCase__ ( __UpperCamelCase ):
__UpperCAmelCase = NEZHA_PRETRAIN... | 607 | 0 |
"""simple docstring"""
import numpy as np
import torch
from torch.utils.data import Dataset, IterableDataset
from ..utils.generic import ModelOutput
class a ( a__ ):
def __init__( self , _snake_case , _snake_case , _snake_case ):
"""simple doc... | 4 |
"""simple docstring"""
import tensorflow as tf
from ...tf_utils import shape_list
class lowerCamelCase__ ( tf.keras.layers.Layer ):
def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=False , **snake_case ) -> ... | 607 | 0 |
'''simple docstring'''
from __future__ import annotations
from math import gcd
def A (__lowerCamelCase :int , __lowerCamelCase :int = 2 , __lowerCamelCase :int = 1 , __lowerCamelCase :int = 3 , ):
# A value less than 2 can cause an infinite loop in the algorithm.
i... | 5 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( __A ,__A = "cpu" ,__A = None ) -> None:
lowercase : Optional[int] = torch.load(__A ,map_location=__A )
for k, v in tqdm(state_... | 607 | 0 |
import argparse
import torch
from transformers import (
UniSpeechSatConfig,
UniSpeechSatForAudioFrameClassification,
UniSpeechSatForSequenceClassification,
UniSpeechSatForXVector,
WavaVecaFeatureExtractor,
logging,
)
logging.set_verbosity_info()
_lowerCamelCase = logging.get_... | 6 |
"""simple docstring"""
import argparse
import json
import os
from collections import OrderedDict
import numpy as np
import tensorflow as tf
import torch
def __snake_case ( __A ) -> Any:
lowercase : List[str] = os.path.join(args.tf_model_dir ,"""para... | 607 | 0 |
"""simple docstring"""
import argparse
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM
from transformers.utils import logging
logging.set_verbosity_info()
a = logging.get_logger(__name__)... | 7 |
"""simple docstring"""
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_... | 607 | 0 |
'''simple docstring'''
import pytest
from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs
@pytest.mark.parametrize(
'kwargs, expected' , [
({'num_shards': 0, 'max_num_jobs': 1}, []),
({'num_shards': ... | 8 |
"""simple docstring"""
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def __snake_case ( __A ) -> Any:
def wrapper(*__A ,**__A ):
lowercase : Tuple ... | 607 | 0 |
# 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 required by appli... | 9 |
"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
convert,
ensure_valid_input,
ge... | 607 | 0 |
import argparse
import shlex
import runhouse as rh
if __name__ == "__main__":
# Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access
# setup instructions, if using on-demand hardware
# If user passes --user <user> --host <host> --key_... | 10 |
"""simple docstring"""
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
... | 607 | 0 |
'''simple docstring'''
import pytest
from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict
@pytest.mark.parametrize(
'''split_dict''' , [
SplitDict(),
SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1_337 , nu... | 11 |
"""simple docstring"""
import argparse
import torch
from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging
logging.set_verbosity_info()
lowerCAmelCase: Tuple =logging.get_logger(__name__)
lowerCAmelCase: int ... | 607 | 0 |
import numpy as np
from nltk.translate import meteor_score
import datasets
from datasets.config import importlib_metadata, version
lowerCamelCase__ : Any = version.parse(importlib_metadata.version("""nltk"""))
if NLTK_VERSION >= version.Version("""3.6.4"""):
from nltk import word_tokenize... | 12 |
"""simple docstring"""
import importlib.metadata
from typing import Union
from packaging.version import Version, parse
from .constants import STR_OPERATION_TO_FUNC
lowerCAmelCase: List[str] =parse(importlib.metadata.version("torch"))
def __snake_case ( __A ,__A ... | 607 | 0 |
'''simple docstring'''
from ..utils import DummyObject, requires_backends
class UpperCAmelCase_ (metaclass=_UpperCAmelCase ):
"""simple docstring"""
lowerCamelCase : Any = ['sentencepiece']
def __init__( self , *SCREAMING_SNAKE_CASE_ , **SCREAMING... | 13 |
"""simple docstring"""
def __snake_case ( ) -> Union[str, Any]:
lowercase : str = 0
for i in range(1 ,1001 ):
total += i**i
return str(__A )[-10:]
if __name__ == "__main__":
print(solution())
| 607 | 0 |
import argparse
import re
import torch
from CLAP import create_model
from transformers import AutoFeatureExtractor, ClapConfig, ClapModel
a__ = {
'''text_branch''': '''text_model''',
'''audio_branch''': '''audio_model.audio_encoder''',
'''attn''': '''attention.self''',
... | 14 |
"""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 tra... | 607 | 0 |
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 GPTaTokenizer
if ... | 15 |
"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import TensorType, logging
if TYPE_CHECKING:
from ...onnx.config i... | 607 | 0 |
def __a ( A__ : int ):
if not isinstance(A__ , A__ ):
raise ValueError("Input must be an integer" )
if input_num <= 0:
raise ValueError("Input must be positive" )
return sum(
divisor for divisor in range(1 , input_num // 2 + 1 ... | 16 |
"""simple docstring"""
from random import shuffle
import tensorflow as tf
from numpy import array
def __snake_case ( __A ,__A ) -> Any:
lowercase : Any = int(__A )
assert noofclusters < len(__A )
# Find out the dimensionality
lower... | 607 | 0 |
from __future__ import annotations
import copy
import inspect
import json
import math
import os
import tempfile
import unittest
from importlib import import_module
import numpy as np
from transformers import ViTMAEConfig
from transformers.file_utils import cached_property, is_tf_available, is_vision_available
from... | 17 |
"""simple docstring"""
import qiskit
def __snake_case ( __A ,__A ) -> qiskit.result.counts.Counts:
lowercase : List[Any] = qiskit.Aer.get_backend("""aer_simulator""" )
lowercase : int = qiskit.QuantumCircuit(4 ,2 )
# encod... | 607 | 0 |
'''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 __a(SCREAMING_SNAKE_CASE_ : Dict ):
'''... | 18 |
"""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 transforme... | 607 | 0 |
"""simple docstring"""
from random import randint, random
def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case, __snake_case = False, __snake_case = False, __snake_case = 5, ) -> list:
"""simple docstring"""
_UpperCamelCase = [[-1] * ... | 19 |
"""simple docstring"""
import argparse
import json
from typing import List
from ltp import LTP
from transformers.models.bert.tokenization_bert import BertTokenizer
def __snake_case ( __A ) -> Union[str, Any]:
# This defines a "chinese character" as anything in the C... | 607 | 0 |
from importlib import import_module
from .logging import get_logger
_lowerCAmelCase: str = get_logger(__name__)
class lowercase_ :
def __init__( self , lowercase_ , lowercase_=None) -> Tuple:
a__ =attrs or []
if module is not Non... | 20 |
"""simple docstring"""
import gc
import unittest
from transformers import CTRLConfig, 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 .... | 607 | 0 |
import argparse
import logging
import os
import re
import tensorflow as tf
from transformers import (
AutoConfig,
AutoTokenizer,
DataCollatorForLanguageModeling,
PushToHubCallback,
TFAutoModelForMaskedLM,
create_optimizer,
)
UpperCAmelCase_ : List[str] ... | 21 |
"""simple docstring"""
import math
import qiskit
def __snake_case ( __A = 1 ,__A = 1 ,__A = 1 ) -> qiskit.result.counts.Counts:
if (
isinstance(__A ,__A )
or isinstance(__A ,__A )
or isinstance(__A ,__A )
):
raise ... | 607 | 0 |
'''simple docstring'''
# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run
import doctest
import sys
import warnings
from os.path import abspath, dirname, join
import _pytest
from transformers.testing_utils import HfDoctestModule, HfDocTe... | 22 |
"""simple docstring"""
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
lowerCAmelCase: str ={
"configuration_convbert": ["CONVBERT_PRETRAINE... | 607 | 0 |
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 GPTaTokenizer
... | 23 |
"""simple docstring"""
import re
def __snake_case ( __A ) -> str:
if len(re.findall("""[ATCG]""" ,__A ) ) != len(__A ):
raise ValueError("""Invalid Strand""" )
return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) )
if _... | 607 | 0 |
'''simple docstring'''
import inspect
import warnings
from typing import Any, Dict, Optional, Union
from packaging import version
def _UpperCamelCase (*_lowerCamelCase : str , _lowerCamelCase : Optional[Union[Dict, Any]] = None , _lowerCamelCase : List[Any]=True , _low... | 24 |
"""simple docstring"""
import os
import random
import sys
from . import cryptomath_module as cryptoMath # noqa: N812
from . import rabin_miller as rabinMiller # noqa: N812
def __snake_case ( ) -> None:
print("""Making key files...""" )
make_key_files("""rsa""" ... | 607 | 0 |
def lowerCamelCase__ ( _a):
if a < 0:
raise ValueError("Input value must be a positive integer")
elif isinstance(_a , _a):
raise TypeError("Input value must be a 'int' type")
return bin(_a).count("1")
if __name__ == "__main__":
import doctest
doctest.testmod() | 25 |
"""simple docstring"""
from ... import PretrainedConfig
lowerCAmelCase: str ={
"sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json",
}
class lowerCamelCase__ ( __UpperCamelCase ):
__UpperCAmelCase = NEZHA_PRETRAIN... | 607 | 0 |
'''simple docstring'''
from __future__ import annotations
class _A :
def __init__( self : Optional[int] , __magic_name__ : list[list[int]] ) -> str:
"""simple docstring"""
__snake_case : str = TypeError(
... | 26 |
"""simple docstring"""
import tensorflow as tf
from ...tf_utils import shape_list
class lowerCamelCase__ ( tf.keras.layers.Layer ):
def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=False , **snake_case ) -> ... | 607 | 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, apply_forward_hook
from .modeling_utils import ModelMixin
from .vae import Decoder, Deco... | 27 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( __A ,__A = "cpu" ,__A = None ) -> None:
lowercase : Optional[int] = torch.load(__A ,map_location=__A )
for k, v in tqdm(state_... | 607 | 0 |
'''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:R... | 28 |
"""simple docstring"""
import argparse
import json
import os
from collections import OrderedDict
import numpy as np
import tensorflow as tf
import torch
def __snake_case ( __A ) -> Any:
lowercase : List[str] = os.path.join(args.tf_model_dir ,"""para... | 607 | 0 |
"""simple docstring"""
from typing import List, Optional, Union
import numpy as np
from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
from ....feature_extraction_sequence_utils import SequenceFeatureExtractor
from ....feature_extraction_utils import BatchFeature
from ....... | 29 |
"""simple docstring"""
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_... | 607 | 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... | 30 |
"""simple docstring"""
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def __snake_case ( __A ) -> Any:
def wrapper(*__A ,**__A ):
lowercase : Tuple ... | 607 | 0 |
import math
def UpperCAmelCase_ ( ) -> None:
SCREAMING_SNAKE_CASE_ = input('Enter message: ' )
SCREAMING_SNAKE_CASE_ = int(input(f"Enter key [2-{len(__UpperCAmelCase ) - 1}]: " ) )
SCREAMING_SNAKE_CASE_ = input('Encryption/Decryption [e/d]... | 31 |
"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
convert,
ensure_valid_input,
ge... | 607 | 0 |
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_flax_available():
from transformers.m... | 32 |
"""simple docstring"""
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
... | 607 | 0 |
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... | 33 |
"""simple docstring"""
import argparse
import torch
from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging
logging.set_verbosity_info()
lowerCAmelCase: Tuple =logging.get_logger(__name__)
lowerCAmelCase: int ... | 607 | 0 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( _lowercase ,_lowercase = "cpu" ,_lowercase = None ):
"""simple docstring"""
UpperCamelCase = torch.load(_lowercase ,map_location=_lowercase ... | 34 |
"""simple docstring"""
import importlib.metadata
from typing import Union
from packaging.version import Version, parse
from .constants import STR_OPERATION_TO_FUNC
lowerCAmelCase: List[str] =parse(importlib.metadata.version("torch"))
def __snake_case ( __A ,__A ... | 607 | 0 |
from __future__ import annotations
def a ( A__ ) -> list[int]:
'''simple docstring'''
if len(A__ ) == 0:
return array
SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = min(A__ ), max(A__ )
# Compute th... | 35 |
"""simple docstring"""
def __snake_case ( ) -> Union[str, Any]:
lowercase : str = 0
for i in range(1 ,1001 ):
total += i**i
return str(__A )[-10:]
if __name__ == "__main__":
print(solution())
| 607 | 0 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available
__lowercase : str = {
'''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''],
'''tokenization_xlm''': ['''X... | 36 |
"""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 tra... | 607 | 0 |
from __future__ import annotations
import inspect
import unittest
from typing import List, Tuple
from transformers import RegNetConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available
from ...test_configura... | 37 |
"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import TensorType, logging
if TYPE_CHECKING:
from ...onnx.config i... | 607 | 0 |
'''simple docstring'''
from typing import Optional, Tuple, Union
import torch
from einops import rearrange, reduce
from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel
from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput
from diff... | 38 |
"""simple docstring"""
from random import shuffle
import tensorflow as tf
from numpy import array
def __snake_case ( __A ,__A ) -> Any:
lowercase : Any = int(__A )
assert noofclusters < len(__A )
# Find out the dimensionality
lower... | 607 | 0 |
import warnings
from typing import Any, Dict, List, Optional, Union
import numpy as np
from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
... | 39 |
"""simple docstring"""
import qiskit
def __snake_case ( __A ,__A ) -> qiskit.result.counts.Counts:
lowercase : List[Any] = qiskit.Aer.get_backend("""aer_simulator""" )
lowercase : int = qiskit.QuantumCircuit(4 ,2 )
# encod... | 607 | 0 |
def UpperCamelCase ( snake_case__ : List[str] ) -> Optional[int]:
UpperCamelCase : int = [0] * len(snake_case__ )
UpperCamelCase : Optional[Any] = []
UpperCamelCase : Optional[Any] = []
UpperCamelCase ... | 40 |
"""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 transforme... | 607 | 0 |
'''simple docstring'''
import os
from datetime import datetime as dt
from github import Github
lowerCAmelCase__ = [
'''good first issue''',
'''good second issue''',
'''good difficult issue''',
'''enhancement''',
'''new pipeline/model''',
'''new scheduler''',
'''wip''',
]
... | 41 |
"""simple docstring"""
import argparse
import json
from typing import List
from ltp import LTP
from transformers.models.bert.tokenization_bert import BertTokenizer
def __snake_case ( __A ) -> Union[str, Any]:
# This defines a "chinese character" as anything in the C... | 607 | 0 |
'''simple docstring'''
import inspect
import os
import unittest
import torch
import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
execute_subprocess_async,
require_cpu,
require_huggingface_suite,
require_multi_gpu,
require_single_gpu,
)
from accelerate... | 42 |
"""simple docstring"""
import gc
import unittest
from transformers import CTRLConfig, 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 .... | 607 | 0 |
from collections.abc import Callable
from math import pi, sqrt
from random import uniform
from statistics import mean
def _a ( SCREAMING_SNAKE_CASE ):
"""simple docstring"""
def is_in_circle(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> bool:
lowercase__ = sqrt((x*... | 43 |
"""simple docstring"""
import math
import qiskit
def __snake_case ( __A = 1 ,__A = 1 ,__A = 1 ) -> qiskit.result.counts.Counts:
if (
isinstance(__A ,__A )
or isinstance(__A ,__A )
or isinstance(__A ,__A )
):
raise ... | 607 | 0 |
'''simple docstring'''
import functools
def A_ ( _lowerCAmelCase : list[int] , _lowerCAmelCase : list[int] ):
"""simple docstring"""
if not isinstance(_lowerCAmelCase , _lowerCAmelCase ) or not all(isinstance(_lowerCAmelCase , _lower... | 44 |
"""simple docstring"""
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
lowerCAmelCase: str ={
"configuration_convbert": ["CONVBERT_PRETRAINE... | 607 | 0 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
UpperCamelCase = logging.get_logger(__name__)
UpperCamelCase = {
"facebook/convnextv2-tiny-1k-224": "http... | 45 |
"""simple docstring"""
import re
def __snake_case ( __A ) -> str:
if len(re.findall("""[ATCG]""" ,__A ) ) != len(__A ):
raise ValueError("""Invalid Strand""" )
return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) )
if _... | 607 | 0 |
"""simple docstring"""
import json
import os
from collections import Counter
import torch
import torchvision
import torchvision.transforms as transforms
from PIL import Image
from torch import nn
from torch.utils.data import Dataset
_lowerCAmelCase : str = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4... | 46 |
"""simple docstring"""
import os
import random
import sys
from . import cryptomath_module as cryptoMath # noqa: N812
from . import rabin_miller as rabinMiller # noqa: N812
def __snake_case ( ) -> None:
print("""Making key files...""" )
make_key_files("""rsa""" ... | 607 | 0 |
from __future__ import annotations
import typing
from collections import Counter
def UpperCAmelCase__ ( lowerCamelCase_ : int ):
__a : typing.Counter[int] = Counter()
for base in range(1 , max_perimeter + 1 ):
for perpendicular in r... | 47 |
"""simple docstring"""
from ... import PretrainedConfig
lowerCAmelCase: str ={
"sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json",
}
class lowerCamelCase__ ( __UpperCamelCase ):
__UpperCAmelCase = NEZHA_PRETRAIN... | 607 | 0 |
'''simple docstring'''
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_atte... | 48 |
"""simple docstring"""
import tensorflow as tf
from ...tf_utils import shape_list
class lowerCamelCase__ ( tf.keras.layers.Layer ):
def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=False , **snake_case ) -> ... | 607 | 0 |
"""simple docstring"""
from collections import OrderedDict
from typing import Mapping
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
_lowercase : Dict = logging.get_logger(__name__)
_lowercase : List[Any] ... | 49 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( __A ,__A = "cpu" ,__A = None ) -> None:
lowercase : Optional[int] = torch.load(__A ,map_location=__A )
for k, v in tqdm(state_... | 607 | 0 |
'''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 .... | 50 |
"""simple docstring"""
import argparse
import json
import os
from collections import OrderedDict
import numpy as np
import tensorflow as tf
import torch
def __snake_case ( __A ) -> Any:
lowercase : List[str] = os.path.join(args.tf_model_dir ,"""para... | 607 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
a__ : Union[str, Any] = logging.get_logger(__name__)
a__ : Optional[int] = {
# See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}
... | 51 |
"""simple docstring"""
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_... | 607 | 0 |
"""simple docstring"""
import argparse
import re
import torch
from CLAP import create_model
from transformers import AutoFeatureExtractor, ClapConfig, ClapModel
A = {
'''text_branch''': '''text_model''',
'''audio_branch''': '''audio_model.audio_encoder''',
''... | 52 |
"""simple docstring"""
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def __snake_case ( __A ) -> Any:
def wrapper(*__A ,**__A ):
lowercase : Tuple ... | 607 | 0 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_flax_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
is_vision_available,
)
_snake_case : int = {
'configuration_clip': [
... | 53 |
"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
convert,
ensure_valid_input,
ge... | 607 | 0 |
from collections import OrderedDict
from typing import Mapping
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
__lowercase : str =logging.get_logger(__name__)
__lowercase : List[str] ={
"""facebook/xmod-base""": "... | 54 |
"""simple docstring"""
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
... | 607 | 0 |
import os
import unittest
from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer
from ...test_tokenization_common import TokenizerTesterMixin
class UpperCAmelCase ( __SCREAMING_SNAKE_CASE , unittest.TestCase ):
'''simple docstring'''
... | 55 |
"""simple docstring"""
import argparse
import torch
from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging
logging.set_verbosity_info()
lowerCAmelCase: Tuple =logging.get_logger(__name__)
lowerCAmelCase: int ... | 607 | 0 |
'''simple docstring'''
import sys
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path
from huggingface_hub import HfFolder, delete_repo
from requests.exceptions import HTTPError
from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor
from transformers.testing_u... | 56 |
"""simple docstring"""
import importlib.metadata
from typing import Union
from packaging.version import Version, parse
from .constants import STR_OPERATION_TO_FUNC
lowerCAmelCase: List[str] =parse(importlib.metadata.version("torch"))
def __snake_case ( __A ,__A ... | 607 | 0 |
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.testing_utils import require_vision
from t... | 57 |
"""simple docstring"""
def __snake_case ( ) -> Union[str, Any]:
lowercase : str = 0
for i in range(1 ,1001 ):
total += i**i
return str(__A )[-10:]
if __name__ == "__main__":
print(solution())
| 607 | 0 |
"""simple docstring"""
def __lowerCAmelCase ( __UpperCamelCase : str , __UpperCamelCase : bool = False ):
'''simple docstring'''
if not isinstance(__UpperCamelCase , __UpperCamelCase ):
snake_case_ : Optional... | 58 |
"""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 tra... | 607 | 0 |
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
from transformers import CLIPModel, CLIPTokenizerFast
fr... | 59 |
"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import TensorType, logging
if TYPE_CHECKING:
from ...onnx.config i... | 607 | 0 |
from typing import List, Union
import numpy as np
from ..tokenization_utils import TruncationStrategy
from ..utils import add_end_docstrings, logging
from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline
lowerCAmelCase_ = logging.get_logger(__name__)
class __lowerCAmelCase ... | 60 |
"""simple docstring"""
from random import shuffle
import tensorflow as tf
from numpy import array
def __snake_case ( __A ,__A ) -> Any:
lowercase : Any = int(__A )
assert noofclusters < len(__A )
# Find out the dimensionality
lower... | 607 | 0 |
import operator as op
UpperCamelCase = 'scaler.pt'
UpperCamelCase = 'pytorch_model'
UpperCamelCase = 'random_states'
UpperCamelCase = 'optimizer'
UpperCamelCase = 'scheduler'
UpperCamelCase = 'pytorch_model.bin'
UpperCamelCase = 'pytorch_model.bin.in... | 61 |
"""simple docstring"""
import qiskit
def __snake_case ( __A ,__A ) -> qiskit.result.counts.Counts:
lowercase : List[Any] = qiskit.Aer.get_backend("""aer_simulator""" )
lowercase : int = qiskit.QuantumCircuit(4 ,2 )
# encod... | 607 | 0 |
from typing import Dict, Optional
import numpy as np
import datasets
snake_case = """
IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union
between the predicted segmentation and the ground truth. For binary (two classes) or multi-class segm... | 62 |
"""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 transforme... | 607 | 0 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
a : Dict = {
"configuration_mvp": ["MVP_PRETRAINED_CONFIG_ARCHIVE_MAP", "MvpConfig", "MvpOnnxConfig"],
"tokenization_mvp": ["MvpT... | 63 |
"""simple docstring"""
import argparse
import json
from typing import List
from ltp import LTP
from transformers.models.bert.tokenization_bert import BertTokenizer
def __snake_case ( __A ) -> Union[str, Any]:
# This defines a "chinese character" as anything in the C... | 607 | 0 |
lowercase_ : List[str] = {
'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': 'hugg... | 64 |
"""simple docstring"""
import gc
import unittest
from transformers import CTRLConfig, 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 .... | 607 | 0 |
"""simple docstring"""
from unittest import TestCase
from datasets import Dataset
from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters
def lowerCAmelCase ( ):
'''simple docstring'''
UpperCAmelCase__ : Any = {
"""repo_name""": [... | 65 |
"""simple docstring"""
import math
import qiskit
def __snake_case ( __A = 1 ,__A = 1 ,__A = 1 ) -> qiskit.result.counts.Counts:
if (
isinstance(__A ,__A )
or isinstance(__A ,__A )
or isinstance(__A ,__A )
):
raise ... | 607 | 0 |
import unittest
from transformers import AutoTokenizer, FalconConfig, 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 ... | 66 |
"""simple docstring"""
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
lowerCAmelCase: str ={
"configuration_convbert": ["CONVBERT_PRETRAINE... | 607 | 0 |
import re
def SCREAMING_SNAKE_CASE__ ( snake_case__ :str ) -> str:
if len(re.findall('[ATCG]' , snake_case__ ) ) != len(snake_case__ ):
raise ValueError('Invalid Strand' )
return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) )
if __name__ == "__ma... | 67 |
"""simple docstring"""
import re
def __snake_case ( __A ) -> str:
if len(re.findall("""[ATCG]""" ,__A ) ) != len(__A ):
raise ValueError("""Invalid Strand""" )
return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) )
if _... | 607 | 0 |
from __future__ import annotations
import pandas as pd
def lowercase__ ( A_: list[int] , A_: list[int] , A_: int ) -> list[int]:
"""simple docstring"""
__UpperCAmelCase =[0] * no_of_processes
__UpperCAmelCase =[0] ... | 68 |
"""simple docstring"""
import os
import random
import sys
from . import cryptomath_module as cryptoMath # noqa: N812
from . import rabin_miller as rabinMiller # noqa: N812
def __snake_case ( ) -> None:
print("""Making key files...""" )
make_key_files("""rsa""" ... | 607 | 0 |
'''simple docstring'''
def __UpperCAmelCase ( _UpperCAmelCase : int = 60_08_51_47_51_43 ) -> int:
try:
__snake_case = int(_UpperCAmelCase )
except (TypeError, ValueError):
raise TypeError("Parameter n must be int or castable to int." )
if n <= 0:... | 69 |
"""simple docstring"""
from ... import PretrainedConfig
lowerCAmelCase: str ={
"sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json",
}
class lowerCamelCase__ ( __UpperCamelCase ):
__UpperCAmelCase = NEZHA_PRETRAIN... | 607 | 0 |
import gc
import unittest
import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
from diffusers import (
AutoencoderKL,
DDIMScheduler,
PNDMScheduler,
StableDiffusionLDMaDPipeline,
UNetaDConditionModel,
)
from diffusers.utils im... | 70 |
"""simple docstring"""
import tensorflow as tf
from ...tf_utils import shape_list
class lowerCamelCase__ ( tf.keras.layers.Layer ):
def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=False , **snake_case ) -> ... | 607 | 0 |
'''simple docstring'''
from ..utils import DummyObject, requires_backends
class _snake_case (metaclass=__SCREAMING_SNAKE_CASE):
__A : str =["keras_nlp"]
def __init__( self ,*_snake_case ,**_snake_case ):
requires_backends(self ,["keras_nlp"] )
| 71 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( __A ,__A = "cpu" ,__A = None ) -> None:
lowercase : Optional[int] = torch.load(__A ,map_location=__A )
for k, v in tqdm(state_... | 607 | 0 |
'''simple docstring'''
from ....utils import logging
_UpperCAmelCase : List[str] = logging.get_logger(__name__)
class __magic_name__ ( __SCREAMING_SNAKE_CASE ):
def __init__( self , snake_case_ , snake_case_=None , snake_case_=20_48 ):
lowercase =config.__dict__
l... | 72 |
"""simple docstring"""
import argparse
import json
import os
from collections import OrderedDict
import numpy as np
import tensorflow as tf
import torch
def __snake_case ( __A ) -> Any:
lowercase : List[str] = os.path.join(args.tf_model_dir ,"""para... | 607 | 0 |
# Author: OMKAR PATHAK, Nwachukwu Chidiebere
# Use a Python dictionary to construct the graph.
from __future__ import annotations
from pprint import pformat
from typing import Generic, TypeVar
a_ : Tuple = TypeVar('T')
class _snake_case ( Generic[T] ):
def __init__( se... | 73 |
"""simple docstring"""
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_... | 607 | 0 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
)
lowercase_ = {
"""configuration_falcon""": ["""FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FalconConfig"""],
}
try:
if not is_torch_available():
raise OptionalDe... | 74 |
"""simple docstring"""
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def __snake_case ( __A ) -> Any:
def wrapper(*__A ,**__A ):
lowercase : Tuple ... | 607 | 0 |
'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging
UpperCamelCase__ = logging.get_logger(__name__)
UpperCamelCase__ = {
'''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''',
}
... | 75 |
"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
convert,
ensure_valid_input,
ge... | 607 | 0 |
"""simple docstring"""
from functools import lru_cache
def __UpperCAmelCase ( __UpperCamelCase ):
__lowercase : str = 2
__lowercase : int = set()
while i * i <= n:
if n % i:
i += 1
else:
n //= i
... | 76 |
"""simple docstring"""
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
... | 607 | 0 |
"""simple docstring"""
def _UpperCamelCase ( UpperCamelCase ) -> int:
"""simple docstring"""
__UpperCAmelCase : list[list[int]] = [[0 for _ in range(UpperCamelCase )] for _ in range(m + 1 )]
for i in range(m + 1 ):
__UpperCAmelCase... | 77 |
"""simple docstring"""
import argparse
import torch
from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging
logging.set_verbosity_info()
lowerCAmelCase: Tuple =logging.get_logger(__name__)
lowerCAmelCase: int ... | 607 | 0 |
'''simple docstring'''
from math import sqrt
def lowerCAmelCase_ ( snake_case_ : int ) -> bool:
'''simple docstring'''
assert isinstance(snake_case_ , snake_case_ ) and (
number >= 0
), "'number' must been an int and positive"
Upper... | 78 |
"""simple docstring"""
import importlib.metadata
from typing import Union
from packaging.version import Version, parse
from .constants import STR_OPERATION_TO_FUNC
lowerCAmelCase: List[str] =parse(importlib.metadata.version("torch"))
def __snake_case ( __A ,__A ... | 607 | 0 |
from dataclasses import dataclass
from typing import List, Optional, Union
import numpy as np
import PIL
from PIL import Image
from ...utils import (
BaseOutput,
OptionalDependencyNotAvailable,
is_flax_available,
is_k_diffusion_available,
is_k_diffusion_version,
is_o... | 79 |
"""simple docstring"""
def __snake_case ( ) -> Union[str, Any]:
lowercase : str = 0
for i in range(1 ,1001 ):
total += i**i
return str(__A )[-10:]
if __name__ == "__main__":
print(solution())
| 607 | 0 |
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | 80 |
"""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 tra... | 607 | 0 |
from math import pi, sqrt
def lowerCAmelCase_ ( __lowerCamelCase ):
if num <= 0:
raise ValueError("math domain error" )
if num > 1_7_1.5:
raise OverflowError("math range error" )
elif num - int(__lowerCamelCase ) not in (0, 0.5):
... | 81 |
"""simple docstring"""
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import TensorType, logging
if TYPE_CHECKING:
from ...onnx.config i... | 607 | 0 |
"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging
lowerCamelCase = logging.get_logger(__name__)
lowerCamelCase = {
"""s-JoL/Open-Llama-V1""": """https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json""",
}
class... | 82 |
"""simple docstring"""
from random import shuffle
import tensorflow as tf
from numpy import array
def __snake_case ( __A ,__A ) -> Any:
lowercase : Any = int(__A )
assert noofclusters < len(__A )
# Find out the dimensionality
lower... | 607 | 0 |
"""simple docstring"""
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 transformer... | 83 |
"""simple docstring"""
import qiskit
def __snake_case ( __A ,__A ) -> qiskit.result.counts.Counts:
lowercase : List[Any] = qiskit.Aer.get_backend("""aer_simulator""" )
lowercase : int = qiskit.QuantumCircuit(4 ,2 )
# encod... | 607 | 0 |
import unittest
import numpy as np
import torch
from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device
from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENER... | 84 |
"""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 transforme... | 607 | 0 |
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on
import numpy # noqa: F401 # Here to have a nice missing dependency error message early on
import requests # noqa: F401 # Here to have a nice missing dependency error message early on
import sklearn # noqa: F401 # Here to have ... | 85 |
"""simple docstring"""
import argparse
import json
from typing import List
from ltp import LTP
from transformers.models.bert.tokenization_bert import BertTokenizer
def __snake_case ( __A ) -> Union[str, Any]:
# This defines a "chinese character" as anything in the C... | 607 | 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 _a ( snake_case_ , unittest.TestCase ):
"""simple docstring"""
_lowerCamelCase ... | 86 |
"""simple docstring"""
import gc
import unittest
from transformers import CTRLConfig, 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 .... | 607 | 0 |
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> str:
"""simple docstring"""
return "".join(chr(ord(lowercase_ ) - 32 ) if '''a''' <= char <= '''z''' else char for char in word )
if __name__ == "__main__":
from doctest import testmod
testmod()
| 87 |
"""simple docstring"""
import math
import qiskit
def __snake_case ( __A = 1 ,__A = 1 ,__A = 1 ) -> qiskit.result.counts.Counts:
if (
isinstance(__A ,__A )
or isinstance(__A ,__A )
or isinstance(__A ,__A )
):
raise ... | 607 | 0 |
"""simple docstring"""
import functools
def _snake_case ( __snake_case : str , __snake_case : str ):
"""simple docstring"""
_lowerCamelCase : int = len(__snake_case )
_lowerCamelCase : List[Any] = len(__snake_case )
... | 88 |
"""simple docstring"""
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
lowerCAmelCase: str ={
"configuration_convbert": ["CONVBERT_PRETRAINE... | 607 | 0 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
)
SCREAMING_SNAKE_CASE : str = {
"configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"],
}
try:
if not is_torch_available()... | 89 |
"""simple docstring"""
import re
def __snake_case ( __A ) -> str:
if len(re.findall("""[ATCG]""" ,__A ) ) != len(__A ):
raise ValueError("""Invalid Strand""" )
return dna.translate(dna.maketrans("""ATCG""" ,"""TAGC""" ) )
if _... | 607 | 0 |
'''simple docstring'''
from __future__ import annotations
import math
def _snake_case ( A , A ) -> float:
lowerCAmelCase__ = u
for i in range(1 , A ):
lowerCAmelCase__ = temp * (u - i)
return temp
... | 90 |
"""simple docstring"""
import os
import random
import sys
from . import cryptomath_module as cryptoMath # noqa: N812
from . import rabin_miller as rabinMiller # noqa: N812
def __snake_case ( ) -> None:
print("""Making key files...""" )
make_key_files("""rsa""" ... | 607 | 0 |
"""simple docstring"""
import os
import torch
from ..logging import get_logger
from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME
from .versions import is_torch_version
if is_torch_version('''>=''', FSDP_PYTORCH_VERSION):
import torch.distributed.checkpoint as dist_cp
from torch.distribu... | 91 |
"""simple docstring"""
from ... import PretrainedConfig
lowerCAmelCase: str ={
"sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json",
}
class lowerCamelCase__ ( __UpperCamelCase ):
__UpperCAmelCase = NEZHA_PRETRAIN... | 607 | 0 |
'''simple docstring'''
from __future__ import annotations
from statistics import mean
def _lowerCAmelCase ( __magic_name__ : list[int] , __magic_name__ : list[int] , __magic_name__ : int ) -> list[int]:
lowercase : List[str] =[0] * no_of_pro... | 92 |
"""simple docstring"""
import tensorflow as tf
from ...tf_utils import shape_list
class lowerCamelCase__ ( tf.keras.layers.Layer ):
def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=False , **snake_case ) -> ... | 607 | 0 |
"""simple docstring"""
import multiprocessing
import time
from arguments import PretokenizationArguments
from datasets import load_dataset
from transformers import AutoTokenizer, HfArgumentParser
def __A (_SCREAMING_SNAKE_CASE ) ->List[Any]:
"""simple docstring"""
lowerCAmelCase__ ... | 93 |
"""simple docstring"""
from typing import Union
import fire
import torch
from tqdm import tqdm
def __snake_case ( __A ,__A = "cpu" ,__A = None ) -> None:
lowercase : Optional[int] = torch.load(__A ,map_location=__A )
for k, v in tqdm(state_... | 607 | 0 |
'''simple docstring'''
from dataclasses import dataclass, field
from typing import ClassVar, Dict
from ..features import Features, Value
from .base import TaskTemplate
@dataclass(frozen=__A )
class UpperCAmelCase_ ( __A ):
"""simple docstring"""
UpperCamelCase_ ... | 94 |
"""simple docstring"""
import argparse
import json
import os
from collections import OrderedDict
import numpy as np
import tensorflow as tf
import torch
def __snake_case ( __A ) -> Any:
lowercase : List[str] = os.path.join(args.tf_model_dir ,"""para... | 607 | 0 |
"""simple docstring"""
from operator import delitem, getitem, setitem
import pytest
from data_structures.hashing.hash_map import HashMap
def snake_case ( A__ ):
return getitem, k
def snake_case ( A__ ,A__ ):
return setitem, k, v
def snake_case ( A__ ):
return delitem... | 95 |
"""simple docstring"""
import unittest
import numpy as np
from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
if is_... | 607 | 0 |
"""simple docstring"""
from __future__ import annotations
__lowerCamelCase = 10
def a ( __UpperCAmelCase : list[int] ) -> list[int]:
__magic_name__: Optional[Any] = 1
__magic_name__: str = max(__UpperCAmelCase )
... | 96 |
"""simple docstring"""
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def __snake_case ( __A ) -> Any:
def wrapper(*__A ,**__A ):
lowercase : Tuple ... | 607 | 0 |
import inspect
import unittest
from transformers import DecisionTransformerConfig, 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_modelin... | 97 |
"""simple docstring"""
import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
convert,
ensure_valid_input,
ge... | 607 | 0 |
'''simple docstring'''
# 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
# ful... | 98 |
"""simple docstring"""
import uuid
from typing import Any, Dict, List, Optional, Union
from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_tf_available():
import tensorflow as tf
if is_torch_available():
... | 607 | 0 |
# 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... | 99 |
"""simple docstring"""
import argparse
import torch
from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration
from transformers.utils import logging
logging.set_verbosity_info()
lowerCAmelCase: Tuple =logging.get_logger(__name__)
lowerCAmelCase: int ... | 607 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.