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 csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def...
581
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowercase__ = 10 def __magic_name__ ( _lowerCamelCase : int , _lowe...
581
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Optional[int] = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], } try: if not is_torch_available(): raise OptionalDependen...
75
# 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 required by applica...
75
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { 'configuration_time_series_transformer': [ 'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP...
466
'''simple docstring''' 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 comm...
466
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig lowerCamelCase__ = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''', '''albert-large-v1''': '...
408
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, log...
408
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['BioGptToken...
458
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __lowerCAmelCase : '''simple docstring''' lowerCAmelCase__ : int lowerCAmelCase__ : TreeNode | None = None lowerCAmelC...
460
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 AddedToken, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : Tuple = logg...
715
'''simple docstring''' import qiskit def _snake_case ( lowercase , lowercase ) -> qiskit.result.counts.Counts: __a : Any = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register __a : str ...
697
0
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = "T5Config" class __UpperCamelCase ( A__ ): ...
32
def _a ( __UpperCamelCase : int ): if not isinstance(__UpperCamelCase ,__UpperCamelCase ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) lowerCAmelCase__ : List[str] = str(__UpperCamelCase ) lowerCAmelCase__ : List[Any] ...
233
0
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() a_ : Dict = logging.get_logger(__name__) def lowerCamelCase__ (_UpperCAmelCase , ...
444
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self) -> str: debug_launcher(test_script.main) de...
444
1
import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from accelerate....
14
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
639
0
import argparse import os import re _lowerCamelCase : Optional[Any] ="""src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict _lowerCamelCase : Dict =re.compile(R"[A-Z_]+_MAPPING(...
720
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import floa...
252
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_ : Optional[int] = ...
44
# 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 t...
639
0
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCamelCase__ ): '''simple docstring''' _A : Optional[int] = (KDPMaDis...
178
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : Optional[int] = {'''configuration_wavlm''': ['''WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''WavLMConfig''']} try: if not is_tor...
178
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : List[str] = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTransformerConfig', ...
15
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A ( unittest.TestCase ): '''simple docstring''' ...
15
1
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow...
652
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def A__( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): # Initialise PyTorch model ...
652
1
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) a_ : Optional[int] ...
676
'''simple docstring''' def a_ ( __snake_case : int , __snake_case : int ) -> str: """simple docstring""" if not isinstance(__snake_case , __snake_case ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(__snak...
676
1
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_tokenization_common import Toke...
286
def __lowerCAmelCase ( A_ : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) __UpperCAmelCase = sorted(string.lower() ) return len(A_ ) == len(set(A_ ) ) if __name__...
286
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase_ ) class lowerCamelCase_ ( lowercase_ ): """simp...
459
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { """microsoft/git-base""": """https://huggingface.co/microsoft/git-base/resolve/main/config....
655
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_...
289
'''simple docstring''' from manim import * class UpperCamelCase__ ( __lowerCAmelCase ): def __a ( self : List[Any] ): '''simple docstring''' a__ = Rectangle(height=0.5 , width=0.5 ) a__ = Rectangle(height=0.25 , wi...
289
1
'''simple docstring''' import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @req...
24
"""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 transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import log...
426
0
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration __SCREAMING_SNAKE_CASE = 500000 __SCREAMING_SNAKE_CASE = os.path.split(__file__) __SCREAMING_SNAKE_CASE = os.path.join(RESULTS_BASEPATH, """results...
720
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __SCREAMING_SNAKE_CASE = 1.0_5_4_5_7_1_8_1_7e-3_4 # unit of ℏ : J * s __SCREAMING_SNAKE_CASE = 3e8 # unit of c : m * s^-1 ...
17
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-large''': '''h...
1
def _A ( _lowercase = 1_00 ) -> int: """simple docstring""" __UpperCamelCase = 0 __UpperCamelCase = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main_...
1
1
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( A__ ): @staticmethod @abstractmethod def snake_case_ ( a__): raise NotImplementedError() @abstractmethod def snake_case_ (...
720
# 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/licenses/LICENSE-2.0 # # Unl...
526
0
from copy import deepcopy class __A : def __init__(self , __magic_name__ = None , __magic_name__ = None ): if arr is None and size is not None: lowerCamelCase__ : int = size lowerCamelCase__ : Union[str, Any] = [0] * size ...
157
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResamp...
157
1
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_av...
719
'''simple docstring''' import numpy # List of input, output pairs SCREAMING_SNAKE_CASE_ = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) SCREAMING_SNAKE_CASE_ = (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) SCREAMING_SNAKE_CASE_ = ...
466
0
'''simple docstring''' import requests SCREAMING_SNAKE_CASE__ = 'YOUR API KEY' def lowercase__ ( __UpperCamelCase , __UpperCamelCase = giphy_api_key )-> list: UpperCamelCase = """+""".join(query.split() ) UpperCamel...
301
'''simple docstring''' import requests from bsa import BeautifulSoup def lowercase__ ( __UpperCamelCase = "AAPL" )-> str: UpperCamelCase = F"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}" UpperCamelCase = BeautifulSoup(...
301
1
def a (_lowerCAmelCase ): if not isinstance(_lowerCAmelCase , _lowerCAmelCase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: raise ValueError('''multiplicative_persistence() does not accept ...
89
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE ={ """configuration_xlm_roberta_xl""": [ """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMRobertaXLConfig""", """X...
89
1
'''simple docstring''' from importlib import import_module from .logging import get_logger SCREAMING_SNAKE_CASE_: Any =get_logger(__name__) class __A : def __init__(self : str , __a : Optional[int] , __a : int=None ): UpperCAmelCase_ ...
78
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline, UnCLIPIma...
354
0
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase : Optional[int] = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys lowercase : ...
94
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowercase : List[str] = collections.namedtuple('_Datasets...
94
1
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase = get_tests_dir("fixtures/spiece.model"...
66
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Optional[Any] = { """configuration_funnel""": ["""FUNNEL_PRETRAIN...
142
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ : Dict = { """configuration_poolformer""": [ """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PoolFormerConfig""", ...
440
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : int = {"""configuration_plbart""": ["""PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
440
1
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Any = { """huggingface/informer-tourism-monthly""": ( ...
79
# 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 # # U...
79
1
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _A = HfApi() _A = {} # fmt: off _A = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, 1.2342, -2.2485, 0.4636, 0.8076...
702
import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class lowerCamelCase ( unittest.TestCase ): ...
294
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 snake_case = '''▁''' snake_case = {'''...
103
"""simple docstring""" import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCamelCase__ ( snake_case ): ...
341
0
'''simple docstring''' from datetime import datetime import requests def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : str ) -> bytes: _a : Optional[int] ="""https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" _a ...
703
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device A__: List[str] = False class A_...
506
0
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accele...
44
import argparse import os import torch from transformers.utils import WEIGHTS_NAME SCREAMING_SNAKE_CASE__ : Union[str, Any] = ["small", "medium", "large"] SCREAMING_SNAKE_CASE__ : Optional[int] = "lm_head.decoder.weight" SCREAMING_SNAKE_CASE__ : List[Any] = "lm_h...
298
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "junnyu/roformer_chinese_small": "https://huggingface.co...
700
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.data import Dataset from tra...
639
0
from collections import deque from math import floor from random import random from time import time class UpperCAmelCase_ : """simple docstring""" def __init__( self ) -> List[Any]: UpperCamelCase :List[str] = {} def UpperCAmelCase ...
658
import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets __snake_case = """\ @article{hendrycksmath2021, title={Measuring Mathematical Problem Solving With the MATH Dataset}, author={Dan Hendrycks and Collin Burns and Saurav Kadavath and Akul Arora ...
658
1
import argparse import json 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 Acce...
648
from ...processing_utils import ProcessorMixin class lowercase ( _lowercase ): """simple docstring""" a__ = ["image_processor", "feature_extractor"] a__ = "TvltImageProcessor" a__ = "TvltFeatureExtractor" def __init__( self , __snake_c...
648
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, log...
47
def UpperCAmelCase__ ( lowerCamelCase_ : list[int] , lowerCamelCase_ : list[int] ): # Check if the input is valid if not len(lowerCamelCase_ ) == len(lowerCamelCase_ ) == 3: raise ValueError('Please enter a valid equation.' ) if equa...
47
1
"""simple docstring""" def _lowerCAmelCase ( __lowerCamelCase:Any ): '''simple docstring''' __magic_name__ = 1 __magic_name__ = 2 while i * i <= n: __magic_name__ = 0 while n % i == 0: n //= ...
720
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin f...
468
0
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( 'files' , [ ['full:README.md', 'dataset_infos.json'], ['empty:README.md', 'dataset_infos.json'], ['data...
84
def __magic_name__ ( lowercase ) -> list: """simple docstring""" if n_term == "": return [] lowercase_ : list = [] for temp in range(int(lowercase ) ): series.append(f"""1/{temp + 1}""" if series else """1""" ...
458
0
"""simple docstring""" # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowercase__ : Tuple = TypeVar('''T''') class _UpperCAmelCase ( Gen...
485
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
485
1
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets _lowercase = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks...
342
'''simple docstring''' import math def __UpperCamelCase ( a : int ) ->list[int]: snake_case = [] snake_case = 2 snake_case = int(math.sqrt(a ) ) # Size of every segment snake_case = [True] * (end + 1) snake_case = ...
342
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : List[Any] =logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] ={ 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://huggingface.co/microsof...
702
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 import...
619
0
from __future__ import annotations from math import pi def lowerCamelCase__ ( _a , _a , _a): if (inductance, frequency, reactance).count(0) != 1: raise ValueError("One and only one argument must be 0") if inductance < 0: raise ValueError("Inductance cannot be negative") if frequen...
25
'''simple docstring''' 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_...
161
0
import os import sys import transformers __magic_name__ = '''3''' print('''Python version:''', sys.version) print('''transformers version:''', transformers.__version__) try: import torch print('''Torch version:''', torch.__version__) print('''Cuda available:''', ...
702
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 lowerCAmelCase__ ( unittest.TestCase ): """...
73
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax...
98
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : str ,_UpperCAmelCase : str ) -> list: _a : Tuple =len(_UpperCAmelCase ) _a : str =[] for i in range(len(_UpperCAmelCase ) - pat...
694
0
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( lowercase_ ): UpperCamelCase = (DDPMScheduler,) def lowerCamelCase ( self :Any , **__UpperCamelCase :Union[s...
524
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransfor...
524
1
'''simple docstring''' def _A ( UpperCAmelCase = 1000 ): '''simple docstring''' A__ = 2**power A__ = 0 while n: A__ , A__ = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input()).strip()...
531
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP lowerCAmelCase__ = False try: lowerCAmelCase__ = _is_packa...
321
0
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_mode...
397
"""simple docstring""" import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging _lowercase : Tuple = lo...
397
1
'''simple docstring''' from __future__ import annotations class snake_case : """simple docstring""" def __init__( self , lowerCamelCase ) -> None: """simple docstring""" snake_case__ : Optional[Any] = order # a_{0} ... a_{k} snak...
261
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tens...
312
0
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def SCREAMING_SNAKE_CASE ( lowerCamelCase_ , lowerCamelCase_ , **lowerCamelCase_): a__ = AutoConfig.from_pretrained(lowerCamelCase_ , **lowerCamel...
713
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __a : Any = logging.get_logger(__name__) __a : Union[str, Any] = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classic...
200
0
"""simple docstring""" from maths.prime_check import is_prime def lowerCAmelCase_ (_SCREAMING_SNAKE_CASE :int ) -> int: if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): a_ : Optional[int] = F'''Input value of [number={number}] must be an ...
473
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class Upp...
473
1
UpperCamelCase = { """a""": """AAAAA""", """b""": """AAAAB""", """c""": """AAABA""", """d""": """AAABB""", """e""": """AABAA""", """f""": """AABAB""", """g""": """AABBA""", """h""": """AABBB""", """i""": """ABAAA""", """j""": """BBBAA""", """k""": """ABAA...
709
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 _A ( UpperCAmelCase_ ): def __init__( self : Optional[Any] , lo...
515
0
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutputW...
618
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_tf class...
618
1
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, to...
705
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.kandinsky.text_en...
181
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( _a ): def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ):...
619
import copy import random from transformers import CLIPTokenizer class __SCREAMING_SNAKE_CASE ( _a ): def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): super().__init__(*__lowerCAmelCase , **__lowerCAmelCase ) UpperCamelCase__ ...
619
1
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone...
553
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def UpperCA...
553
1
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_av...
479
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 _a : ...
479
1
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def snake_case ( lowerCamelCase ): '''simple docstring''' return input_array.reshape((input_array.size, 1) ) def snake_case...
53
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' if (ksize % 2) ...
53
1
"""simple docstring""" def lowercase ( __UpperCamelCase ) -> int: __magic_name__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def lowercase ( __UpperCamelCase ) -> int: __magic_name__ = 0 while number > 0: __magic_name__ = number % 10 sum_of...
490
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __lowerCamelCase = logging.get_logger(__name__) class _lowercase ( __UpperCAmelCase ): def __init__( self , *UpperCamelCase_ , **Up...
490
1
"""simple docstring""" import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_avail...
719
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if ...
200
0
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...ut...
68
def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> int: if not isinstance(_snake_case , _snake_case ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for divisor i...
2
0
'''simple docstring''' from __future__ import annotations from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self , __lowerCAmelCase ): UpperCamelCase__ = num_of_nodes UpperCamelCase__ = [] UpperCa...
707
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Co...
548
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 lowerCAmelCase__ ( unittest.TestCase ): """simple docstring""" ...
575
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if ...
575
1
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor _snake_case = logging.get_logger(__name__) class lowerCAmelCase ( lowercase_ ): def __init__( self :Optional[int] , *_lowercase :Tuple , ...
611
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 lowerCAmelCase ( lowercase_ ): __lowerC...
611
1
'''simple docstring''' import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging lowerCamelCase : str = logging.get_logger(__name__...
405
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowerCAmelCase = (7_2_0, 1_2_8_0) # Height, Width _lowerCAmelCase = (0.4, 0.6) # if height or width lower than this scale, drop ...
161
0
from __future__ import annotations class lowerCamelCase_ : def __init__( self , _SCREAMING_SNAKE_CASE=None ): a_ = data a_ = None def __repr__( self ): a_ = [] a_ = self while temp: ...
705
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers....
403
0
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding,...
73
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=a_ ) class lowerCAmelCase_ ( a_ ): __UpperCAmelCase = field(default='imag...
349
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_image_inputs if is_torch_availab...
461
'''simple docstring''' import functools from typing import Any def __a ( __lowerCamelCase : str , __lowerCamelCase : list[str] ) -> bool: '''simple docstring''' if not isinstance(__lowerCamelCase , __lowerCamelCase ) or len(__lowerCamelCase ) == 0: raise Value...
461
1
import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput snake_case = logging.getLogger(__name__) if is_torch_tpu_available(check_device=False)...
62
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
0
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_available(): import torch if is_t...
711
'''simple docstring''' import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCAmelCase_ ( snak...
343
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a__ : Optional[int] = logging.get_logger(__name__) def __snake_case ( SCREAMING_SNAKE_CA...
51
snake_case = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import ArrayaD, ArrayaD, ArrayaD, ArrayaD, ClassLab...
424
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class _lowerCamelCase : """simple docstring""" def __init__( self , _SCREAMING_SNAKE_CASE )->Dict: '''simple docstring''' A_ : Any = data ...
152
# 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 t...
152
1
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# __lowerCAmelCase = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weight", "tim...
536
'''simple docstring''' import math import qiskit def __UpperCamelCase ( lowercase_ : int = 1 , lowercase_ : int = 1 , lowercase_ : int = 1 ): """simple docstring""" if ( isinstance(lowercase_ , lowercase_ ) ...
536
1
'''simple docstring''' from math import factorial def UpperCAmelCase_ ( lowercase__ = 2_0 ) -> List[Any]: '''simple docstring''' a_ =2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... a...
708
'''simple docstring''' from collections.abc import Generator def UpperCAmelCase_ ( ): '''simple docstring''' a_ , a_ =0, 1 while True: a_ , a_ =b, a + b yield b def UpperCAmelCase_ ...
41
0
'''simple docstring''' 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, ) _UpperCamelCase : str = { 'con...
284
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import Bat...
434
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
288
from math import isclose, sqrt def lowerCAmelCase_ (lowercase__ : float , lowercase__ : float , lowercase__ : float ) -> tuple[float, float, float]: '''simple docstring''' lowerCAmelCase__ = point_y / 4 / point_x low...
288
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSp...
33
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class SCREAMING_SNAKE_CASE (pl.LightningModule ): def __init__( self : Optional[Any] , a : Any )-...
235
0
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def lowercase ( lowerCAmelCase : Optional[int]): """simple docstrin...
716
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class lowerCamelCase__ ( snake_case_ ): """simple docstring""" def __init__( self ) -> List[str]: # test for the above condition self.test() def _lowerCamelCas...
417
0
from collections.abc import Callable class snake_case__ : '''simple docstring''' def __init__( self , a__ = None ) -> None: '''simple docstring''' __snake_case :list = [] #...
455
from __future__ import annotations class snake_case__ : '''simple docstring''' def __init__( self , a__ ) -> None: '''simple docstring''' __snake_case :str = order # a_{0...
455
1
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, ...
705
from __future__ import annotations import math from collections.abc import Callable def UpperCamelCase__( UpperCamelCase__ : Callable[[int | float], int | float] , UpperCamelCase__ : int | float , UpperCamelCase__ : int | float , UpperCamelCase__ : int = 1_00 , )->flo...
212
0
from functools import reduce a_ :Optional[Any] = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '6689664895044524452316...
35
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tens...
35
1
import gc import threading import time import psutil import torch class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : str ): snake_case__ : List[str] = psutil.Process() snake_case__ : int = False de...
25
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def SCREAMING_SNAKE_CASE ( snake_case_ : Dataset , snake_case_ : Dict[str, str] ...
25
1
"""simple docstring""" def lowerCamelCase ( _snake_case ,_snake_case ,_snake_case ,_snake_case ): # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vertex is not already in path...
110
'''simple docstring''' import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu,...
41
0
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black _a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is the...
705
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_atten...
29
0
import pytest import datasets # Import fixture modules as plugins UpperCAmelCase__ = ['tests.fixtures.files', 'tests.fixtures.hub', 'tests.fixtures.fsspec'] def a_ (__A , __A ) -> Optional[Any]: """simple docstring""" # Mark tests as "unit" by defau...
351
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: List[str] = logging.get_logger(__name__) lowerCAmelCase: Union[str, Any] = { 'SCUT-DLVCLab/lilt-roberta-en-base': ( 'https://huggingface.co/SCUT-DLVCLab/lilt-rob...
526
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, res...
280
'''simple docstring''' import qiskit def a ( __a , __a ) -> qiskit.result.counts.Counts: '''simple docstring''' UpperCamelCase__ :int = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register U...
280
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Union[str, Any] = logging.get_logger(__name__) _a : str = { "microsoft/git-base": "https://huggingface.co/microsoft...
56
'''simple docstring''' 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_mo...
90
0
'''simple docstring''' from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def _lowerCAmelCase( ) -> List[str]: lowerCAmelCase__ = 9, 14 # noqa: F841 lowerCAmelCase__ = [ [0, 1, 4]...
704
'''simple docstring''' from sklearn.metrics import fa_score import datasets _UpperCamelCase = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ _UpperCamelCase = ...
211
0
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase_ ( UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ ): # Initialise PyTorch model lo...
412
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.tes...
412
1
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 transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def UpperCAmelCase__ ( lowercase__ ) -> Tuple:...
718
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_comm...
634
0
'''simple docstring''' def snake_case ( snake_case : list , snake_case : list ) -> float: """simple docstring""" _validate_point(__lowercase ) _validate_point(__lowercase ) if len(__lowercase ) != len(__lowercase ): raise ValueError('Both points must be...
284
'''simple docstring''' import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( ...
399
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 __UpperCAmelCase = object() # For specifying empty leaf dict `{}` __UpperCAmelCase = obj...
692
'''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_utils import require_vision...
692
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_git": ["GIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GitConfig", "GitVisionConfig"], "processing_git": ["GitProcessor"], } try: if not is_torch_avail...
59
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
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 __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''g...
704
import re def __magic_name__ ( lowerCAmelCase_): '''simple docstring''' if len(re.findall("[ATCG]" , lowerCAmelCase_)) != len(lowerCAmelCase_): raise ValueError("Invalid Strand") return dna.translate(dna.maketrans("ATCG" , "TAGC")) if __name__ == "__main__...
73
0
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def a ( lowerCamelCase__ ): '''simple docstring''' if not sentence: return "" A_ : Union[str, Any] = dict(zip(lowerCamelCase__ , lowerCamelCase__ ) ) return lower_to_u...
667
'''simple docstring''' import math from collections.abc import Callable def a ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): '''simple docstring''' A_ : float = xa A_ : float = xa while True: if x_n == x_na or function(lowerCamel...
667
1
'''simple docstring''' import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _lowerCAmelCase ( __a ) -> Any: '''simple docstring''' ...
712
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=__snake_case ): __UpperCAmelCase = ["""torch""", """scipy"""] def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ ) -> Tuple: ...
512
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase_) class UpperCAmelCase__ ( UpperCAmelCase_): __SCREAMING_SNAKE_CASE = f...
601
'''simple docstring''' from __future__ import annotations def _lowercase ( __A ,__A ,__A ,__A ,__A ,): '''simple docstring''' __UpperCamelCase = len(__A ) # If row is equal to the size of the board it means there are a queen in each row in ...
601
1
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class _UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): ...
721
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _U...
558
0