code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def a__ ( UpperCAmelCase : str ) -> str: return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
336
from __future__ import annotations def a__ ( UpperCAmelCase : list[list[int]] ) -> bool: UpperCAmelCase : Union[str, Any] = len(UpperCAmelCase ) # We need to create solution object to save path. UpperCAmelCase : int = [[0 for _ in range(UpperCAmelCase )] fo...
336
1
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( UpperCAmelCase : list[float] , UpperCAmelCase : list[float] ): '''simple docstring''' UpperCamelCase__ : List[str] =sorted(numsa + numsa ) UpperCamelC...
157
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Union[str, Any] = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/reso...
157
1
'''simple docstring''' from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import float...
331
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _lowerCamelCase ( unittest.TestCas...
331
1
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...tes...
114
'''simple docstring''' from math import factorial def _lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : float ) -> float: """simple docstring""" if successes > trials: raise ValueError('successes mu...
114
1
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipe...
298
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowercase_ ( unittest.TestCase ): ...
338
0
"""simple docstring""" from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class UpperCamelCase_ ( UpperCamelCase): ""...
359
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' print(f"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(lowerCAmelCase_ ): prin...
195
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Optional[int] = { "configuration_mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegaConfig", "Mega...
93
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase__ : def __init__( self ): """simple docstring""" lowercase_ : int = ...
93
1
'''simple docstring''' import qiskit def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : List[str] = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register _UpperCAmelCase : Tuple = qiskit....
369
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-la...
322
0
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase ): if n == 1 or not isinstance(_UpperCamelCase , _UpperCamelCase ): return 0 elif n == 2: return 1 else: __lowerCAmelCase : Optional[int] = [0, 1] for i in range(2 , n + 1 ): sequence.append(se...
86
"""simple docstring""" import math import sys def __lowerCAmelCase (_UpperCamelCase ): if number != int(_UpperCamelCase ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the value of input must not be a negative number' ) if number == 0: ret...
86
1
'''simple docstring''' 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 Flax...
365
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _lowerCAmelCase ( _UpperCamelCase : int ) -> bool: """simple docstring""" _SCREAMING_SNAKE_CASE =int(number**0.5 ) return number == sq * s...
114
0
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class snake_case...
277
from __future__ import annotations class A : def __init__(self : Union[str, Any] , __UpperCAmelCase : list[list[int]] ) -> List[str]: """simple docstring""" UpperCAmelCase__ = TypeError( "Matrices must be for...
65
0
def A ( _lowercase = 600_851_475_143 ): try: SCREAMING_SNAKE_CASE : Optional[Any] = int(_lowercase ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ) if n <= 0: ...
258
from typing import Union import fire import torch from tqdm import tqdm def A ( _lowercase , _lowercase = "cpu" , _lowercase = None ): SCREAMING_SNAKE_CASE : Optional[int] = torch.load(_lowercase , map_location=_lowercase ) for k, v in tqdm(state_dict...
258
1
"""simple docstring""" import re def UpperCAmelCase ( UpperCAmelCase ) -> str: if len(re.findall('[ATCG]' , __lowercase ) ) != len(__lowercase ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ...
69
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin ...
319
0
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCAmelCase( SCREAMING_SNAKE_CASE_ = "" )-> dict[str, float]: """simple docstring""" UpperCamelCase_ = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" ...
60
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, Diff...
60
1
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAM...
157
def _UpperCamelCase ( snake_case__ ) -> list: __UpperCAmelCase : Dict = [0] * len(snake_case__ ) for i in range(1, len(snake_case__ ) ): # use last results for better performance - dynamic programming __UpperCAmelCase ...
157
1
def lowerCAmelCase__ ( a__: int = 1_0_0 ) -> int: '''simple docstring''' _UpperCAmelCase = set() _UpperCAmelCase = 0 _UpperCAmelCase = n + 1 # maximum limit for a in range(2 , a__ ): for b in range(2 , a__ )...
185
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCAmelCase__ :Tuple = argparse.ArgumentParser( description=( '''Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned''' ''' ...
185
1
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...model...
309
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class snake_case_ ( unittest.TestCase ): @require_to...
87
0
from __future__ import annotations from collections.abc import Iterator from typing import Any class lowerCAmelCase : def __init__( self : List[str] , UpperCAmelCase : Union[str, Any] ) -> Union[str, Any]: lowerCamelCase__ : Any = data lowerCamel...
350
from __future__ import annotations def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , ) -> None: lowerCamelCase__ : Optional[Any] = len(_UpperCAmelCase ) # If row is eq...
45
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCamelCase : List[Any] = logging...
77
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''xlnet-large-cased''': '''https://h...
195
0
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common impo...
130
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import Tok...
130
1
"""simple docstring""" SCREAMING_SNAKE_CASE__ = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import Stream...
150
"""simple docstring""" from sklearn.metrics import fa_score import datasets A__ : List[str] = '\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' A__ : List[Any] = ...
144
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { '''facebook/data2vec-text-base''': '''https://huggingface.co/data2ve...
361
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
277
0
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset __lowerCamelCase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: ...
18
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils i...
114
0
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, resize, to_channel_dimen...
223
def A__ ( lowerCamelCase ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowerCamelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("""doctest""").testmod()
223
1
'''simple docstring''' from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class __UpperCAmelCase ( A__ ): '''simple docstring''' def __lt__(self : Tuple , _lowerCAmelCase...
258
'''simple docstring''' 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_unord...
258
1
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants a_ = Mapping[str, np.ndarray] a_ = Mapping[str, Any] # Is a nested dict. a_ = ...
222
'''simple docstring''' def _a( UpperCamelCase__ : Optional[Any]=2_8_1_2_3 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[Any] =[1] * (limit + 1) for i in range(2, int(limit**0.5 ) + 1 ): sum_di...
222
1
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case_...
60
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() snake_cas...
60
1
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from i...
361
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case__ : ...
250
0
from typing import Any class A__: """simple docstring""" def __init__( self , _lowercase ) -> List[str]: a_ : List[str] = data a_ : Optional[int] = None def __repr__( self ) -> str: return F'''Node({self...
248
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) __snak...
248
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A , __A ) -> List[Any]: _snake_case = [0 for i in range(r + 1 )] # nc0 = 1 _snake_case = 1 for i in range(1 , n + 1 ): # to compute current row from previous row. _snake_ca...
352
'''simple docstring''' 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 __UpperCAmelCase ( unittest.TestCase ...
160
0
"""simple docstring""" def A_ ( _lowercase = 3, _lowercase = 7, _lowercase = 1000000 ): '''simple docstring''' snake_case_ :List[Any] = 0 snake_case_ :Any = 1 for current_denominator in range(1, limit + 1 ): snake_case_ :int = curr...
66
"""simple docstring""" def lowercase ( lowerCAmelCase__ : str ) -> list: if n_term == "": return [] __a = [] for temp in range(int(lowerCAmelCase__ ) ): series.append(f'''1/{temp + 1}''' if series else '''1''' ) return series if __name...
45
0
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class UpperCamelCase : lowercase = 42 # [batch_size x 3] lowercase = 42 # [batch_size x 3] lowercase = 42 # [batch_size x 3] lowercase =...
321
"""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...
321
1
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, ...
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available __A = { "configuration_audio_spectrogram_transformer": [ "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ASTConfig...
90
0
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerat...
347
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 100 * 2**20, 900 * 2...
347
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchF...
165
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Dict = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerC...
165
1
'''simple docstring''' import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever snake_case_ : str = logging.getLogger(__name__) class lowercase__ ( lowercase ...
236
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case_ : Any = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization_mvp'...
236
1
'''simple docstring''' import numpy class UpperCamelCase__ : def __init__( self :Tuple , _A :numpy.ndarray , _A :numpy.ndarray ) -> None: '''simple docstring''' __A = input_array # Random initial weights are assi...
161
'''simple docstring''' import unittest from transformers import XLMConfig, 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_model...
161
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config...
193
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class UpperCamelCase__ ( lowerCAmelCase...
193
1
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torc...
141
'''simple docstring''' def __UpperCamelCase ( lowercase__ : str, lowercase__ : bool = False ): '''simple docstring''' if not isinstance(lowercase__, lowercase__ ): __lowercase =F'''Expected string as input, found {type(lowercase__ )}''' ...
141
1
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torc...
93
import logging from transformers import PretrainedConfig lowerCAmelCase = logging.getLogger(__name__) lowerCAmelCase = { 'bertabs-finetuned-cnndm': 'https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json', } class _a ...
93
1
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import...
25
import requests from bsa import BeautifulSoup def UpperCamelCase ( lowerCAmelCase__ = "https://www.worldometers.info/coronavirus" ): '''simple docstring''' lowercase = BeautifulSoup(requests.get(lowerCAmelCase__ ).text , '''html.parser''' ) lowercase = soup....
101
0
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __lowercase = 0 __lowercase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0,...
105
from __future__ import annotations def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ): '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 valu...
105
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __A : List[Any] ...
120
'''simple docstring''' def UpperCamelCase_ ( A__ : int ): '''simple docstring''' lowerCAmelCase_ : Union[str, Any] = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def UpperCamelCase_ ( A__ : int = 50_00 ): ''...
120
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @req...
351
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import x...
21
0
"""simple docstring""" from __future__ import annotations import math def lowercase (snake_case__ : list , snake_case__ : list ) -> list: '''simple docstring''' if len(snake_case__ ) != 2 or len(a[0] ) != 2 or len(snake_cas...
155
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import To...
155
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
368
from typing import Any class a : def __init__( self , A_ ): '''simple docstring''' _UpperCAmelCase : List[Any] = data _UpperCAmelCase : Any = None class a : def __init__( self ): ...
189
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
9
from __future__ import annotations from cmath import sqrt def _a ( UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : int ) -> tuple[complex, complex]: """simple docstring""" if a == 0: raise ValueError("Coefficient...
340
0
from ... import PretrainedConfig __A = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = NEZHA_PRETRAINED_CONFIG_ARCHIVE_...
273
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE , unittest.TestCase ): '''simple do...
273
1
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowerCamelCase_ ( lowerCamelCase__ ): return (data["data"], data["targ...
19
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _SCREAMING_SNAKE_CASE = models.Sequential() # Step 1 -...
343
0
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_at...
145
from collections import defaultdict from math import ceil, sqrt def lowercase__ ( __snake_case : int = 1_000_000 , __snake_case : int = 10 ): '''simple docstring''' UpperCAmelCase_ : defaultdict = defaultdict(__snake_case ) ...
145
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.test_utils...
169
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class _UpperCamelCase ( lowerCAmelCase...
169
1
'''simple docstring''' from __future__ import annotations def a ( __a ) -> bool: '''simple docstring''' UpperCamelCase__ :Tuple = len(__a ) # We need to create solution object to save path. UpperCamelCase__ :List[str] = [[0 f...
219
'''simple docstring''' from __future__ import annotations __snake_case = [True] * 1000001 __snake_case = 2 while i * i <= 1000000: if seive[i]: for j in range(i * i, 1000001, i): __snake_case = False i += 1 def a ( __a ) -> bool: ...
219
1
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() lowercase = logging.get_logger(__name__) ...
178
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def __UpperCAmelCase ( a_ , a_ , a_ , a_ , a_): snake_case_ = np.array([[...
178
1
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A_ :List[str] = { '''facebook/mask2former-swin-small-coco-instance''': ( '''https://huggingface.co/face...
245
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A_ :List[str] = { '''facebook/mask2former-swin-small-coco-instance''': ( '''https://huggingface.co/face...
245
1
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as ...
105
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class __UpperCamelCase : def __init__( self , lowerCAmelCase__ ) -> Optional[int]: a : List[str] = str(id_ ) a : Opti...
105
1
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_com...
366
lowerCamelCase : Optional[int] ={ '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } ...
196
0
UpperCAmelCase__ = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def _a ( a :int ) -> int: a = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared += DIGITS_SQUARED[number % 100_000] n...
0
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass SCREAMING_SNAKE_CASE : Tuple = (3, 9, -11, 0, 7, 5, 1, -1) SCREAMING_SNAKE_CASE : Union[str, Any] = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _lowe...
21
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowercase__ :List[str] = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu a...
97
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ra...
97
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase :List[Any] = { '''configuration_megatron_bert''': ['''MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegatronBertConfig'''], } try: ...
331
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import requ...
331
1
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a__: int = get_tests_dir('fixtures/spiece.model...
39
def UpperCamelCase__( UpperCamelCase__ : int , UpperCamelCase__ : int )->float: return base * power(UpperCamelCase__ , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') a__:...
39
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''camembert-base'...
97
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __snake_case = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
97
1
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_...
235
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from ...tes...
235
1
from __future__ import annotations def lowerCamelCase__ ( A__ : int , A__ : int ): '''simple docstring''' __lowerCamelCase = [] create_all_state(1 , A__ , A__ , [] , A__ ) return result def lowerCamelCase__ ...
12
from math import factorial def A_ ( snake_case : int = 100 ) -> int: '''simple docstring''' return sum(int(snake_case ) for x in str(factorial(snake_case ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: "...
328
0
'''simple docstring''' from __future__ import annotations from collections.abc import Generator def __UpperCamelCase ( ): lowercase__ : Optional[int] = {} lowercase__ : Optional[int] = 2 while True: lowercase__ : Optional[int] = factor_map.pop(UpperCAmelCase_ , Uppe...
353
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] )...
214
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case ={ """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], ...
4
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class SCREAMING_SNAKE_CASE__ ( tf.keras.optimizers.schedules.LearningRateSchedule ...
116
0
'''simple docstring''' 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 .token...
18
'''simple docstring''' 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...
18
1
'''simple docstring''' from math import sqrt def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int = 1000000 ) -> int: UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int while num_cuboids <= limit: ...
125
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.config...
125
1
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class UpperCAmelCase_ ( __lowercase , __lowercase ): @regist...
55
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
1
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCAmelCase : Dict...
237
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def UpperCamelCase ( _lowerCamelCase : list[list[float]] ): A__ = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implem...
237
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_perceiver": ["PERCEIVER_PRETRAI...
358
from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Optional[Any] = { "alibaba-damo/mgp-str-base": "https://huggingface.co/alibaba-damo/mgp-str-base/re...
213
0
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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_co...
122
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 @require_sentencepiece @slow # see ht...
122
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class SCREAMING_SNAKE_CASE__ ( unittest.T...
361
from math import sqrt def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00_00_00 ): __UpperCamelCase : int = 0 __UpperCamelCase : int = 0 __UpperCamelCase : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_si...
171
0
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UN...
39
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.traini...
39
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_avail...
26
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase__ = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "De...
26
1
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split A__: Any = datasets.load_iris() A__: int = np.array(data['''data''']) A__: str = np.array(data['''target''']) A__: str ...
149
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCamelCase ( A ): ...
166
0
'''simple docstring''' import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __snake_case( _lowerCAmelCase ): '''simple docstring''' UpperCAmelCase : List[str] ...
187
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as tr...
187
1
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def lowerCAmelCase__ ( low...
129
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline __snake_case : Dict =logging.get_logger(__name__) ...
129
1
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem lowerCamelCase_ = importlib.util.find_spec('''s3fs''') is not None if _has_safs: fro...
371
'''simple docstring''' lowerCamelCase_ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' lowerCa...
174
0
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, logging from .benchmark_...
18
from math import factorial, radians def _snake_case ( lowerCAmelCase : float , lowerCAmelCase : int = 1_8 , lowerCAmelCase : int = 1_0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) ...
18
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCamelCase ( ...
359
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if...
244
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase ) class snake_case ( lowercase ): """simple d...
55
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCase...
55
1
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class a : def __init__( self : Union[str, Any] , __lowerCAmelCase : int , __lowerCAmelCase : MutableSequence[float] ): if len(__lowerCAmelCase ) != degree + 1: ...
30
"""simple docstring""" def __UpperCAmelCase ( lowercase = 10_00 ): """simple docstring""" _UpperCAmelCase = 2**power _UpperCAmelCase = 0 while n: _UpperCAmelCase , _UpperCAmelCase = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input...
30
1
def __A ( __lowerCAmelCase , __lowerCAmelCase )-> float: """simple docstring""" return base * power(__lowerCAmelCase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('''Raise base to the power of exponent using recursion...''') _a ...
39
"""simple docstring""" 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...
213
0
"""simple docstring""" def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): lowercase__ = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ = 100 ): lowercase__ = 1 lowercase__ = ...
366
from pathlib import Path import fire def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) dest_dir.mkdir(exist_ok=SCREAMING_SNAK...
224
0
import os def SCREAMING_SNAKE_CASE_ ( ) -> Dict: """simple docstring""" a_ : Tuple = os.path.dirname(os.path.realpath(__A ) ) a_ : Tuple = os.path.join(__A , 'triangle.txt' ) with open(__A ) as f: ...
32
"""simple docstring""" from typing import TYPE_CHECKING from ..utils import _LazyModule _A = { """config""": [ """EXTERNAL_DATA_FORMAT_SIZE_LIMIT""", """OnnxConfig""", """OnnxConfigWithPast""", """OnnxSeq2SeqConfigWithPast""", """PatchingSpec""", ], """co...
171
0
"""simple docstring""" from math import factorial, pi def UpperCamelCase_ ( lowerCAmelCase__ : float , lowerCAmelCase__ : int = 30 ): """simple docstring""" if not isinstance(lowerCAmelCase__ , (int, float) ): raise ValueError(...
371
"""simple docstring""" from collections.abc import Iterable from typing import Generic, TypeVar lowercase__ : Any = TypeVar("""_T""") class UpperCamelCase__ ( Generic[_T] ): """simple docstring""" def __init__( self ...
289
0
import torch def lowerCAmelCase_ ( ): if torch.cuda.is_available(): _A : Dict = torch.cuda.device_count() else: _A : Union[str, Any] = 0 print(f'''Successfully ran on {num_gpus} GPUs''' ) if __name__ == "__main__": m...
26
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel ...
26
1
"""simple docstring""" from itertools import count def UpperCAmelCase ( a_ = 50 ): '''simple docstring''' lowerCamelCase : Union[str, Any] = [1] * min_block_length for n in count(a_ ): fill_count_functions.append(1 ) for block_length in ra...
205
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json', # ...
205
1
"""simple docstring""" _lowercase = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' _lowercase ...
74
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) de...
227
0
'''simple docstring''' 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...
369
'''simple docstring''' import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): '''simple docstring''' def _UpperCamelC...
274
0
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import require_...
279
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning t...
279
1
def __lowerCamelCase ( __magic_name__ : list , __magic_name__ : list , __magic_name__ : int ): a__: int =len(__magic_name__ ) a__: Optional[int] =[[0] * n for i in range(__magic_name__ )] for i in range(__magic_name__ ): ...
42
def __lowerCamelCase ( __magic_name__ : int ): if not isinstance(__magic_name__ , __magic_name__ ): a__: List[str] =F"Input value of [number={number}] must be an integer" raise TypeError(__magic_name__ ) if number < 1: a__: ...
42
1
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_available(): import j...
13
'''simple docstring''' import math import unittest def snake_case ( UpperCAmelCase )-> bool: """simple docstring""" assert isinstance(UpperCAmelCase , UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and posi...
161
0
from __future__ import annotations def UpperCamelCase ( _a , _a ) -> float: '''simple docstring''' lowercase_ :str = sorted(numsa + numsa ) lowercase_ , lowercase_ :int = divmod(len(_a ) , 2 ) ...
252
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Any = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://hugging...
252
1
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transfor...
30
def a ( snake_case__: int = 100 ): '''simple docstring''' lowercase_ = (n * (n + 1) // 2) ** 2 lowercase_ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(f"{solution() = }")
30
1
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate....
275
'''simple docstring''' from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DD...
275
1
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands fro...
136
"""simple docstring""" UpperCAmelCase : Optional[Any] = tuple[float, float, float] UpperCAmelCase : Optional[Any] = tuple[float, float, float] def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> Vectorad: '''simple docstrin...
136
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class __SCREAMING_SNAKE_CASE ( _a ): snake_case : Dict ...
87
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from ...
87
1
"""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 ...
172
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: '''simple docstring''' while a != 0: __snake_case , __snake_case : Optional[Any] = b % a, a return b def __UpperCAmelCase...
172
1
def _a ( lowerCamelCase: list[int] , lowerCamelCase: list[int] ) -> Union[str, Any]: '''simple docstring''' if not len(lowerCamelCase ) == len(lowerCamelCase ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equatio...
360
from __future__ import annotations from math import pi, sqrt def _a ( lowerCamelCase: float , lowerCamelCase: float ) -> tuple: '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be ...
250
0