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 timm import create_model
from timm.data import resolve_data_config
from timm.data.transforms_factory import create_transform
from transformers import BitConfi... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : List[Any] ) -> Any:
"""simple docstring"""
stooge(__lowercase , 0 , len(__lowercase ) - 1 )
return arr
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Dict... | 637 | 1 |
from __future__ import annotations
from typing import Any
class __lowercase ( lowercase_ ):
'''simple docstring'''
pass
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : Any ):
... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
"""simple docstring"""
__A = """"""
for ch in key:
if ch == " " or ch not in key_no_dups and ch.isalpha():
key_no_dups += ch
return key_no_dups
def _SCREAMING_SNAKE_CASE ... | 637 | 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
__a : Any = logging.get_logger(__name__)
__a : Union[str, Any] = {
"faceb... | 637 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 | 1 |
import os
def _SCREAMING_SNAKE_CASE ( ) -> Union[str, Any]:
"""simple docstring"""
with open(os.path.dirname(__lowercase ) + """/grid.txt""" ) as f:
__A = [] # noqa: E741
for _ in range(2_0 ):
l.append([int(__lowercase ) for... | 637 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 | 1 |
from __future__ import annotations
__a : Optional[int] = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
__a : int = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]
def _SCREAMING_SNAKE_CASE ( __lowercase : list[float] ) -> list[float]... | 637 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] ) -> float:
"""simple docstring"""
if not nums: # Makes sure that the list is not empty
raise ValueError("""List is empty""" )
__A = sum(__lowercase ) / len(__lowercase ) # Calculate t... | 637 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_sentencepiece_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_... | 637 | 1 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available
__a : Optional[Any] = {"tokenization_herbert": ["HerbertTokenizer"]}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDepen... | 637 |
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import P... | 637 | 1 |
from torch import nn
class __lowercase ( nn.Module ):
'''simple docstring'''
def __init__( self : str , UpperCamelCase_ : Tuple , UpperCamelCase_ : Tuple ):
"""simple docstring"""
super().__init__()
... | 637 |
import unittest
from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tens... | 637 | 1 |
from __future__ import annotations
from collections.abc import Iterator
from typing import Generic, TypeVar
__a : List[Any] = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : List[Any] , UpperCamelCase... | 637 |
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_FILENAME, RealmR... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> int:
"""simple docstring"""
if not isinstance(__lowercase , __lowercase ):
raise ValueError("""Input must be an integer""" )
if input_num <= 0:
raise ValueError("""Input must be positive... | 637 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 | 1 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 | 1 |
import gc
import unittest
import numpy as np
import torch
from torch.backends.cuda import sdp_kernel
from diffusers import (
CMStochasticIterativeScheduler,
ConsistencyModelPipeline,
UNetaDModel,
)
from diffusers.utils import randn_tensor, slow, torch_device
from diffusers.utils.testing_utils impor... | 637 |
from __future__ import annotations
from PIL import Image
# Define glider example
__a : Tuple = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0... | 637 | 1 |
import unittest
import numpy as np
import torch
from torch import nn
from transformers import (
CLIPImageProcessor,
CLIPTextConfig,
CLIPTextModelWithProjection,
CLIPTokenizer,
CLIPVisionConfig,
CLIPVisionModelWithProjection,
)
from diffusers import KandinskyVaaPriorPipeline, PriorTransf... | 637 |
import json
from typing import 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 .tokenization_roberta import RobertaTokenizer
... | 637 | 1 |
import argparse
import torch
from transformers import (
EncodecConfig,
EncodecFeatureExtractor,
EncodecModel,
logging,
)
# checkpoints downloaded from:
# https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th
# https://huggingface.co/facebook/musicgen-small/resolve/main/compressi... | 637 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
__a : Any = {
"configuration_time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
}
try:... | 637 | 1 |
import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict
from ..features import Audio, Features, Value
from .base import TaskTemplate
@dataclass(frozen=lowercase_ )
class __lowercase ( lowercase_ ):
'''simple docstring'''
SCREAMING_SNAKE_CASE = ... | 637 |
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, XLMRobertaXLForSequence... | 637 | 1 |
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_device
from transformers.... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Dict = logging.get_logger(__name__)
__a : Dict = {
"bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json",
}
class __lowercase ... | 637 | 1 |
import inspect
import unittest
from transformers import DPTConfig
from transformers.file_utils import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from ...test_configuration_commo... | 637 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> bool:
"""simple docstring"""
if len(__lowercase ) == 0:
return False
__A = len(__lowercase ) // 2
if a_list[mi... | 637 | 1 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> bool:
"""simple docstring"""
if len(__lowercase ) == 0:
return False
__A = len(__lowercase ) // 2
if a_list[mi... | 637 |
# 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 required ... | 637 | 1 |
from typing import List, Optional, Union
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
class __lowercase ( lowercase_ ):
'''simple docs... | 637 |
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
__a : List[str] = "▁"
__a : int = {"vocab_file": "spiece.model"}
__a : A... | 637 | 1 |
import argparse
import torch
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt
if __name__ == "__main__":
__a : Dict = argparse.ArgumentParser()
parser.add_argument(
"--checkpoint_path", default=None, type=str, required=Tru... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Optional[Any] = logging.get_logger(__name__)
__a : Dict = {
"google/realm-cc-news-pretrained-embedder": (
"https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c... | 637 | 1 |
import json
import os
import subprocess
import unittest
from ast import literal_eval
import pytest
from parameterized import parameterized, parameterized_class
from . import is_sagemaker_available
if is_sagemaker_available():
from sagemaker import Session, TrainingJobAnalytics
from sagemaker.huggingface ... | 637 |
import argparse
import os
import re
import packaging.version
__a : Tuple = "examples/"
__a : Any = {
"examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
"init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"... | 637 | 1 |
__a : Dict = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n"
__a : Optional[Any] ... | 637 |
from ....configuration_utils import PretrainedConfig
from ....utils import logging
__a : List[Any] = logging.get_logger(__name__)
# TODO: upload to AWS
__a : Union[str, Any] = {
"yjernite/retribert-base-uncased": (
"https://huggingface.co/yjernite/retribert-base-uncased/r... | 637 | 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_FILENAME, RealmR... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : List[Any] ) -> Any:
"""simple docstring"""
stooge(__lowercase , 0 , len(__lowercase ) - 1 )
return arr
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Dict... | 637 | 1 |
import os
import unittest
from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast
from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers
from ...test_tokenization_common import TokenizerTesterMixin
@require_tokenize... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
"""simple docstring"""
__A = """"""
for ch in key:
if ch == " " or ch not in key_no_dups and ch.isalpha():
key_no_dups += ch
return key_no_dups
def _SCREAMING_SNAKE_CASE ... | 637 | 1 |
import os
import tempfile
import unittest
from transformers import is_torch_available
from transformers.testing_utils import require_torch
if is_torch_available():
import torch
from torch import nn
from transformers import (
Adafactor,
AdamW,
get_constant_schedule,
get_constant_... | 637 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 | 1 |
import argparse
import math
import os
import torch
from neural_compressor.utils.pytorch import load
from PIL import Image
from transformers import CLIPTextModel, CLIPTokenizer
from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel
def _SCREAMING_SNAKE_CASE ( ) -> ... | 637 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 | 1 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_flax_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : int = {
"configuration_blenderbot": [
"BLENDERBOT_PRETRAINED_CONFIG_ARC... | 637 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 | 1 |
import os
import unittest
from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer
from ...test_tokenization_common import TokenizerTesterMixin
class __lowercase ( lowercase_ , unittest.TestCase ):
'''simple docstring'''
SCREAMING_SNAK... | 637 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_sentencepiece_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_... | 637 | 1 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 |
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import P... | 637 | 1 |
import re
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> list:
"""simple docstring"""
return [char.split() for char in re.split(R"""[^ a-z A-Z 0-9 \s]""" , str_ )]
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
... | 637 |
import unittest
from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tens... | 637 | 1 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 |
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_FILENAME, RealmR... | 637 | 1 |
from collections import OrderedDict
from typing import Mapping
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
__a : Tuple = logging.get_logger(__name__)
__a : int = {
"facebook/data2vec-text-base": "https://hugging... | 637 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : str ) -> str:
"""simple docstring"""
__A = len(__lowercase )
__A = len(__lowercase )
__A = (
first_str_length if first_str_length > second_st... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 | 1 |
from __future__ import annotations
class __lowercase :
'''simple docstring'''
def __init__( self : int , UpperCamelCase_ : str , UpperCamelCase_ : str ):
"""simple docstring"""
__A , __A = ... | 637 |
from __future__ import annotations
from PIL import Image
# Define glider example
__a : Tuple = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0... | 637 | 1 |
from string import ascii_uppercase
__a : Dict = {str(ord(c) - 55): c for c in ascii_uppercase}
def _SCREAMING_SNAKE_CASE ( __lowercase : int , __lowercase : int ) -> str:
"""simple docstring"""
if isinstance(__lowercase , __lowercase ... | 637 |
import json
from typing import 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 .tokenization_roberta import RobertaTokenizer
... | 637 | 1 |
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
f... | 637 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
__a : Any = {
"configuration_time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
}
try:... | 637 | 1 |
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 t... | 637 |
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, XLMRobertaXLForSequence... | 637 | 1 |
import math
import sys
import cva
import numpy as np
def _SCREAMING_SNAKE_CASE ( __lowercase : np.ndarray , __lowercase : float ) -> np.ndarray:
"""simple docstring"""
__A = math.sqrt(__lowercase )
__A = 1 / (sigma * math.sqrt... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Dict = logging.get_logger(__name__)
__a : Dict = {
"bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json",
}
class __lowercase ... | 637 | 1 |
from __future__ import annotations
import unittest
from transformers import LEDConfig, is_tf_available
from transformers.testing_utils import require_tf, slow
from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin... | 637 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> bool:
"""simple docstring"""
if len(__lowercase ) == 0:
return False
__A = len(__lowercase ) // 2
if a_list[mi... | 637 | 1 |
import os
from shutil import copyfile
from typing import List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
__a : str = logging.get_logger(__name__)
__a : Optional[Any] = {"vocab_file": "sentencepiece... | 637 |
# 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 required ... | 637 | 1 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 |
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
__a : List[str] = "▁"
__a : int = {"vocab_file": "spiece.model"}
__a : A... | 637 | 1 |
from ...processing_utils import ProcessorMixin
class __lowercase ( lowercase_ ):
'''simple docstring'''
SCREAMING_SNAKE_CASE = ["image_processor", "feature_extractor"]
SCREAMING_SNAKE_CASE = "TvltImageProcessor"
SCREAMING_SNAKE_CASE = "TvltFeatureExt... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Optional[Any] = logging.get_logger(__name__)
__a : Dict = {
"google/realm-cc-news-pretrained-embedder": (
"https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : Union[str, Any] , __lowercase : List[Any] ) -> Union[str, Any]:
"""simple docstring"""
__A = [1]
for i in range(2 , __lowercase ):
factorials.append(factorials[-1] * i )
asse... | 637 |
import argparse
import os
import re
import packaging.version
__a : Tuple = "examples/"
__a : Any = {
"examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
"init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"... | 637 | 1 |
import os
from shutil import copyfile
from typing import List, Optional, Tuple
from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging
if is_sentencepiece_available():
from .tokenization_big_bird imp... | 637 |
from ....configuration_utils import PretrainedConfig
from ....utils import logging
__a : List[Any] = logging.get_logger(__name__)
# TODO: upload to AWS
__a : Union[str, Any] = {
"yjernite/retribert-base-uncased": (
"https://huggingface.co/yjernite/retribert-base-uncased/r... | 637 | 1 |
import requests
from bsa import BeautifulSoup
def _SCREAMING_SNAKE_CASE ( __lowercase : str = "https://www.worldometers.info/coronavirus" ) -> dict:
"""simple docstring"""
__A = BeautifulSoup(requests.get(__lowercase ).text , """html.parser""" ... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : List[Any] ) -> Any:
"""simple docstring"""
stooge(__lowercase , 0 , len(__lowercase ) - 1 )
return arr
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Dict... | 637 | 1 |
import random
def _SCREAMING_SNAKE_CASE ( __lowercase : int , __lowercase : float , __lowercase : bool = False ) -> dict:
"""simple docstring"""
__A = {i: [] for i in range(__lowercase )}
# if probability is greater or equa... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
"""simple docstring"""
__A = """"""
for ch in key:
if ch == " " or ch not in key_no_dups and ch.isalpha():
key_no_dups += ch
return key_no_dups
def _SCREAMING_SNAKE_CASE ... | 637 | 1 |
from bisect import bisect
from itertools import accumulate
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Any , __lowercase : Tuple , __lowercase : Dict ) -> Any:
"""simple docstring"""
__A = sorted(zip(... | 637 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 | 1 |
import json
import logging
import os
import socket
import git
import numpy as np
import torch
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s",
datefmt="%m/%d/%Y %H:%M:%S",
level=logging.INFO,
)
__a : List[str] = logging.getLogger(... | 637 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 | 1 |
import math
import unittest
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> bool:
"""simple docstring"""
assert isinstance(__lowercase , __lowercase ) and (
number >= 0
), "'number' must been an int and positive"
if 1 < number < 4:
... | 637 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 | 1 |
# using dfs for finding eulerian path traversal
def _SCREAMING_SNAKE_CASE ( __lowercase : Optional[Any] , __lowercase : Tuple , __lowercase : Optional[int] , __lowercase : Dict=None ) -> Union[str, Any]:
"""simple docstring"""
__... | 637 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_sentencepiece_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_... | 637 | 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_DATA... | 637 |
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import P... | 637 | 1 |
from queue import Queue
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from ..models.auto import AutoTokenizer
class __lowercase :
'''simple docstring'''
def lowerCAmelCase_ ( self : List[Any] , UpperCamelCase_ : Optional[Any] ... | 637 |
import unittest
from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tens... | 637 | 1 |
from __future__ import annotations
import copy
import tempfile
import unittest
from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available
from transformers.testing_utils import (
DUMMY_UNKNOWN_IDENTIFIER,
SMALL_MODEL_IDENTIFIER,
RequestCounte... | 637 |
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_FILENAME, RealmR... | 637 | 1 |
import os
from pathlib import Path
import numpy as np
import pytest
from pack_dataset import pack_data_dir
from parameterized import parameterized
from save_len_file import save_len_file
from torch.utils.data import DataLoader
from transformers import AutoTokenizer
from transformers.models.mbart.modeling_mbart... | 637 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 | 1 |
import argparse
import os
import re
import packaging.version
__a : Tuple = "examples/"
__a : Any = {
"examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
"init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 | 1 |
import json
from typing import 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 .tokenization_roberta import RobertaTokenizer
... | 637 |
from __future__ import annotations
from PIL import Image
# Define glider example
__a : Tuple = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 |
import json
from typing import 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 .tokenization_roberta import RobertaTokenizer
... | 637 | 1 |
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required ... | 637 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
__a : Any = {
"configuration_time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
}
try:... | 637 | 1 |
import unittest
from transformers import CamembertTokenizer, CamembertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.utils import is_torch_available
from ...test_tokenization_common import TokenizerTesterMixin
__a : ... | 637 |
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, XLMRobertaXLForSequence... | 637 | 1 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
__a : Any = {
"configuration_time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
}
try:... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Dict = logging.get_logger(__name__)
__a : Dict = {
"bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json",
}
class __lowercase ... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : list ) -> int:
"""simple docstring"""
if not grid or not grid[0]:
raise TypeError("""The grid does not contain the appropriate information""" )
for cell_n in range(1 , len(grid[0] ) ):
grid[... | 637 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> bool:
"""simple docstring"""
if len(__lowercase ) == 0:
return False
__A = len(__lowercase ) // 2
if a_list[mi... | 637 | 1 |
from ..utils import DummyObject, requires_backends
class __lowercase ( metaclass=lowercase_ ):
'''simple docstring'''
SCREAMING_SNAKE_CASE = ["sentencepiece"]
def __init__( self : Tuple , *UpperCamelCase_ : Tuple , **UpperCamel... | 637 |
# 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 required ... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> int:
"""simple docstring"""
if not isinstance(__lowercase , __lowercase ) or number < 0:
raise ValueError("""Input must be a non-negative integer""" )
__A = 0
while number:
... | 637 |
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
__a : List[str] = "▁"
__a : int = {"vocab_file": "spiece.model"}
__a : A... | 637 | 1 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : str , UpperCamelCase_ : int ):
"""simple docstring"""
__A = num_of_nodes
__A ... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Optional[Any] = logging.get_logger(__name__)
__a : Dict = {
"google/realm-cc-news-pretrained-embedder": (
"https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c... | 637 | 1 |
import numpy as np
def _SCREAMING_SNAKE_CASE ( __lowercase : np.ndarray ) -> np.ndarray:
"""simple docstring"""
return 1 / (1 + np.exp(-vector ))
def _SCREAMING_SNAKE_CASE ( __lowercase : np.ndarray ) -> np.ndarray:
"""simple docs... | 637 |
import argparse
import os
import re
import packaging.version
__a : Tuple = "examples/"
__a : Any = {
"examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
"init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"... | 637 | 1 |
import logging
import os
import sys
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
from datasets import load_dataset
from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor
import transformers
from tr... | 637 |
from ....configuration_utils import PretrainedConfig
from ....utils import logging
__a : List[Any] = logging.get_logger(__name__)
# TODO: upload to AWS
__a : Union[str, Any] = {
"yjernite/retribert-base-uncased": (
"https://huggingface.co/yjernite/retribert-base-uncased/r... | 637 | 1 |
import os
from shutil import copyfile
from typing import List, Optional, Tuple
from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging
if is_sentencepiece_available():
from .tokenization_rembert impo... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : List[Any] ) -> Any:
"""simple docstring"""
stooge(__lowercase , 0 , len(__lowercase ) - 1 )
return arr
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Dict... | 637 | 1 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
"""simple docstring"""
__A = """"""
for ch in key:
if ch == " " or ch not in key_no_dups and ch.isalpha():
key_no_dups += ch
return key_no_dups
def _SCREAMING_SNAKE_CASE ... | 637 | 1 |
__a : Any = {
"Pillow": "Pillow",
"accelerate": "accelerate>=0.11.0",
"compel": "compel==0.1.8",
"black": "black~=23.1",
"datasets": "datasets",
"filelock": "filelock",
"flax": "flax>=0.4.1",
"hf-doc-builder": "hf-doc-builder>=0.3.0",
"huggingface-hub": "huggingfa... | 637 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 | 1 |
from sklearn.metrics import matthews_corrcoef
import datasets
__a : List[str] = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account t... | 637 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 | 1 |
import pickle
import shutil
import tempfile
import unittest
from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.utils import cached_property
from ...test_t... | 637 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> int:
"""simple docstring"""
if not isinstance(__lowercase , __lowercase ):
raise TypeError("""only integers accepted as input""" )
else:
__A = str(abs(__lowercase ) )
... | 637 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_sentencepiece_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_... | 637 | 1 |
import math
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> bool:
"""simple docstring"""
if 1 < number < 4:
# 2 and 3 are primes
return True
elif number < 2 or number % 2 == 0 or number % 3 == 0:
# Negatives, 0, 1, all even numbers, all mul... | 637 |
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import P... | 637 | 1 |
import argparse
import json
from typing import List
from ltp import LTP
from transformers import BertTokenizer
def _SCREAMING_SNAKE_CASE ( __lowercase : Optional[Any] ) -> Tuple:
"""simple docstring"""
if (
(cp >= 0X4_e_0_0 and cp <= 0X9_f_f_f)
or (cp >... | 637 |
import unittest
from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tens... | 637 | 1 |
from urllib.parse import quote
import pytest
from datasets.utils.hub import hf_hub_url
@pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] )
@pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blanks.csv"""] )... | 637 |
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_FILENAME, RealmR... | 637 | 1 |
import os
# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_doctest_list.py
__a : Any = "."
if __name__ == "__main__":
__a : Optional[int] = os.path.join(REPO_PATH, "utils/documentation_tests.txt")
__a ... | 637 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 | 1 |
__a : str = [
999,
800,
799,
600,
599,
500,
400,
399,
377,
355,
333,
311,
288,
266,
244,
222,
200,
199,
177,
155,
133,
111,
88,
66,
44,
22,
0,
]
__a : List[Any] = [
999,
... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 | 1 |
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/
import gc
import random
import tempfile
import unittest
import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer
from diffusers import (... | 637 |
from __future__ import annotations
from PIL import Image
# Define glider example
__a : Tuple = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0... | 637 | 1 |
from math import acos, sin
from typing import List, Tuple, Union
import numpy as np
import torch
from PIL import Image
from ...models import AutoencoderKL, UNetaDConditionModel
from ...schedulers import DDIMScheduler, DDPMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import AudioPipelineOut... | 637 |
import json
from typing import 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 .tokenization_roberta import RobertaTokenizer
... | 637 | 1 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
__a : Optional[Any] = logging.get_logger(__name__)
__a : Any = {
"facebook/convnextv2-tiny-1k-224":... | 637 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
__a : Any = {
"configuration_time_series_transformer": [
"TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
"TimeSeriesTransformerConfig",
],
}
try:... | 637 | 1 |
import json
from typing import Dict, List, Optional, Tuple, Union
from tokenizers import pre_tokenizers, processors
from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import PaddingStrategy, logging
from .t... | 637 |
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, XLMRobertaXLForSequence... | 637 | 1 |
class __lowercase :
'''simple docstring'''
def __init__( self : List[Any] , UpperCamelCase_ : Union[str, Any] ):
"""simple docstring"""
__A = arr.split(""",""" )
def lowerCAmelCase_ ( self ... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Dict = logging.get_logger(__name__)
__a : Dict = {
"bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json",
}
class __lowercase ... | 637 | 1 |
from typing import Dict, List, Optional, Union
import numpy as np
from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
OPENAI_CLIP_MEAN,
... | 637 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[int] , __lowercase : int ) -> bool:
"""simple docstring"""
if len(__lowercase ) == 0:
return False
__A = len(__lowercase ) // 2
if a_list[mi... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : float , __lowercase : list[float] ) -> float:
"""simple docstring"""
if discount_rate < 0:
raise ValueError("""Discount rate cannot be negative""" )
if not cash_flows:
raise ValueError("""Cash f... | 637 |
# 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 required ... | 637 | 1 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_flax_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Union[str, Any] = {
"configuration_roberta": ["ROBERTA_PRETRAINED_CONFIG_ARCHIV... | 637 |
import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple
import sentencepiece as spm
from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging
__a : List[str] = "▁"
__a : int = {"vocab_file": "spiece.model"}
__a : A... | 637 | 1 |
from __future__ import annotations
class __lowercase :
'''simple docstring'''
def __init__( self : Optional[int] , UpperCamelCase_ : int ):
"""simple docstring"""
__A = data
__A = None
... | 637 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Optional[Any] = logging.get_logger(__name__)
__a : Dict = {
"google/realm-cc-news-pretrained-embedder": (
"https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c... | 637 | 1 |
from ...configuration_utils import PretrainedConfig
from ...utils import logging
__a : Optional[Any] = logging.get_logger(__name__)
__a : Dict = {
"google/realm-cc-news-pretrained-embedder": (
"https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c... | 637 |
import argparse
import os
import re
import packaging.version
__a : Tuple = "examples/"
__a : Any = {
"examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
"init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"... | 637 | 1 |
from __future__ import annotations
def _SCREAMING_SNAKE_CASE ( __lowercase : list[float] , __lowercase : Any ) -> Any:
"""simple docstring"""
print(f"Vertex\tShortest Distance from vertex {src}" )
for i, d in enumerate(__lowercase ):
pri... | 637 |
from ....configuration_utils import PretrainedConfig
from ....utils import logging
__a : List[Any] = logging.get_logger(__name__)
# TODO: upload to AWS
__a : Union[str, Any] = {
"yjernite/retribert-base-uncased": (
"https://huggingface.co/yjernite/retribert-base-uncased/r... | 637 | 1 |
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
__a : str = {
"configuration_maskformer": ["MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "MaskFormerConfig"],
"configuration_maskformer_swin": ["MaskFor... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : List[Any] ) -> Any:
"""simple docstring"""
stooge(__lowercase , 0 , len(__lowercase ) - 1 )
return arr
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : Dict... | 637 | 1 |
import gc
import threading
import time
import psutil
import torch
class __lowercase :
'''simple docstring'''
def __init__( self : Dict ):
"""simple docstring"""
__A = psutil.Process()
__A = False
def ... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str:
"""simple docstring"""
__A = """"""
for ch in key:
if ch == " " or ch not in key_no_dups and ch.isalpha():
key_no_dups += ch
return key_no_dups
def _SCREAMING_SNAKE_CASE ... | 637 | 1 |
import gc
import tempfile
import unittest
import numpy as np
import torch
from diffusers import VersatileDiffusionPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device
__a : int = False
class __lowercase ( unittest.TestCase ):
... | 637 |
from __future__ import annotations
from typing import Any
class __lowercase :
'''simple docstring'''
def __init__( self : Dict , UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : float = 0 ):
... | 637 | 1 |
import shutil
import tempfile
import unittest
from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available
from transformers.testing_utils import (
get_tests_dir,
nested_simplify,
require_sentencepiece,
require_tokenizers,
require_torch,
)
... | 637 |
import warnings
from ...utils import logging
from .image_processing_deit import DeiTImageProcessor
__a : Any = logging.get_logger(__name__)
class __lowercase ( lowercase_ ):
'''simple docstring'''
def __init__( self : Union[str, Any] , *Upper... | 637 | 1 |
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path:
# hack it in for now:
import sys
from pathlib import Path
__a : Union[str, Any] = Path(__file__).resolve().parents[3] / "src"
sys.path.insert(1, str(git_repo_path))
import dataclasses # noqa
import io # ... | 637 |
import argparse
import os
import evaluate
import torch
from datasets import load_dataset
from torch.optim import AdamW
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from accelerate import Accelerator... | 637 | 1 |
from maths.prime_factors import prime_factors
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> int:
"""simple docstring"""
if not isinstance(__lowercase , __lowercase ):
__A = f"Input value of [number={number}] must be an integer"
... | 637 |
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_sentencepiece_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
__a : Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_... | 637 | 1 |
import unittest
import numpy as np
import timeout_decorator # noqa
from transformers import BlenderbotSmallConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from ...generation.test_flax_utils import FlaxGenerationTesterMixin
from ...test_modeling_flax_common import FlaxModel... | 637 |
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import P... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : list[list[float]] ) -> list[list[float]]:
"""simple docstring"""
__A = []
for data in source_data:
for i, el in enumerate(__lowercase ):
if len(__lowercase ) < i + 1:
data_l... | 637 |
import unittest
from transformers import SqueezeBertConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tens... | 637 | 1 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int , __lowercase : int ) -> float:
"""simple docstring"""
return base * power(__lowercase , (exponent - 1) ) if exponent else 1
if __name__ == "__main__":
print("Raise base to the power of exponent us... | 637 |
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_FILENAME, RealmR... | 637 | 1 |
from typing import Union
from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging
from .base import PIPELINE_INIT_ARGS, Pipeline
if is_vision_available():
from PIL import Image
from ..image_utils import load_image
if is_torch_available():
from ..models.auto.modeling_aut... | 637 |
from __future__ import annotations
from typing import Generic, TypeVar
__a : str = TypeVar("T")
class __lowercase ( Generic[T] ):
'''simple docstring'''
def __init__( self : Any , UpperCamelCase_ : T ):
"""simple docs... | 637 | 1 |
import math
import torch
from torch import nn
from ..configuration_utils import ConfigMixin, register_to_config
from .attention_processor import Attention
from .embeddings import get_timestep_embedding
from .modeling_utils import ModelMixin
class __lowercase ( lowercase_ , lowercase_ ):
... | 637 |
def _SCREAMING_SNAKE_CASE ( __lowercase : int ) -> list[int]:
"""simple docstring"""
if length <= 0 or not isinstance(__lowercase , __lowercase ):
raise ValueError("""Length must be a positive integer.""" )
return [n * (2 * n - 1) for n in range... | 637 | 1 |
import functools
from typing import Any
def _SCREAMING_SNAKE_CASE ( __lowercase : str , __lowercase : list[str] ) -> bool:
"""simple docstring"""
if not isinstance(__lowercase , __lowercase ) or len(__lowercase ) == 0:
raise ValueEr... | 637 |
from __future__ import annotations
from PIL import Image
# Define glider example
__a : Tuple = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0... | 637 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.