code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import to...
30
from __future__ import annotations import math __a = '2020.9.26' __a = 'xcodz-dot, cclaus, dhruvmanila' def lowerCamelCase__ ( _lowercase , _lowercase , _lowercase , _lowercase , _lowercase ): '''simple docstring''' if not all(isinstance(...
30
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) snake_case__ : Tuple = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFI...
702
snake_case__ : List[Any] = """Tobias Carryer""" from time import time class _a : """simple docstring""" def __init__( self , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=int(time() ) ) -> Tuple: # noqa...
618
0
"""simple docstring""" import numpy class lowercase__ : """simple docstring""" def __init__( self , _A , _A ): '''simple docstring''' UpperCamelCase : Dict = input_array ...
102
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast f...
149
0
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class UpperCamelCase__ ( unittest.TestCase ): """simple docstring""" def snake_case ( self : str ): ...
602
'''simple docstring''' import re import string import numpy as np import datasets __magic_name__ : Optional[Any] = ''' Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. ''' __magic_name__ ...
602
1
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
560
"""simple docstring""" lowerCAmelCase_ = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kil...
560
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : List[Any] = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerConfig"...
705
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def Uppe...
441
0
"""simple docstring""" import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _lowerCamelCase ( UpperCAmelCase_ : Optional[int], UpperCAmelCase_ : Tuple, UpperCAmelCase_ : str, UpperCAmelC...
104
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_...
311
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase =logging.get_logger(__name__) lowerCamelCase ={ "sail/poolformer_s12": "https://...
462
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase ={ "configuration_mobilebert": [ "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MobileBertCon...
462
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging log...
88
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) logging...
187
0
"""simple docstring""" from math import factorial, radians def lowercase (snake_case__ : float , snake_case__ : int = 18 , snake_case__ : int = 10 ) -> List[str]: '''simple docstring''' lowerCAmelCase = angle_in_degrees - ((angle_in_degree...
709
"""simple docstring""" 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_...
529
0
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion impo...
130
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __a ( ) -> int: '''simple docstring''' UpperCAmelCase_, UpperCAmelCase_= 9, 14 # noqa: F841 UpperCAmelCase_= [ [0, 1, 4], [0, 7, 8], ...
593
0
import torch def UpperCAmelCase_ ( ) -> Optional[Any]: if torch.cuda.is_available(): __lowercase : Dict = torch.cuda.device_count() else: __lowercase : Optional[Any] = 0 print(F'Successfully ran on {num_gpus} GPUs' ) if __...
718
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from ...
284
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase ={ "configuration_vision_encoder_decoder": ["VisionEncoderDecod...
617
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase__ = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''], } try: ...
41
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.t...
535
def SCREAMING_SNAKE_CASE__ ( snake_case__ :List[str] ) -> Dict: _lowercase = len(snake_case__ ) while cur > 1: # Find the maximum number in arr _lowercase = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi _lowercase = a...
535
1
'''simple docstring''' import math def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = 0 , SCREAMING_SNAKE_CASE_ = 0 ) -> list: """simple docstring""" _SCREAMING_SNAKE_CASE = end or len(SCREAMING_SNAKE_CASE_ ) for i in range(SCREAMING_SNAKE_CASE_ ...
591
'''simple docstring''' import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.model...
591
1
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class UpperCamelCase_ : def _snake_case ( self :Any , __A :Tuple ) -> Optional[Any]: """simple docstring""" r...
59
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list[list[float]] ): SCREAMING_SNAKE_CASE__ = [] for data in source_data: for i, el in enumerate(UpperCamelCase__ ): if len(UpperCamelCase__ ) < i + 1: data_lists.append([] ) data_lists[i].append(fl...
59
1
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase ) -> int: '''simple docstring''' for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in ran...
46
'''simple docstring''' import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers impo...
588
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = {'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']} try: if not is_torch_available(): ...
220
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, req...
220
1
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ (lowerCamelCase__ ): """simple docstring""" SCREAMING_SNAKE_CASE : Dict = (DDPMScheduler,) def SCREAMING_SNAK...
41
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def lowerCamelCase_( ) -> None: '''simple docstring''' print("Making key files..." ) make_key_...
46
0
from __future__ import annotations __UpperCAmelCase : Any = [] def lowercase_ ( __snake_case : list[list[int]] , __snake_case : int , __snake_case : int ) -> bool: '''simple docstring''' for i in range(len(__...
712
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from...
57
0
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from...
23
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 i...
23
1
'''simple docstring''' import re def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> Union[str, Any]: if len(re.findall('[ATCG]' , snake_case_ ) ) != len(snake_case_ ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC...
718
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { """configuration_luke""": ["""LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LukeConfig"""], """tokenization_luke""": ["""LukeTokenizer"""], } try: i...
69
0
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.testi...
519
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance __UpperCamelCase : Optional[Any] = 6_378_137.0 __UpperCamelCase : Any = 6_356_752.314_245 __UpperCamelCase : Optional[int] = 6378137 def _UpperCAmelCase ( Up...
519
1
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin lo...
15
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __snake_case ( __lowerCAmelCase ): '''simple docstring''' _snake_case = (EulerDiscreteScheduler,) ...
15
1
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version _SCREAMING_SNAKE_CASE = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import w...
18
'''simple docstring''' import re import string import numpy as np import datasets _SCREAMING_SNAKE_CASE = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" _SCREAMING_SNAKE_CASE = ...
18
1
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): return getitem, k def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): return setitem, k, v...
706
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase = [ord(letter) for letter in string.ascii_lowercase] Upp...
152
0
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE : Tuple = (CMStochasticIterativeScheduler,) SCREAMING_SNAKE_CASE : Lis...
699
from __future__ import annotations import time lowerCamelCase_ : Union[str, Any] = list[tuple[int, int]] lowerCamelCase_ : str = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0,...
548
0
def __lowerCamelCase (UpperCAmelCase__ : int ): assert isinstance(UpperCAmelCase__ , UpperCAmelCase__ ), F"The input value of [n={number}] is not an integer" if number == 1: return 2 elif number < 1: SCREAMING_SNAKE_CASE = F"The input value o...
647
from __future__ import annotations import math def __lowerCamelCase (UpperCAmelCase__ : int ): 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, al...
647
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils impor...
170
# Copyright (c) 2021-, NVIDIA CORPORATION. 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...
170
1
"""simple docstring""" import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging __UpperCAmelCase = loggin...
713
"""simple docstring""" from ...configuration_utils import PretrainedConfig class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :Tuple = "bert-generation" def __init__( self , __A=5_0358 , __A=1024 , __A=24 , __A=16 , ...
256
0
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowercase_( SCREAMING_SNAKE_CASE_ = "" ): '''simple docstring''' lowerCamelCase : Any = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" lowerCa...
340
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dat...
340
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json'...
712
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _snake_case ...
170
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImga...
123
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_...
123
1
'''simple docstring''' 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 tensorflow as tf from transf...
704
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowerCamelCase__ = 3 def _SCREAMING_SNAKE_CASE( snake_case_ : int ) ->int: '''simple docstring''' ...
411
0
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel UpperCamelCase__ = HfApi() UpperCamelCase__ = {} # fmt: off UpperCamelCase__ = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, ...
322
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class UpperCAmelCase__ ( A_ ): '''simple docstring''' def __init__( self : int , *UpperCamelCase : ...
322
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-large''': ...
702
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging UpperCamelCase_ = loggin...
320
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...im...
630
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffuse...
630
1
def snake_case_ ( lowercase__ : int ): '''simple docstring''' _lowerCAmelCase =[1] _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase =0, 0, 0 _lowerCAmelCase =ugly_nums[ia] * 2 _lowerCAmelCase =ugly_nums[ia] * 3 _lowerCAme...
712
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) # TODO Update this __SCREAMING_SNAKE_CASE : int = { ''...
149
0
import argparse import struct import unittest class snake_case_ : '''simple docstring''' def __init__( self : Union[str, Any] , _UpperCamelCase : bytes ) ->None: snake_case_ = data # Initialize hash values s...
39
'''simple docstring''' 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...
538
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices A_ : Union[str, Any] = logging.get_logger(__name__) A_ : str ...
719
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging A_ : Un...
616
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase : int ={ "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "Chin...
440
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, TokenC...
537
0
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class _lowercase ( A__ ): '''simple docstring''' def __init__( self :List[Any] , lowerCAmelCase__ :Dict , lowerCAmelCase__ ...
260
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _lowercase ( A__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[Any] = (EulerDiscreteScheduler,) SCREAMI...
260
1
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger _a: Dict = get_logger(__name__) _a: int = r"""\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length...
162
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Te...
208
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .va...
700
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ = "cpu" , lowerCamelCase_ = None) -> None: UpperCamelCase__ : List[Any] ...
6
0
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
40
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUE...
468
0
"""simple docstring""" 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 = { '''distilbert-b...
702
"""simple docstring""" from math import ceil, sqrt def lowercase ( __snake_case : int = 1_0_0_0_0_0_0 ): lowercase_ : Tuple = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowercase_ : in...
141
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from...
633
"""simple docstring""" # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def A_ ( snake_case__ ) -> str: return 1 / (1 + np.exp(-z )) def A_ ...
355
0
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...te...
122
"""simple docstring""" import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available...
122
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_distilbert''': [ ...
467
'''simple docstring''' class UpperCAmelCase : def __init__( self : Union[str, Any] ): UpperCAmelCase__ :dict[str, TrieNode] = {} # Mapping from char to TrieNode UpperCAmelCase__ :Union[str, Any] = False def __SCREAMING_SNAKE_CASE ( self :...
467
1
from __future__ import annotations def _lowerCamelCase ( _a ): """simple docstring""" _lowerCamelCase = 0.00 _lowerCamelCase = 0 for resistor in resistors: if resistor <= 0: _lowerCamelCase = F'''Resistor at index {index} has a negative or zero value...
297
from maths.prime_factors import prime_factors def _lowerCamelCase ( _a ): """simple docstring""" if not isinstance(_a , _a ): _lowerCamelCase = F'''Input value of [number={number}] must be an integer''' raise TypeError(_a ) if number < 1: raise ValueError('...
297
1
from typing import TYPE_CHECKING from ..utils import _LazyModule a__ = { '''config''': [ '''EXTERNAL_DATA_FORMAT_SIZE_LIMIT''', '''OnnxConfig''', '''OnnxConfigWithPast''', '''OnnxSeq2SeqConfigWithPast''', '''PatchingSpec''', ], '''c...
14
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowercase__( A ): if "model" in orig_key: snake_case__ : Any = orig_key.replace('model.' , '' ) if "norm1" in orig_key: snake_case__ : Optional...
170
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __snake_case =logging.get_logger(__name__) __snake_case ={ """microsoft/fo...
513
'''simple docstring''' def a_ ( lowerCamelCase : Tuple , lowerCamelCase : Tuple ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) lowerCAmelCase = (boundary[1] - boundary[0]) / steps lowerCAmelCase = boundary[0] lowerCAmelCase...
513
1
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase ( lowerCamelCa...
105
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class _a ( A__ ): """simple docstring""" snake_case ="""EncodecFeatureExtractor""" snake_case =("""T5Tokenizer""", """T5TokenizerF...
408
0
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. a :Union[str, Any] = 10 def _lowercase ( __lowerCAmelCase , __lowerCAmelCase...
709
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a :Optional[Any] = logging.get_logger(__name__) a :Union[str, Any] = { "t5-small": "https://huggingface.co/t5-small/r...
12
0
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class snake_case_ : '''simple docstring''' __UpperCamelCase = None __UpperCamelCase = False __UpperCamelCase = False __UpperCamelCase = False __UpperCamelCase ...
375
def SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case , snake_case ) -> int: # Return True if there is node that has not iterated. __lowercase = [False] * len(snake_case ) __lowercase = [] queue.append(snake_case ) ...
375
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """fac...
45
from PIL import Image def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Image: def brightness(_SCREAMING_SNAKE_CASE ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError('level must be between ...
45
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects import ...
339
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization...
339
1
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is j...
113
'''simple docstring''' import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) __A =logging.getLogger() ...
113
1
def lowerCAmelCase_ ( _lowercase : Tuple , _lowercase : Union[str, Any]) -> float: """simple docstring""" _validate_point(a__) _validate_point(a__) if len(a__) != len(a__): raise ValueError("""Both points must be in the same n-dimensional space"...
136
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class __A( unittest.TestCas...
219
0
'''simple docstring''' from __future__ import annotations from collections.abc import Generator def lowerCamelCase__ ( ): '''simple docstring''' UpperCAmelCase = {} UpperCAmelCase = 2 while True: UpperCAmelCase = factor_map.pop(A ...
711
'''simple docstring''' # Copyright 2023 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 # #...
50
0
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def a (lowerCAmelCase__ = "isbn/0140328726" ): __a = olid.strip().strip("""/""" ) # Remove leading/trailing whitespace & slashes if new_olid.count("""/""" ) != 1: __a ...
99
import warnings from ..trainer import Trainer from ..utils import logging _SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) class A ( lowerCamelCase_ ): '''simple docstring''' def __init__( self : List[str] , _UpperCamelCase : ...
226
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class _A ( snake_case ): '''simple docstring''' def __init__( self ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ...
700
def lowercase ( __A : Union[str, Any] ) -> int: '''simple docstring''' snake_case : Dict = [0] * len(__A ) snake_case : int = [] snake_case : Optional[Any] = [1] * len(__A ) for values in graph.values(): for i in v...
315
0
'''simple docstring''' from math import pi, sqrt def _lowercase ( lowerCamelCase__ : float ): if num <= 0: raise ValueError("math domain error" ) if num > 1_71.5: raise OverflowError("math range error" ) elif num - int(lowerCamelCase__ ) not i...
131
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from...
131
1
'''simple docstring''' import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline __...
61
'''simple docstring''' from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class a_ : def __init__(self , __a = None) -> None: """simple docstring""" ...
61
1
def _lowerCamelCase ( SCREAMING_SNAKE_CASE_ : List[str] , SCREAMING_SNAKE_CASE_ : Optional[Any] , SCREAMING_SNAKE_CASE_ : Union[str, Any] , SCREAMING_SNAKE_CASE_ : Union[str, Any] ): """simple docstring""" a_ : int = ...
419
from ..utils import DummyObject, requires_backends class snake_case__ ( metaclass=__A ): UpperCAmelCase : Optional[int] = ["""sentencepiece"""] def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> List[Any]: """simple docstring""" ...
419
1
"""simple docstring""" from ... import PretrainedConfig __A = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class a ( A_ ): A_ : int = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP A_ : ...
173
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 1000 ): return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
173
1
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase (SCREAMING_SNAKE_CASE_ ): __A = (DDPMScheduler,) def _a ( self , **_lowerCAmelCase ) -> Any: '''simpl...
588
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCAmelCase__ : '''simple docstring''' lowerCAmelCase_ = 42 lowerCAmelCase_ = 42 class ...
544
0
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _lowercase : Any = _symbol_d...
546
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Di...
546
1
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) A__ = models.Sequential() # Step 1 - Convolution # ...
166
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( a_ : Optional[int] , a_ : Optional[Any] , a_ : List[st...
166
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorT...
607
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from tra...
607
1
from ...configuration_utils import PretrainedConfig A : Optional[int] = { 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co/goog...
15
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, w...
120
0
'''simple docstring''' import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'kakaobrain/align-base': 'https://hugg...
709
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging a_ = logging.get...
193
0
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : Dict , lowerCAmelCase : Optional[Any] ): """simple docstring""" def get_matched_characters(lowerCAmelCase : Optional[int] , lowerCAmelCase : int ) -> str: __...
561
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( A__ , unittest.TestCase ): """simple docstring""" a = TransfoXLTo...
493
0
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, neste...
400
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import ...
400
1
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class __SCREAMING_SNAKE_CASE : def __init__( self : Dict , UpperCAmelCase__ : Union[str, Any]=2 , UpperCAmelCa...
92
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _lowerCAmelCase = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = "mumbai" ): ""...
565
0
'''simple docstring''' def A ( _UpperCAmelCase : int ,_UpperCAmelCase : Any ,_UpperCAmelCase : Any=False ) -> List[str]: '''simple docstring''' if isinstance(_UpperCAmelCase ,_UpperCAmelCase ) and isinstance(_UpperCAmelCase ,_UpperCAmelCase ...
123
'''simple docstring''' from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def A ( ) -> Tuple: '''simple docstring''' __lowerCAmelCase : int = { 'repo_name': ['test_repo1...
123
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTra...
523
'''simple docstring''' import numpy as np def UpperCamelCase__ ( _lowercase : np.array ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
523
1
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = { """vocab_file""": """vocab.json""", """tokenizer_config_file""...
716
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel _A = logging.getLo...
507
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a = { """configuration_trajectory_transformer""": [ """TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TrajectoryTransformerConfig""", ...
687
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCAmelCase_ (unittest.TestCase ): """simple docstring""" def SCREAMING_SNAKE_CASE__ ( self: int ): _lowerC...
687
1
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling_tf...
705
from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=_lowerCAmelCase ): a_ : Dict = ['''torch''', '''transformers''', '''onnx'''] def __init__(self , *UpperCAmelCase , **UpperCAmelCase): '''simple docstring''' ...
142
0
"""simple docstring""" from __future__ import annotations from math import gcd def A ( _A, _A = 2, _A = 1, _A = 3, ): """simple docstring""" # A value less than 2 can cause an infinite loop in the algorithm. if num < 2: raise ValueError("The input value cannot be les...
584
"""simple docstring""" def A_ ( snake_case_ : int = 1_0_0_0_0_0_0 ): '''simple docstring''' UpperCamelCase : List[Any] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(...
499
0
"""simple docstring""" import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class a_ ( __UpperCamelCase ): def __init__( self ...
707
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version f...
674
0
'''simple docstring''' import argparse import datetime def _UpperCamelCase ( UpperCamelCase__ ): """simple docstring""" __magic_name__ : Union[str, Any] = { "0": "Sunday", "1": "Monday", "2": "Tuesday...
436
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _SCREAMING_SNAKE_CASE : List[Any] = Lock() def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCa...
436
1
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __lowerCamelCase : Tuple = re.compile(r"""^(?P<major>\d+)""" r"""\.(?P<minor>\d+)""" r"""\.(?P<patch>\d+)$""")...
418
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Tuple = {"""configuration_fnet""": ["""FNET_PRET...
418
1
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, ...
645
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType lowe...
645
1
'''simple docstring''' __UpperCAmelCase = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" _...
692
'''simple docstring''' import os import sys import unittest __UpperCAmelCase = 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, crea...
692
1
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowercase__ = str(bin(SCREAMING_SNAKE_CASE ) )[2:] # remove the leading "0b" lowercase__ = str(...
43
def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" return "".join([hex(SCREAMING_SNAKE_CASE )[2:].zfill(2 ).upper() for byte in list(SCREAMING_SNAKE_CASE )] ) def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if (len(SCREAMING_SNAKE_CASE ) % 2) != ...
43
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERende...
349
"""simple docstring""" import numpy as np def UpperCAmelCase_ ( __a : np.array ): '''simple docstring''' return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
349
1
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow ...
458
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __magic_name__ ( ) -> Union[str, Any]: """simple docstring""" wit...
458
1
'''simple docstring''' from __future__ import annotations import math def _A ( A__ ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not pri...
702
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_con...
624
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __UpperCamelCase ( lowerCAmelCase__ ): """simple docstring""" lowerCAmelCase_ = ['''image_processor''', '''tokenizer'''] lowerCAmelCase_...
74
def lowerCAmelCase ( UpperCamelCase__ : List[Any] , UpperCamelCase__ : Dict ) -> List[Any]: """simple docstring""" __SCREAMING_SNAKE_CASE: int = [0 for i in range(r + 1 )] # nc0 = 1 __SCREAMING_SNAKE_CASE: Dict = 1 ...
202
0
'''simple docstring''' import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets impo...
701
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
271
0
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_GUIDED_...
68
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 lowercase__ ( uni...
475
0
from __future__ import annotations from decimal import Decimal from numpy import array def UpperCAmelCase__ ( lowerCamelCase_ : Union[str, Any] ): __a : str = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only...
720
def UpperCAmelCase__ ( lowerCamelCase_ : list[int] , lowerCamelCase_ : list[int] ): # Check if the input is valid if not len(lowerCamelCase_ ) == len(lowerCamelCase_ ) == 3: raise ValueError('Please enter a valid equation.' ) if e...
577
0
"""simple docstring""" from __future__ import annotations def __A ( a_ :str) -> list[int]: return [ord(a_) - 96 for elem in plain] def __A ( a_ :list[int]) -> str: return "".join(chr(elem + 96) for elem in encoded) def __A ( ) ->...
52
'''simple docstring''' import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @req...
24
0
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --...
700
'''simple docstring''' from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowercase = logging.get_logger(__name__) lowercase = '''T5Config''' class __lowerCamelCase ...
564
0
'''simple docstring''' def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = 0 , _lowerCAmelCase = 0 )-> int: __UpperCAmelCase = right or len(__lowercase ) - 1 if left > right: return -1 elif list_data[left] == key: return left elif...
126
from __future__ import annotations def snake_case (__lowercase , __lowercase , __lowercase ) -> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: ...
670
0
def lowercase ( _a ) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def lowercase ( _a ) -> bool: UpperCAmelCase_: Any = 0 UpperCAmelCase_: List[str] = number while duplicate > 0: UpperCAmelCase_ , UpperCAm...
306
from __future__ import annotations _lowerCAmelCase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowerCAmelCase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowercase ( _a ) -> list[float]: UpperCAmelCase_: Dict = [] U...
306
1
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')
521
from __future__ import annotations def __UpperCamelCase ( lowerCAmelCase__ : list[float] , lowerCAmelCase__ : int ): print(f"Vertex\tShortest Distance from vertex {src}" ) for i, d in enumerate(lowerCAmelCase__ ): print(f"{i}\t\t{d}" ) def __UpperCamelCase ( ...
521
1
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping __lowerCAmelCase = tuple[int, int] class SCREAMING_SNAKE_CASE : def __init__( self : List[str] , __SCREAMING_SNAKE_CASE ...
714
'''simple docstring''' import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet i...
666
0