code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFea...
123
from collections import deque def A__ ( __A : Optional[Any] ) ->Tuple: __A =len(__A ) __A =deque() __A =[False for _ in range(__A )] __A =[-1 for _ in range(__A )] __A =index_of[:] def strong_connect(__A : Union[str, Any] ...
184
0
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import...
720
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_model...
534
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_con...
421
'''simple docstring''' from math import pi def UpperCamelCase__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> float: return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
270
0
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline __snake_case : Tuple = 'path-to-your-trained-model' __snake_case : Dict = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('cuda') __snake_case : Optional[A...
719
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case = { 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTConfig', 'GroupViT...
128
0
'''simple docstring''' import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTest...
42
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_att...
42
1
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transform...
710
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
284
0
import os def __SCREAMING_SNAKE_CASE ( ) -> int: __A : Optional[Any] = os.path.join(os.path.dirname(a__ ) ,"""num.txt""" ) with open(a__ ) as file_hand: return str(sum(int(a__ ) for line in file_hand ) )[:10] if __name__ == "__main__": print(...
17
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def SCREAMING_SNAKE_CASE_ ( snake_case__ , snake_case__=() , snake_case__=None , snake_case__="no" , snake_case__="...
312
0
from __future__ import annotations def A_ ( a , a , a , a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : int = [] SCREAMING_SNAKE_CASE_ : List[Any] = input_list[low:mid], input_list[mid : high + 1] while left and right: ...
717
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : str = { 'microsoft/git-base': 'https://huggingface.co/microsoft/git-b...
353
0
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism fr...
341
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : List[Any] = logging.get_logger(__name__) __a : List[Any] = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/c...
534
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE...
557
def _snake_case (_snake_case : str , _snake_case : str) -> float: def get_matched_characters(_snake_case : str , _snake_case : str) -> str: _lowercase =[] _lowercase =min(len(_stra) , len(_stra)) // 2 ...
557
1
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct...
630
"""simple docstring""" from __future__ import annotations def _snake_case ( lowercase__ ): # This function is recursive _lowerCamelCase : Optional[Any] = len(lowercase__ ) # If the array contains only one element, we return it (it's t...
630
1
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visio...
712
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCAmelCase = 299_792_458 # Symbols UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase = symbols("""ct x y z""") def A_ ( __a ...
351
0
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _snake_case = get_tests_dir() + "/te...
500
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common ...
525
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 __UpperCAmelCase = '▁' __UpperCAmelCase = {'vocab_file': 'sp...
717
"""simple docstring""" 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,...
194
0
"""simple docstring""" import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from .....
177
"""simple docstring""" def __lowercase ( snake_case_ : int ,snake_case_ : int ) ->int: '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def __lowercase ( ) ->None: '''simple docstring''' assert and_gate(0 ...
177
1
from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase_ = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and false pos...
702
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTest...
86
0
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase : int = """\ """ _lowerCamelCase : int = """ Perplexity (PPL) is one of the most com...
87
'''simple docstring''' import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL a__ : Optional[int] = version.parse(version.parse(torch.__version__).base_version) < version....
368
0
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class a (_lowerCAmelCase ): """simple docstring""" def __init__( self : ...
720
import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib _snake_case : int = { "debug...
203
0
def __a ( __lowerCAmelCase ) -> list: if n_term == "": return [] SCREAMING_SNAKE_CASE : list = [] for temp in range(int(__lowerCAmelCase ) ): series.append(F'''1/{temp + 1}''' if series else '1' ) return series if __...
352
_lowerCamelCase : Optional[Any] = 256 # Modulus to hash a string _lowerCamelCase : Optional[Any] = 1_000_003 def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> bool: SCREAMING_SNAKE_CASE : Tuple = len(__lowerCAmelCase ) S...
352
1
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar _lowerCAmelCase = TypeVar("""T""") _lowerCAmelCase = TypeVar("""U""") class UpperCAmelCase__ ( Generic[T, U] ): def __init__( self , A__ , ...
306
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { """vocab_file""": """vocab.json""", """tokenizer_config_fil...
306
1
"""simple docstring""" import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __a ( __a ): '''simple docstring''' _lowerCamelCase : List[str] = (DDIMParallelScheduler,) ...
118
"""simple docstring""" import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.d...
118
1
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig _lowerCamelCase = { '''facebook/maskformer-swin-base-ade''': ( '''http...
321
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Ra...
321
1
import enum import shutil import sys __a ,__a = shutil.get_terminal_size() __a = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class __a( enum.Enum ): """simple docstring""" lowerCAmelCase = 0 lowerCAmelCase = 1 def lowe...
30
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, ...
269
0
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def A_ ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): ...
718
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, ...
38
0
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py ...
39
'''simple docstring''' def UpperCAmelCase ( lowerCamelCase_ :Union[str, Any] ): '''simple docstring''' snake_case_ : str = len(lowerCamelCase_ ) while cur > 1: # Find the maximum number in arr snake_case_ : Optional[Any] = arr.index(max(arr[0:...
334
0
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers A_ : Dict =[int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def snake_case_ ( ) -> Union[str, Any]: lowerCAmelCase_ = os.path.dirname(os.path.realpath(__snake_case)) lowerCAmelCase...
700
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor,...
606
0
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokeni...
277
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils im...
466
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=_snake_case ): '''simple docstring''' lowerCamelCase__ = ['note_seq'] def __init__( self , *lowercase , **lowercase ...
713
"""simple docstring""" from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch...
492
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def _SCREAMING_SNAKE_CASE ( _lowercase : str , _lowercase : float | Decimal , _lowercase : ...
633
'''simple docstring''' import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def __a(SCREAMING_SNAKE_CASE_ : Any , SCREAMING_SNAKE_CASE_ : Tuple=None ): '''simple docstring''' ...
18
0
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def _lowerCAmelCase ( lowercase : int = 1_0_0_0_0_0_0 , lowercase : int = 1_0 ) ->int: """simple docstring""" lowercase__ = defaultd...
700
'''simple docstring''' def _lowerCAmelCase ( lowercase : int , lowercase : int ) ->str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowercase__ = st...
318
0
'''simple docstring''' class _lowercase : '''simple docstring''' def __init__( self ,lowerCamelCase_ ) -> None: '''simple docstring''' UpperCAmelCase__ : List[Any] = len(lowerCamelCase_ ) UpperCAmelCase__ : Dict ...
614
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase__ : List[str] = logging.get_logger(__name__) UpperCamelCase__ : str = { ...
614
1
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, TrainingArguments...
720
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate dep...
115
0
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel SCREAMING_SNAKE_CASE_ ...
34
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, EN...
532
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_av...
703
"""simple docstring""" from itertools import permutations def A__ ( UpperCamelCase ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False A = [7, 11...
524
0
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, TrainingArguments...
81
def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase ): return 1 if input_a == input_a else 0 def UpperCAmelCase_ ( ): assert xnor_gate(0, 0 ) == 1 assert xnor_gate(0, 1 ) == 0 assert xnor_gate(1, 0 ) == 0 asse...
151
0
'''simple docstring''' 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 ...
44
'''simple docstring''' from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() exc...
44
1
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def UpperCAmelCase__ ( __magic_name__ : str = "isbn/0140328726" ): '''simple docstring''' lowerCAmelCase : Optional[Any] = olid.strip().strip('''/''' ) # Remove leading/...
348
from ..utils import DummyObject, requires_backends class __magic_name__ ( metaclass=snake_case ): _lowerCAmelCase = ["flax"] def __init__( self : Any , *lowerCamelCase__ : Any , **lowerCamelCase__ : Any ): requires_backends(self , ['''flax''']...
348
1
from __future__ import annotations import numpy as np def A ( lowercase ) -> str: '''simple docstring''' return np.maximum(0 , lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
3
def A ( lowercase , lowercase ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) UpperCamelCase = str(bin(lowercase ) )[2:] # remove the leading "0b" UpperCamelCase = str(bin(lowercase ) )[...
3
1
'''simple docstring''' from __future__ import annotations import math class SCREAMING_SNAKE_CASE : def __init__( self , _UpperCAmelCase): '''simple docstring''' __A : int = size # approximate the overall ...
8
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class SCREAMING_SNAKE_CASE : def __init_...
8
1
from __future__ import annotations import time import numpy as np UpperCAmelCase__ : List[str] = [8, 5, 9, 7] UpperCAmelCase__ : List[str] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] UpperCAmelCase__ : Union[str, An...
707
def __lowercase ( _A , _A ) -> int: assert x is not None assert y is not None SCREAMING_SNAKE_CASE : int = len(_A ) SCREAMING_SNAKE_CASE : Union[str, Any] = len(_A ) # declaring the array for storing the dp values ...
446
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( __UpperCamelCase ): _A : Tuple = ['image_processor', 'tokenizer'] _A : str = 'ViTImageProcessor' _A : str...
276
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 __ma...
276
1
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def lowercase (_snake_case ,_snake_case ,_snake_case=1024 ,_snake_case=1024 ,_snake_case=False ,**_snake_case ) ->...
228
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, s...
228
1
'''simple docstring''' class UpperCamelCase__ : def __init__( self : Dict ): '''simple docstring''' a__ = {} # Mapping from char to TrieNode a__ = False def __a ( self : Optional[Any] , lowerCamelCase : Dic...
489
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create s...
8
0
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_atte...
383
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { "facebook/convnextv2-tiny-1k-2...
383
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _A : Optional[Any] = logging.get_logger(__name...
315
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM...
315
1
'''simple docstring''' import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ......
702
'''simple docstring''' import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _SCREAMING_SNAKE_CASE = "src/t...
489
0
'''simple docstring''' def lowercase__( __UpperCamelCase: str ): """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
28
'''simple docstring''' __lowercase : List[Any] = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm''', '''yo...
422
0
from __future__ import annotations def _lowercase ( lowercase__ ): if len(a_ ) == 0: return [] __lowerCAmelCase : Optional[Any] = min(a_ ), max(a_ ) __lowerCAmelCase : Optional[Any] = int(max_value - min_value ) + 1 __lowerCAmelCase ...
713
def _lowercase ( lowercase__ , lowercase__ ): __lowerCAmelCase : Union[str, Any] = len(lowercase__ ) __lowerCAmelCase : Any = len(lowercase__ ) __lowerCAmelCase : str = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] __low...
583
0
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, T...
550
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
98
0
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class _UpperCAmelCase ( unittest.TestCase ): def lowerCAmelCase__ ( sel...
708
'''simple docstring''' 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 _UpperCAmelCase ( snake_case...
640
0
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class __UpperCAmelCase ( unittest.TestCase ): """simple ...
99
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __magic_name__ : List[Any] = { '''configuration_m2m_100''': ['''M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''M2M100Config''', ''...
497
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": __lowerCamelCase = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ' Distillation' ...
721
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import...
328
0
from __future__ import annotations def UpperCAmelCase_ ( _UpperCAmelCase :float , _UpperCAmelCase :float , _UpperCAmelCase :float , ) -> tuple: '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise Val...
188
from __future__ import annotations def UpperCAmelCase_ ( _UpperCAmelCase :list[float] , _UpperCAmelCase :list[float] ) -> float: '''simple docstring''' A_ = sorted(numsa + numsa ) A_ , A_ = divmod(len(_UpperCAmelCase ) ...
188
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ = { 'configuration_efficientformer': [ ...
707
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDM...
35
0
"""simple docstring""" def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> int: """simple docstring""" while a != 0: __snake_case , __snake_case = b % a, a return b def __UpperCamelCase ( SCREAMING_SNAKE...
163
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _SCREAMING_SNAKE_CASE = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""...
163
1
import math def __a ( __UpperCAmelCase , __UpperCAmelCase ): 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 > 360: raise ValueError('''In Malus Law, the a...
709
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Union[str, Any] = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependen...
148
0
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_bytes, to_bytes ...
354
from collections.abc import Sequence from queue import Queue class __a : def __init__( self : str , snake_case_ : List[str] , snake_case_ : Tuple , snake_case_ : Tuple , snake_case_ : Optional[Any]=None , snake_case_ ...
354
1
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class _A ( __UpperCamelCase...
702
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _A ( unittest.TestCase ): ...
469
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] = { "Intel/dpt-large": "https://hugg...
85
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, ...
431
0
'''simple docstring''' import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class __SCREAMING_SNAKE_CASE ( __UpperCamelCase , unittest.TestCase ): '''simple d...
368
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef __magic_name__ : List[str] = ( """This metric will be removed...
368
1
'''simple docstring''' import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device...
685
def UpperCamelCase ( snake_case__ : int ) -> str: if isinstance(snake_case__ , snake_case__ ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(snake_case__ , snake_case__ ): raise TypeError('\'str\' object can...
40
0
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class UpperCAmelCase_ : UpperCamelCase =42 UpperCamelCase =None UpperCamelCase =None def __UpperCAmelCase ( __UpperCamelCase ): ...
523
"""simple docstring""" a_ = [ 9_9_9, 8_0_0, 7_9_9, 6_0_0, 5_9_9, 5_0_0, 4_0_0, 3_9_9, 3_7_7, 3_5_5, 3_3_3, 3_1_1, 2_8_8, 2_6_6, 2_4_4, 2_2_2, 2_0_0, 1_9_9, 1_7_7, 1_5_5, 1_3_3, 1_1...
523
1
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSemantic...
182
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsk...
182
1
'''simple docstring''' from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ : List[str] = TypeVar('''T''') def a ( UpperCamelCase_ : Tuple ) -> int: return (position - 1) // 2 def a ( ...
701
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def a ( UpperCamelCase_ : Union[str, Any] , UpperCamelCase_ : Union[str, Any] , UpperCamelCase_ : Optional[int] , UpperCamelCase_ : Dict ) ...
581
0
"""simple docstring""" 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_uti...
104
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCamelCase__ ( unittest.TestCase ): """simple docstri...
104
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalD...
454
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowerCamelCase = logging.get_logger(__name__) class _UpperCamelCase ( A ): '''simple docstring''' def __init__( self : Optional[int] , *_...
454
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig lowerCAmelCase = { """google/tapas-base-finetuned-sqa""": ( """https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json""" ), """google/tapas-base-finetuned-wtq""": ( "...
292
'''simple docstring''' def lowerCamelCase_ ( __UpperCamelCase : int ) -> bool: """simple docstring""" if num < 0: return False _A = num _A = 0 while num > 0: _A = rev_num * 1_0 + (num % 1_0) ...
292
1
'''simple docstring''' from __future__ import annotations import math def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ) -> float: lowerCamelCase__ : Union[str, Any] = u for i in range(1 , UpperCamelCase ): ...
631
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_t...
631
1
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __A : Tuple = ( '4S 3H 2C 7S 5H', '9D 8H 2C 6S 7H', '2D 6D 9D TH 7D', 'TC 8C 2S JH 6C', 'JH 8S TH AH QH', 'TS KS 5S 9S AC', 'KD 6S 9D TH AD...
16
"""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,...
674
0
'''simple docstring''' from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import data...
513
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_util...
513
1
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a__ = False class snake_case ( unittest.TestCase ): ...
477
"""simple docstring""" import argparse import importlib from pathlib import Path # Test all the extensions added in the setup SCREAMING_SNAKE_CASE_ = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deform...
465
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __snake_case : Optional[int] = { "configuration_sp...
701
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : Tuple = logging.get_logger(__name__) __snake_case : int = { "facebook/wav2vec2-base-960h": "https://huggingface.c...
691
0
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datas...
475
"""simple docstring""" import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Co...
473
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")): raise OptionalDependencyNotAvailable(...
106
import math import os import sys def _a ( SCREAMING_SNAKE_CASE : str ): """simple docstring""" UpperCamelCase__ : Any = '''''' try: with open(SCREAMING_SNAKE_CASE , '''rb''' ) as binary_file: UpperCamelCase__ : int = binary_file.read() for...
106
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,...
619
def lowerCamelCase__ ( __A :int ,__A :int ): """simple docstring""" if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) __snake_case = str(bin(__A ) )[2:] # remove the leading "0b" __sna...
268
0
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin __lowerCA...
713
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
396
0
'''simple docstring''' from datetime import datetime as dt import os from github import Github __UpperCAmelCase = [ """good first issue""", """good second issue""", """good difficult issue""", """feature request""", """new model""", """wip""", ] def __A ( ): ...
379
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=lowercase_ ): """simple docstring""" SCREAMING_SNAKE_CASE__ = ['''flax'''] def __init__( self : Optional[int] , *lowerCamelCase_ : An...
379
1
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils im...
423
def snake_case__ ( lowerCamelCase_ ): A : Optional[Any] = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( lowerCamelCase_ ): A : Optional[Any] = 0 while number > 0: ...
423
1
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, ...
633
"""simple docstring""" from numpy import exp, pi, sqrt def _SCREAMING_SNAKE_CASE ( _lowercase : Tuple , _lowercase : float = 0.0 , _lowercase : float = 1.0 ) ->int: '''simple docstring''' return 1 / sqrt(...
633
1
from random import randint from tempfile import TemporaryFile import numpy as np def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Dict = 0 if start < end: ...
709
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _snake_case = logging.get_logger(__name__) _snake_case = { "microsoft/focalnet-tiny": "https://huggingface.co/microsof...
658
0
'''simple docstring''' import math def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """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 mult...
565
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available _lowerCamelCase : int = { '''configuration_ernie''': ['''ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieConfig''', '''ErnieOnnxConfig'''], } t...
686
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, float...
716
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : List[str] = logging.get_logger(__name__) _a : Any = { "kssteven/ibe...
10
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils import f...
360
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: Optional[int] = { '''configuration_roformer''': ...
360
1
import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
711
import json import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prep...
669
0
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, ...
319
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_common im...
319
1
from typing import List import numpy as np def lowerCAmelCase_ (_SCREAMING_SNAKE_CASE : dict ): UpperCamelCase_ : Optional[Any] = {key: len(_SCREAMING_SNAKE_CASE ) for key, value in gen_kwargs.items() if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )} ...
717
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 UpperCamelCase ( ...
138
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): assert isinstance(__lowerCAmelCase , __lowerCAmelCase ), F"""The input value of [n={number}] is not an integer""" if number == 1: return 2 elif number < 1: __lowercase = F"""The input value of [n={number}] has to be > 0""" raise ValueEr...
402
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": ( "htt...
369
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def UpperCAmelCase_ ( _UpperCAmelCase ): lowerCamelCase_: List[s...
584
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """Grou...
584
1
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available...
11
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartFor...
689
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
702
from sklearn.metrics import fa_score import datasets UpperCAmelCase_ : List[Any] = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' UpperCAmelCase_ : Optional[Any] ...
443
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCamelCase = 2_9979_2458 # Symbols UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase = symbols('ct x y z') def _A ( lowerCAmelCase_ : ...
61
from __future__ import annotations def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : int , lowerCAmelCase_ : int , lowerCAmelCase_ : int ): """simple docstring""" lowerCAmelCase__ = [] lowerCAmelCase__ , lowerCAmelCas...
61
1
'''simple docstring''' from __future__ import annotations def __lowercase (_lowercase ) -> List[str]: """simple docstring""" __lowerCamelCase : Union[str, Any] = 2 __lowerCamelCase : Optional[int] = [] while i * i <= n: if n ...
714
'''simple docstring''' from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=lowerCAmelCase_ ): snake_case__ : Union[str, Any] = ['torch', 'torchsde'] def __init__( self : int , *A__ : Optional[Any] , **A__ ...
483
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_a...
410
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch...
431
0
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class lowerCAmelCase ( unittest.TestCase ): def a__ ( self ): _A= inspect.getfile(accelerate.test_utils ) ...
701
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { '''BridgeTower/bridgetower-base''': '''https://huggingface.co/BridgeTower/bridge...
476
0
import baseaa def _lowercase ( __UpperCamelCase : str ): return baseaa.aaaencode(string.encode("""utf-8""" ) ) def _lowercase ( __UpperCamelCase : bytes ): return baseaa.aaadecode(__UpperCamelCase ).decode("""utf-8""" ) if __name__ == "__main__": ...
214
from math import ceil def _lowercase ( __UpperCamelCase : int = 1001 ): snake_case__ = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): snake_case__ = 2 * i + 1 snake_case__ = 2 * i snake_case__ = tot...
214
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 _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] ...
108
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class lowercase : __SCREAMING_SNAKE_CASE : int __SCREAMING_SNAKE_CASE : Node | None = None __SC...
108
1
import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel SCREAMING_SNAKE_CASE :str = logging.getLo...
55
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGEN...
89
0
def __UpperCAmelCase( ): _lowerCamelCase : int = [] _lowerCamelCase : Union[str, Any] = 1 while len(lowercase_ ) < 1e6: constant.append(str(lowercase_ ) ) i += 1 _lowerCamelCase : str = ''''''.join(lo...
613
import unittest from knapsack import knapsack as k class __A ( unittest.TestCase ): """simple docstring""" def __snake_case ( self): """simple docstring""" _lowerCamelCase : Dict = 0 _lowerCamelCase ...
613
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json', } class SCREAMING_SNAKE_CASE ( sn...
225
'''simple docstring''' import argparse from collections import defaultdict import yaml lowerCAmelCase_ : Tuple = 'docs/source/en/_toctree.yml' def UpperCAmelCase ( A : Union[str, Any] ): SCREAMING_SNAKE_CASE : Dict = defaultdi...
527
0
import gc import threading import time import psutil import torch class __UpperCamelCase : def __init__( self: List[Any] ): '''simple docstring''' __magic_name__ = psutil.Process() __magic_name__ = False def _SCREAMING_SNAKE_CASE ( ...
704
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): @register_to_config def __init__( self: Optional[Any] , *, __UpperCamelCas...
184
0