code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import os import sys import unittest lowercase_ = 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_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dum...
470
'''simple docstring''' import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor lowerCAmelCase_ : Optional[int] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" ...
692
0
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_common import Backbo...
287
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _lowerC...
692
0
"""simple docstring""" import os from distutils.util import strtobool def __lowercase ( _a , _a ): for e in env_keys: snake_case_ : Union[str, Any] = int(os.environ.get(_a , -1 ) ) if val >= 0: return val return defau...
123
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ : Any = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tok...
692
0
A = { "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0, ...
544
'''simple docstring''' import gc import threading import time import psutil import torch class __SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : List[Any] ): _a = psutil.Process() _a = False def ...
692
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import loa...
371
'''simple docstring''' import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" __a =(DDIMParallelScheduler,) __a =(('eta', 0.0), ('num_inference_s...
692
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase_ : Optional[Any] = { 'configuration_vision_encoder_decoder': ['VisionEncoderDecod...
304
'''simple docstring''' from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _lowerCamelCase ( lowercase : Any ) -> List[str]: return getitem, k def _lowerCamelCase ( lowercase : Opt...
692
0
SCREAMING_SNAKE_CASE__ : Optional[int] = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager imp...
79
'''simple docstring''' import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __SCREAMING_SNAKE_CASE (lowerCamelCase_ , unittest.TestCase ): """s...
692
0
"""simple docstring""" from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) # TODO Update this __A = { 'facebook/esm-1b': 'https://hugging...
93
'''simple docstring''' import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as ...
692
0
"""simple docstring""" lowerCAmelCase__ = range(2, 20 + 1) lowerCAmelCase__ = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ = {} def snake_case_ ( A_ : Tuple, A_ : Union[str, Any], A_ : Union[str, Any],...
83
'''simple docstring''' import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowerCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docst...
692
0
'''simple docstring''' from __future__ import annotations A_ = [True] * 1000001 A_ = 2 while i * i <= 1000000: if seive[i]: for j in range(i * i, 1000001, i): A_ = False i += 1 def UpperCamelCase__ ( __SCREAMING_SNAKE_CASE )...
270
'''simple docstring''' from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddin...
692
0
"""simple docstring""" import math def a ( __UpperCAmelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all...
96
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : """simple docstring""" __a =42 __a =42 class __SCREAMING_SN...
692
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""" UpperCamelCase_ : List[Any] = (KDPMaDiscre...
470
'''simple docstring''' 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 ...
692
0
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXT...
287
'''simple docstring''' import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration lowerCAmelCase_ : List[Any] = [ # tf -> hf ('/', '.'), ('layer_',...
692
0
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __lowercase ( _a ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org/wiki/CJK_Unified_Ideograph...
123
'''simple docstring''' def _lowerCamelCase ( lowercase : str , lowercase : list[str] ) -> str: _a = "" for word_or_phrase in separated: if not isinstance(lowercase , lowercase ): raise Exception("join() accepts only str...
692
0
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup A = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2col_cuda.cuh', 'models/grapho...
544
'''simple docstring''' lowerCAmelCase_ : Optional[Any] = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' lowerCAmelCase_ : List[Any] =...
692
0
from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase( lowerCamelCase_ ): def __init__( self : Optional[int] , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : str...
371
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') lowerCAmelCase_ : Optional[Any] = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]...
692
0
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A__( __lowerCAmelCase ): ...
304
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets lowerCAmelCase_ : Optional[Any] = datasets.logging.get_logger(__name__) lowerCAmelCase_ : ...
692
0
import os def _lowerCamelCase ( __lowerCamelCase = "input.txt" ) -> int: '''simple docstring''' with open(os.path.join(os.path.dirname(__lowerCamelCase ) , __lowerCamelCase ) ) as input_file: UpperCAmelCase__ : Optional...
79
'''simple docstring''' import math def _lowerCamelCase ( lowercase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples...
692
0
"""simple docstring""" from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self , __UpperCAmelCase ): '''simple docstring''' lowerCAmelCase__ :List[str] = data lowerCAmelCase__ :Tup...
93
'''simple docstring''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" __a =(CMStochasticIterativeScheduler,) __a =10 def...
692
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowerCAmelCase__ = { 'configuration_trocr': ['TROCR_PRETRAINED_CONFIG...
83
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor lowerCAmelCase_ : Optional[int] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" ...
692
0
from functools import lru_cache def _A ( __snake_case :int ) -> set: """simple docstring""" __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
693
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(IPNDMScheduler,) SCREAMING_SNAKE_CASE__ =(("""num_inference_steps""", 50),...
693
1
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as ...
693
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
1
from __future__ import annotations def _A ( __snake_case :list[int] ) -> list[int]: # This function is recursive """simple docstring""" __SCREAMING_SNAKE_CASE = len(__snake_case ) # If the array contains only one element, we return it (it's the stop cond...
693
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int ) -> np.ndarray: """simple doc...
693
1
def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = [1] __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0, 0, 0 __SCREAMING_SNAKE_CASE = ugly_nums[ia] * 2 __SCREAM...
693
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
1
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse...
693
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 i...
693
1
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __lowerCAmelCase ( self ) -> List[str]: return [ {"col_1": 3, "col_...
693
from __future__ import annotations import math def _A ( __snake_case :int , __snake_case :int , __snake_case :bool , __snake_case :list[int] , __snake_case :float ) -> int: """simple docstring""" if depth < 0: raise ValueError("Depth cannot be les...
693
1
class __SCREAMING_SNAKE_CASE : def __init__( self, _a ) -> str: # we need a list not a string, so do something to change the type __SCREAMING_SNAKE_CASE = arr.split("," ) def __lowerCAmelCase ( self ) -> Optional[Any]: ...
693
def _A ( __snake_case :bytes ) -> str: """simple docstring""" return "".join([hex(__snake_case )[2:].zfill(2 ).upper() for byte in list(__snake_case )] ) def _A ( __snake_case :str ) -> bytes: """simple docstring""" if (len(__sna...
693
1
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils ...
693
from functools import lru_cache def _A ( __snake_case :int ) -> set: """simple docstring""" __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
693
1
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant...
693
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _A ( __snake_c...
693
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _A ( __snake_c...
693
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TY...
693
from math import sqrt def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(__snake_case ) + 1 ) ): if n % i == 0 and i != sqrt(__snake_case ): total += i + n // i e...
693
1
# 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 ...
693
def _A ( __snake_case :int , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _A ( __snake_case :float , __snake_case :float , __snake_case :float ) -> float...
693
1
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available ...
693
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_mo...
693
1
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 xopen from ....
693
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _A ( __snake_case :BertModel , __snake_case :str , __snake_case :str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE ...
693
1
def _A ( __snake_case :int ) -> int: """simple docstring""" if n == 1 or not isinstance(__snake_case , __snake_case ): return 0 elif n == 2: return 1 else: __SCREAMING_SNAKE_CASE = [0, 1] for i in range(2 , n + 1 ): seq...
693
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _snake_case : str = logging.get_logge...
693
1
# Imports import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self, _a=None, _a=None, _a=None, _a=None, _a=None ) -> List[Any]: self.set_matricies(red=_a, green=_a, blue=_a, red_edge=_a, nir=_a ) def __lowerCAmelCase ...
693
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_...
693
1
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Be...
693
def _A ( __snake_case :int = 400_0000 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = [] __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__snake_case ) __SCRE...
693
1
import math from collections.abc import Callable def _A ( __snake_case :Callable[[float], float] , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" __SCREAMING_SNAKE_CASE = xa __SCREAMING_SNAKE_CASE = xa whil...
693
from __future__ import annotations _snake_case : str = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _snake_case : Optional[int] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def _A ( __snake_case :list[float] ) ...
693
1
def _A ( __snake_case :int ) -> int: """simple docstring""" 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 div...
693
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self, _a ) -> Any: __SCREAMING_SNAKE_CASE = data __SCREAMING_SNAKE_CASE = None def __repr__( self ) -> str: return f'''Node({self.da...
693
1
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
693
import argparse import json from tqdm import tqdm def _A ( ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__snake_case , defau...
693
1
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self, _a ) -> Any: __SCREAMING_SNAKE_CASE = data __SCREAMING_SNAKE_CASE = None def __repr__( self ) -> str: return f'''Node({self.da...
693
def _A ( __snake_case :int = 10**9 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 while peri...
693
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_f...
693
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast...
693
1
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xform...
693
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(IPNDMScheduler,) SCREAMING_SNAKE_CASE__ =(("""num_inference_steps""", 50),...
693
1
def _A ( __snake_case :list[int] ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) __SCREAMING_SNAKE_CASE = sum(__snake_case ) / len(__snake_case ) # Calculate the average retu...
693
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
1
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, SkipDat...
693
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int ) -> np.ndarray: """simple doc...
693
1
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _snake_case : Any = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : List[str] = logging.get_logger(__name__) _snake_case : Tuple = {} class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ ...
693
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 i...
693
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_mo...
693
from __future__ import annotations import math def _A ( __snake_case :int , __snake_case :int , __snake_case :bool , __snake_case :list[int] , __snake_case :float ) -> int: """simple docstring""" if depth < 0: raise ValueError("Depth cannot be les...
693
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer _snake_case : str = logging.get_logger(__name__)...
693
def _A ( __snake_case :bytes ) -> str: """simple docstring""" return "".join([hex(__snake_case )[2:].zfill(2 ).upper() for byte in list(__snake_case )] ) def _A ( __snake_case :str ) -> bytes: """simple docstring""" if (len(__sna...
693
1
import os import string import sys _snake_case : Optional[int] = 1 << 8 _snake_case : List[Any] = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLA...
693
from functools import lru_cache def _A ( __snake_case :int ) -> set: """simple docstring""" __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
693
1
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : List[str] = logging.get_logger(__name__) _snake_case : Dict = {...
693
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _A ( __snake_c...
693
1
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 __SCREAMING_SNAKE_CASE ( unittest.TestCase ): @...
693
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def _A ( __snake_case :Dict , __snake_case :Optional[int]=None ) -> str: """simple docstring""" __SCREAMING_SNAKE_...
693
from math import sqrt def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(__snake_case ) + 1 ) ): if n % i == 0 and i != sqrt(__snake_case ): total += i + n // i e...
693
1
from math import sqrt def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(__snake_case ) + 1 ) ): if n % i == 0 and i != sqrt(__snake_case ): total += i + n // i e...
693
def _A ( __snake_case :int , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _A ( __snake_case :float , __snake_case :float , __snake_case :float ) -> float...
693
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassifi...
693
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_mo...
693
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int ) -> np.ndarray: """simple doc...
693
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _A ( __snake_case :BertModel , __snake_case :str , __snake_case :str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE ...
693
1
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration _snake_case : str = HfArgumentParser(InitializationArguments) _snake_case : Optional[Any] = parser.parse_args()...
693
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _snake_case : str = logging.get_logge...
693
1
def _A ( __snake_case :List[Any] , __snake_case :Dict ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = [1] for i in range(2 , __snake_case ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bou...
693
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_...
693
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : str = logging.get_logger(__name__) _snake_case : Optional[int] = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kinetics...
693
def _A ( __snake_case :int = 400_0000 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = [] __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__snake_case ) __SCRE...
693
1
from math import factorial class __SCREAMING_SNAKE_CASE : def __init__( self, _a, _a ) -> int: __SCREAMING_SNAKE_CASE = real if isinstance(_a, _a ): __SCREAMING_SNAKE_CASE = [1] * rank else: __SCREAMING_SN...
693
from __future__ import annotations _snake_case : str = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _snake_case : Optional[int] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def _A ( __snake_case :list[float] ) ...
693
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Any = logging.get_logger(__name__) _snake_case : Optional[Any] = { 'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json'...
693
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self, _a ) -> Any: __SCREAMING_SNAKE_CASE = data __SCREAMING_SNAKE_CASE = None def __repr__( self ) -> str: return f'''Node({self.da...
693
1
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
import argparse import json from tqdm import tqdm def _A ( ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__snake_case , defau...
693
1
# Algorithm for the pigeonhole sorting def _A ( __snake_case :List[str] ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = min(__snake_case ) # min() finds the minimum value __SCREAMING_SNAKE_CASE = max(__snake_case ) # max() finds ...
693
def _A ( __snake_case :int = 10**9 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 while peri...
693
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_...
693
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast...
693
1
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _snake_case : List[str] = {'UserAgent': UserAgent().random} def _A ( __snake_case :List[Any] ) -> dict: """simple d...
693
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(IPNDMScheduler,) SCREAMING_SNAKE_CASE__ =(("""num_inference_steps""", 50),...
693
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acce...
693
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
1
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _A ( __snake_case :int ) -> Optional[int]: """simple docstring""" def is_in_circle(__snake_case :float , __snake_case :float ) -> bool: ...
693
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int ) -> np.ndarray: """simple doc...
693
1
from math import isqrt def _A ( __snake_case :int ) -> list[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , __snake_case...
693
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
1
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def _A ( __snake_case :Namespace ) -> Any: """simple docstring""" return ConvertCommand( args.model_type , args.tf_checkpoint , args.pyto...
693
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 i...
693
1
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
693
from __future__ import annotations import math def _A ( __snake_case :int , __snake_case :int , __snake_case :bool , __snake_case :list[int] , __snake_case :float ) -> int: """simple docstring""" if depth < 0: raise ValueError("Depth cannot be les...
693
1
def _A ( __snake_case :int , __snake_case :str ) -> List[Any]: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def _A ( __snake_case :Optio...
693
def _A ( __snake_case :bytes ) -> str: """simple docstring""" return "".join([hex(__snake_case )[2:].zfill(2 ).upper() for byte in list(__snake_case )] ) def _A ( __snake_case :str ) -> bytes: """simple docstring""" if (len(__sna...
693
1
def _A ( ) -> Union[str, Any]: """simple docstring""" __SCREAMING_SNAKE_CASE = [] __SCREAMING_SNAKE_CASE = 1 while len(__snake_case ) < 1e6: constant.append(str(__snake_case ) ) i += 1 __SCREAMING_SNAKE_CASE = "".join(__sn...
693
from functools import lru_cache def _A ( __snake_case :int ) -> set: """simple docstring""" __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
693
1
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_mo...
693
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _A ( __snake_c...
693
1
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configurat...
693
from math import sqrt def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(__snake_case ) + 1 ) ): if n % i == 0 and i != sqrt(__snake_case ): total += i + n // i e...
693
1
def _A ( __snake_case :int = 100_0000 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = limit + 1 __SCREAMING_SNAKE_CASE = [0] * limit for first_term in range(1 , __snake_case ): for n in range(__snake_case , __snake_case , __snake_...
693
def _A ( __snake_case :int , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _A ( __snake_case :float , __snake_case :float , __snake_case :float ) -> float...
693
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case : Union[str, Any] = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise Opt...
693
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_mo...
693
1
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _A ( __snake_case :BertModel , __snake_case :str , __snake_case :str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE ...
693
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availab...
693
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _snake_case : str = logging.get_logge...
693
1
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ...
693
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_...
693
1
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel _snake_case : Union[str, Any] = False _snake_case : Union[str, Any] = True _snake_case : Optional[Any...
693
def _A ( __snake_case :int = 400_0000 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = [] __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__snake_case ) __SCRE...
693
1
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engi...
693
from __future__ import annotations _snake_case : str = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _snake_case : Optional[int] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def _A ( __snake_case :list[float] ) ...
693
1
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _A ( __snake_case :Any ) ->...
693
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self, _a ) -> Any: __SCREAMING_SNAKE_CASE = data __SCREAMING_SNAKE_CASE = None def __repr__( self ) -> str: return f'''Node({self.da...
693
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case : Tuple = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
693
import argparse import json from tqdm import tqdm def _A ( ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__snake_case , defau...
693
1
import torch from torch import nn class __SCREAMING_SNAKE_CASE ( nn.Module ): def __init__( self, _a, _a, _a, _a, _a=1, _a=False ) -> str: super().__init__() __SCREAMING_SNAKE_CASE = n_token __SCREAMING_SNAKE_CASE = d_em...
693
def _A ( __snake_case :int = 10**9 ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 while peri...
693
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Tuple = logging.get_logger(__name__) _snake_case : Tuple = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://h...
693
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast...
693
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _snake_case : Optional[Any] = { 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG...
693
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(IPNDMScheduler,) SCREAMING_SNAKE_CASE__ =(("""num_inference_steps""", 50),...
693
1
def _A ( __snake_case :str , __snake_case :str = " " ) -> list: """simple docstring""" __SCREAMING_SNAKE_CASE = [] __SCREAMING_SNAKE_CASE = 0 for index, char in enumerate(__snake_case ): if char == separator: split_words.append(str...
693
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_f...
693
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int , __snake_case :int ) -> np.ndarray: """simple doc...
693
1
from __future__ import annotations from cmath import sqrt def _A ( __snake_case :int , __snake_case :int , __snake_case :int ) -> tuple[complex, complex]: """simple docstring""" if a == 0: raise ValueError("Coefficient 'a' must not be zero." ) __SC...
693
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
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 _A ( __snake_case :dict ) -> tuple: """sim...
693
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 i...
693
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : int = logging.get_logger(__name__) _snake_case : str = { 'google/pix2struct-textcaps-base': ( 'https://h...
693
from __future__ import annotations import math def _A ( __snake_case :int , __snake_case :int , __snake_case :bool , __snake_case :list[int] , __snake_case :float ) -> int: """simple docstring""" if depth < 0: raise ValueError("Depth cannot be les...
693
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
693
def _A ( __snake_case :bytes ) -> str: """simple docstring""" return "".join([hex(__snake_case )[2:].zfill(2 ).upper() for byte in list(__snake_case )] ) def _A ( __snake_case :str ) -> bytes: """simple docstring""" if (len(__sna...
693
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from .....
693
from functools import lru_cache def _A ( __snake_case :int ) -> set: """simple docstring""" __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
693
1
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def _A ( ) -> str: """simple docstring""" raise RuntimeError("CUDA out of memory." ) ...
693
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _A ( __snake_c...
693
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _snake_case : int = [ # tf -> hf ('/', '.'), ('layer_', 'layers.'), ('kernel...
693
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
1
from ..utils import DummyObject, requires_backends class __SCREAMING_SNAKE_CASE ( metaclass=__SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =["""keras_nlp"""] def __init__( self, *_a, **_a ) -> int: requires_backends(self, ["keras_nlp"] )
693
from math import sqrt def _A ( __snake_case :int ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(__snake_case ) + 1 ) ): if n % i == 0 and i != sqrt(__snake_case ): total += i + n // i e...
693
1
from math import factorial def _A ( __snake_case :int , __snake_case :int , __snake_case :float ) -> float: """simple docstring""" if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes < 0: ...
693
def _A ( __snake_case :int , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _A ( __snake_case :float , __snake_case :float , __snake_case :float ) -> float...
693
1
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_cards ...
693
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_mo...
693
1
def _A ( __snake_case :List[str] ) -> Dict: # noqa: E741 """simple docstring""" __SCREAMING_SNAKE_CASE = len(__snake_case ) __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = [0] * n __SCREAMING_SNAKE_CASE = [False] * n __SCR...
693
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _A ( __snake_case :BertModel , __snake_case :str , __snake_case :str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE ...
693
1