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
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bn...
662
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAut...
101
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fro...
662
0
"""simple docstring""" import math import os import sys def UpperCamelCase (SCREAMING_SNAKE_CASE ): UpperCamelCase : Optional[Any] = """""" try: with open(SCREAMING_SNAKE_CASE , """rb""" ) as binary_file: UpperC...
102
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:int = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_...
662
0
"""simple docstring""" 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 Config...
103
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
"""simple docstring""" # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union UpperCamelCase = re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""")...
104
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
662
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase_ ( lowerCamelCase_ , unittest.Test...
105
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __snake_case :List[str] =logging.get_logger(__name__) __snake_case ...
106
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
662
0
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig _UpperCAmelCase : Dict = logging.getLogger(__name__) class lowercase_ ( _UpperCamelCase ): """simple docstring""" __lowerCAmelCase = "masked_bert" ...
107
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
0
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...t...
108
from typing import Any import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return np.array_equal(_lowerCAmelCase , matrix.conjugate().T ) def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> ...
662
0
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: '''simple docstring''' __SCREAMING_SNAKE_CASE = len(__UpperCAmelCase ) __SCREAMING_SNAKE_CASE = len(__UpperCAmelCase ) __SCREAMING_SNAKE_CASE ...
109
from __future__ import annotations import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" A , A : int = np.shape(_lowerCAmelCase ) if rows != columns: A : Union[str, Any] = ...
662
0
import math import sys def lowerCAmelCase_ ( __a ) -> int: """simple docstring""" if number != int(_lowerCAmelCase ): raise ValueError("the value of input must be a natural number" ) if number < 0: raise ValueError("the value of input must not be a negativ...
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' class UpperCamelCase__ : """simple docstring""" def __init__( self : int ): '''simple docstring''' SCREAMING_SNAKE_CASE : List[str] = """""" SCREAMING_SNAKE_CASE : Optional[int] = """""" SCREAMING_SNAKE_...
379
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self, lowerCamelCase__ ): # we need a list not a string, so do something to change the type A : List[Any] = arr.split(""",""" ) def _lowerCAmelCase ( self ): ...
662
0
"""simple docstring""" def _lowerCamelCase ( UpperCAmelCase__,UpperCAmelCase__,UpperCAmelCase__ ) -> int: '''simple docstring''' def count_of_possible_combinations(UpperCAmelCase__ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum...
232
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_:List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[Any] = { """google/bit-50""": ...
662
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ : Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ : int = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.js...
375
import unittest from transformers import BertGenerationConfig, 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 ModelTeste...
662
0
class __lowercase : """simple docstring""" def __init__( self : Union[str, Any] , lowerCAmelCase__ : List[str]): # we need a list not a string, so do something to change the type SCREAMING_SNAKE_CASE_: List[Any] = arr.split(",") def _SC...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
662
0
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy lowerCAmelCase__ = logging.get_logger(__name__) class snake_case ...
321
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 PILImageResamplin...
662
0
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration a_ = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """weight"""),...
175
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE_:Optional[int] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __init__( self, *...
662
0
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _UpperCAmelCase : Union[str, Any] = """Usage of script: script_name <size_of_canvas:int>""" _UpperCAmelCase : Union[str, Any] = [0] * 1_00 + [1...
295
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
662
0
"""simple docstring""" import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_fl...
123
from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE_:int = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE_:Dict = _LazyModule(__name__, global...
662
0
from __future__ import annotations _snake_case = list[tuple[int, int]] _snake_case = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0...
382
def __UpperCamelCase ( _lowerCAmelCase = 1000 ) -> int: """simple docstring""" A , A : str = 1, 1 A : List[Any] = [] for i in range(1 , n + 1 ): A : Optional[int] = prev_numerator + 2 * prev_denominator A : Any =...
662
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } a__ = { "...
654
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
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 required b...
59
from __future__ import annotations SCREAMING_SNAKE_CASE_:Tuple = """#""" class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self ): A : dict = {} def _lowerCAmelCase ( self, lowerCamelCase__ ): A : List[A...
662
0
'''simple docstring''' 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_BLOC...
379
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bn...
662
0
"""simple docstring""" def _lowerCamelCase ( UpperCAmelCase__ ) -> int: '''simple docstring''' a__ = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def _lowerCamelCase ( UpperCAmelCase__ = 1_00 ) -> int: '''simple docstrin...
232
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fro...
662
0
def SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case , snake_case ) -> bool: if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vertex is not already in path return not any(vertex == next_ver for vertex in path ...
375
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:int = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_...
662
0
import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ConfigTester from ...tes...
671
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class snake_case ( SCREAMING_SNAKE_CASE__ ,unittest.TestCase ): """si...
321
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
662
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
175
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.models.wavave...
295
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
662
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : Any = logging.get_logger(__name__) lowercase__ ...
123
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _snake_case = logging.get_logger(__name__) _snake_case = { """SenseTime/deformable-detr""": """https://huggingface.co/sensetime/deformable-detr/resolve/mai...
382
from typing import Any import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return np.array_equal(_lowerCAmelCase , matrix.conjugate().T ) def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> ...
662
0
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
654
from __future__ import annotations import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" A , A : int = np.shape(_lowerCAmelCase ) if rows != columns: A : Union[str, Any] = ...
662
0
from math import asin, atan, cos, radians, sin, sqrt, tan __A = 637_8137.0 __A = 635_6752.31_4245 __A = 637_8137 def lowerCAmelCase_ ( __a , __a , __a , __a ) -> float: """simple docstring""" lower...
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extr...
379
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self, lowerCamelCase__ ): # we need a list not a string, so do something to change the type A : List[Any] = arr.split(""",""" ) def _lowerCAmelCase ( self ): ...
662
0
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare...
232
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_:List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[Any] = { """google/bit-50""": ...
662
0
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # sinc...
375
import unittest from transformers import BertGenerationConfig, 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 ModelTeste...
662
0
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 lowerCAmelCase : List[str] = logging.get_logger(__name__) lowerCAmelCase : List[Any] ...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
662
0
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
321
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 PILImageResamplin...
662
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { """configuration_bert""": ["""BERT_PRETRAINED_C...
175
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE_:Optional[int] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __init__( self, *...
662
0
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow _UpperCAmelCase : Dict = logging.getLogger() @unittest.skip("""Temporarily disable the...
295
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
662
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCAmelCase ( SCREAMING_SNAKE_CASE__): _lowerCAmelCase : Union[str, Any] = "Speech2TextFeatureExtractor" _lowerCAmelCase : Optional[int] ...
123
from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE_:int = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE_:Dict = _LazyModule(__name__, global...
662
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _snake_case = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author={Yonghui Wu and...
382
def __UpperCamelCase ( _lowerCAmelCase = 1000 ) -> int: """simple docstring""" A , A : str = 1, 1 A : List[Any] = [] for i in range(1 , n + 1 ): A : Optional[int] = prev_numerator + 2 * prev_denominator A : Any =...
662
0
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq....
654
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
0
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket" ) @patch("builtins.open" ) def lowerCAmelCase_ ( __a , __a ) -> Dict: """simple docstring""" lowerCamelCase__: int =Mock() lowerCamelCase...
59
from __future__ import annotations SCREAMING_SNAKE_CASE_:Tuple = """#""" class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self ): A : dict = {} def _lowerCAmelCase ( self, lowerCamelCase__ ): A : List[A...
662
0
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class UpperCamelCase__ ( datasets.BuilderConfig ): """simple docstring""...
379
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bn...
662
0
"""simple docstring""" from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def _lowe...
232
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fro...
662
0
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTe...
375
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:int = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_...
662
0
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class __lowercase ( ...
671
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interle...
321
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
662
0
import argparse import os import re a_ = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ = re.compile(R"""[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict""") # re pa...
175
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _UpperCAmelCase : str = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
295
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
662
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
123
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = {"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""} class _snake_case ( SCREAMING_SNAKE_CASE__ ): lo...
382
from typing import Any import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return np.array_equal(_lowerCAmelCase , matrix.conjugate().T ) def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> ...
662
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 required ...
654
from __future__ import annotations import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" A , A : int = np.shape(_lowerCAmelCase ) if rows != columns: A : Union[str, Any] = ...
662
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import ...
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClas...
379
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self, lowerCamelCase__ ): # we need a list not a string, so do something to change the type A : List[Any] = arr.split(""",""" ) def _lowerCAmelCase ( self ): ...
662
0
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( UpperCAmelCase__,UpperCAmelCase__ ) -> tuple[int, int]: '''simple docstring''' if b == 0: return (1, 0) (a__) = extended_euclid(_lowerCAmelCase,a % b ) a__ = a // b return ...
232
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_:List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[Any] = { """google/bit-50""": ...
662
0
from heapq import heappop, heappush import numpy as np def SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case , snake_case , ) -> tuple[float | int, list[tuple[int, int]]]: __lowercase = grid.shape __lowercase = [-1, 1, 0, 0] ...
375
import unittest from transformers import BertGenerationConfig, 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 ModelTeste...
662
0
class __lowercase : """simple docstring""" def __init__( self : List[str] , lowerCAmelCase__ : List[str] , lowerCAmelCase__ : List[str]=None , lowerCAmelCase__ : Optional[Any]=None): SCREAMING_SNAKE_CASE_: str = data SCREAMING_SNAKE_CAS...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
662
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class ...
321
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 PILImageResamplin...
662
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils impor...
175
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE_:Optional[int] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __init__( self, *...
662
0
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Op...
295
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
662
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=SCREAMING_SNAKE_CASE__): _lowerCAmelCase : Any = ["torch", "transformers", "onnx"] def __init__( self : Any , *lowercase_ : List[str] , **lowercase_ ...
123
from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE_:int = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE_:Dict = _LazyModule(__name__, global...
662
0
import math def _UpperCamelCase ( snake_case__, snake_case__ ) -> float: if initial_intensity < 0: raise ValueError("The value of intensity cannot be negative" ) # handling of negative values of initial intensity if angle < 0 or angle...
382
def __UpperCamelCase ( _lowerCAmelCase = 1000 ) -> int: """simple docstring""" A , A : str = 1, 1 A : List[Any] = [] for i in range(1 , n + 1 ): A : Optional[int] = prev_numerator + 2 * prev_denominator A : Any =...
662
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() a__ = logging.get_logger(__name__) a__ = [ ["""attention""", """attn"""], ["""encoder_attention""", """encoder_attn"""]...
654
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( __a , __a , __a ) -> Optional[Any]: """...
59
from __future__ import annotations SCREAMING_SNAKE_CASE_:Tuple = """#""" class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self ): A : dict = {} def _lowerCAmelCase ( self, lowerCamelCase__ ): A : List[A...
662
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCAmelCase = {"""configuration_unispeech""": ["""UNISPEECH_PRETRAINED_CONFIG_ARCHI...
379
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bn...
662
0
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels __magic_name__ = object() # For specifying empty leaf dict `{}` __magic_name__ = object()...
232
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fro...
662
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch,...
375
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:int = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_...
662
0
def A_ ( _UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: Optional[Any] = len(_lowerCAmelCase ) SCREAMING_SNAKE_CASE_: Optional[Any] = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a...
671
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset from torc...
321
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
662
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, ) a_ = { """configuration_clip""": [ """CLIP_PRETRAINED_C...
175
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase ( metaclass=SCREAMING_SNAKE_CASE__ ): UpperCAmelCase__ = ["torch", "scipy"] def __init__( self : Union[str, Any] , *UpperCAmelCase : List[str] , **UpperCAmelCase : Optional[int] ) -> int:...
295
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
662
0
"""simple docstring""" import os import numpy import onnx def __lowercase ( _a , _a ): snake_case_ : int = a.name snake_case_ : Optional[int] = b.name snake_case_ : Tuple = """""" snake_case_ : List[Any] = """""...
123
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _snake_case ...
382
from typing import Any import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return np.array_equal(_lowerCAmelCase , matrix.conjugate().T ) def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> ...
662
0
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acc...
654
from __future__ import annotations import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" A , A : int = np.shape(_lowerCAmelCase ) if rows != columns: A : Union[str, Any] = ...
662
0
def lowerCAmelCase_ ( __a = 50 ) -> int: """simple docstring""" lowerCamelCase__: List[Any] =[1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ...
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' 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_uti...
379
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self, lowerCamelCase__ ): # we need a list not a string, so do something to change the type A : List[Any] = arr.split(""",""" ) def _lowerCAmelCase ( self ): ...
662
0
"""simple docstring""" import unittest from transformers import BertGenerationConfig, 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_co...
232
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_:List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[Any] = { """google/bit-50""": ...
662
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case , snake_case ) -> list: __lowercase = [] __lowercase = input_list[low:mid], input_list[mid : high + 1] while left and right: result.ap...
375
import unittest from transformers import BertGenerationConfig, 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 ModelTeste...
662
0
def A_ ( _UpperCAmelCase = 10**12 ): SCREAMING_SNAKE_CASE_: Tuple = 1 SCREAMING_SNAKE_CASE_: Dict = 0 SCREAMING_SNAKE_CASE_: int = 1 SCREAMING_SNAKE_CASE_: Optional[int] = 1 while numerator <= 2 * min_total - ...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
662
0
import json import sys def __lowercase ( _UpperCAmelCase , _UpperCAmelCase ) -> int: '''simple docstring''' with open(_lowerCAmelCase , encoding="utf-8" ) as f: __lowercase = json.load(_lowerCAmelCase ) __lowercase = ["""<details>""", """<summary>Show updat...
321
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 PILImageResamplin...
662
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatureExtractor"""], """proce...
175
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE_:Optional[int] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __init__( self, *...
662
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Acc...
295
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
662
0
"""simple docstring""" from __future__ import annotations from typing import Any def __lowercase ( _a ): create_state_space_tree(_lowerCAmelCase , [] , 0 ) def __lowercase ( _a , _a , _a ): if index == len(_lowerCAmelCase ...
123
from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE_:int = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE_:Dict = _LazyModule(__name__, global...
662
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.ut...
382
def __UpperCamelCase ( _lowerCAmelCase = 1000 ) -> int: """simple docstring""" A , A : str = 1, 1 A : List[Any] = [] for i in range(1 , n + 1 ): A : Optional[int] = prev_numerator + 2 * prev_denominator A : Any =...
662
0
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ......
654
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
0
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_xlnet impo...
59
from __future__ import annotations SCREAMING_SNAKE_CASE_:Tuple = """#""" class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self ): A : dict = {} def _lowerCAmelCase ( self, lowerCamelCase__ ): A : List[A...
662
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example __UpperCAmelCase = [ [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,...
379
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import Bn...
662
0
"""simple docstring""" import re from filelock import FileLock try: import nltk __magic_name__ = True except (ImportError, ModuleNotFoundError): __magic_name__ = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True...
232
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand fro...
662
0
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.u...
375
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_:int = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_...
662
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.mo...
671
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> list[int]: """simple docstring""" A : Optional[int] = int(_lowerCAmelCase ) # Initialize Result A : int = [] # Traverse through all denomination for denomination in reversed(...
662
0
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class snake_case ( nn.Module ): """...
321
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ...
662
0
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu from...
175
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__v...
662
0
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase = False ) -> str: if not isinstance(_lowerCAmelCase , _lowerCAmelCase ): lowerCamelCase__ : Optional[Any] = F"""Expected string as input, found {type(_lowerCAmelCase )}""" rais...
295
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProce...
662
0
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : str , lowercase_ : str ): snake_case_ : Any = value snake_case_ : Node | None = None snake_case...
123
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp @s...
662
0
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeli...
382
from typing import Any import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return np.array_equal(_lowerCAmelCase , matrix.conjugate().T ) def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> ...
662
0
def _UpperCAmelCase ( a : Optional[int] , a : Optional[Any] ): return int((input_a, input_a).count(0 ) == 0 ) def _UpperCAmelCase ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0 ) == 0 ...
654
from __future__ import annotations import numpy as np def __UpperCamelCase ( _lowerCAmelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" A , A : int = np.shape(_lowerCAmelCase ) if rows != columns: A : Union[str, Any] = ...
662
0
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __A = logging.get_logger(__name__) __A = """https://openaipublic....
59
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
'''simple docstring''' from __future__ import annotations import math def __A ( lowerCamelCase_ ): """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 multiples...
379
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self, lowerCamelCase__ ): # we need a list not a string, so do something to change the type A : List[Any] = arr.split(""",""" ) def _lowerCAmelCase ( self ): ...
662
0