code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import math import random def lowercase ( UpperCamelCase : float , UpperCamelCase : bool = False ): """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value __A : ...
656
"""simple docstring""" import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils...
656
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('T') class __lowercase (Generic[T] ): def __init__( self : Union[str, Any]...
6
'''simple docstring''' import argparse import struct import unittest class __lowercase : def __init__( self : Tuple , UpperCAmelCase_ : bytes): UpperCamelCase__ : Dict = data # Initialize hash values UpperCamelCas...
6
1
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_util...
439
from __future__ import annotations from math import gcd def __lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int = 2 , _UpperCamelCase : int = 1 , _UpperCamelCase : int = 3 , ) -> int | None: '''simple docstring''' if num < 2: raise ValueError('The input v...
439
1
'''simple docstring''' from __future__ import annotations from typing import Generic, TypeVar lowerCAmelCase : Optional[Any] = TypeVar("""T""") class _UpperCamelCase ( Generic[T]): '''simple docstring''' def __init__( self , a_ ) -> None: ...
425
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunD...
425
1
'''simple docstring''' def A ( UpperCamelCase_ : Optional[int] ) -> str: '''simple docstring''' lowerCAmelCase__ = [] lowerCAmelCase__ = set({"(", "[", "{"} ) lowerCAmelCase__ = set({")", "]", "}"} ) lowerCAmelCase__ = ...
48
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A ( UpperCamelCase_ : Optional[int] , UpperCamelCase_ ...
48
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase_: Dict = {"configuration_vit_mae": ["VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_M...
705
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
668
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kine...
96
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers SCREAMING_SNAKE_CASE_ = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def A__ ( ) -> List[str]: '''simple docstring''' _UpperCAmelCase = os.path.dirname(os.path.realpath(...
426
0
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name...
180
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class lowerCamelCase_ ( unittest.TestCase ): def A ( self ): """simple docstring""" __magic_name__ :Union[str, Any] ...
180
1
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor SCREAMING_SNAKE_CASE__ : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase_ ( __lowerCamelCase ): def __init__( self , *_l...
79
def _a ( lowercase__ : int = 60_08_51_47_51_43 ): '''simple docstring''' try: SCREAMING_SNAKE_CASE__ : Dict = int(lowercase__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: ...
85
0
from __future__ import annotations A_ = list[list[int]] # assigning initial values to the grid A_ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, ...
479
def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase )-> int: """simple docstring""" while a != 0: lowercase ,lowercase = b % a, a return b def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase )-> int...
479
1
'''simple docstring''' import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_...
261
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common im...
261
1
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _lowerCAmelCase : Dict = "src/transformers" _lowerCAm...
364
import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase : List[Any] = ["small", "medium", "large"] _lowerCAmelCase : List[Any] = "lm_head.decoder.weight" _lowerCAmelCase : Optional[int] = "lm_head.weight" def lowerCAmelCase ( ...
364
1
"""simple docstring""" 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 lowerCAmelCase = logging...
174
"""simple docstring""" from collections.abc import Callable class A_ : """simple docstring""" def __init__( self :Tuple , lowerCamelCase_ :Callable | None = None ): """simple docstring""" lowerCamelCase__ : list...
174
1
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transformers import Aut...
685
from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=lowerCamelCase_ ): __a : Tuple = ["flax"] def __init__( self ,*snake_case__ ,**snake_case__ ): requires_backends(self ,['flax'] ) @classmethod ...
685
1
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : int = 10 , _UpperCamelCase : int = 10_00 , _UpperCamelCase : bool = True ) -> int: """simple docstring""" assert ( isinstance(lowerCamelCase_ , lowerCamelCase_ ) and isinstance(...
405
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() UpperCamelCase__ : Tuple = logging.get_logger(__name__) UpperCamelCase__ : Option...
105
0
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : list[int] ) -> int: '''simple docstring''' if not numbers: return 0 if not isinstance(__lowercase , (list, tuple) ) or not all( isinstance(__lowercase , __lowercase ) for number in ...
119
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def UpperCAmelCase_ ( __lowercase : str ) -> str:...
119
1
"""simple docstring""" lowerCAmelCase: Tuple =8.3_1_4_4_5_9_8 def __snake_case ( __A ,__A ) -> List[Any]: if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <= 0: raise Exception("""Molar ...
607
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor A : Optional[Any] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self ...
636
0
"""simple docstring""" import argparse import json import subprocess def a__ ( a : Optional[Any] , a : Optional[int] ): """simple docstring""" _snake_case : str = [] _snake_case : Optional[Any] = ( f'curl -H "Accept: application/vnd.gith...
87
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self , snake_case_ , snake_case_ ): _snake_case , _snake_case : Dict = text, pattern _snake_case , _snake_case : int = len(sna...
87
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, ...
347
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class lowercase__ ( __SCREAMING_SNAKE_CASE ...
475
0
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils...
123
'''simple docstring''' import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from uti...
123
1
"""simple docstring""" import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_avail...
4
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipelin...
4
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class _a ( unittest.TestCase ): """simple docstri...
713
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _snake_case (__lowercase , __lowercase , __lowercase = "x" , __lowercase = 10**-10 , __lowercase = 1 , ): UpperCamelCase_ = symbols(__lower...
618
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCAmelCase...
434
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ) ->Union[str, Any]: return ConvertCommand( args.model_type , args.tf_checkpoint ,...
434
1
"""simple docstring""" from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_av...
713
"""simple docstring""" def snake_case__ ( _lowerCamelCase ) ->list: """simple docstring""" __lowercase : Optional[int] = [0] * len(_lowerCamelCase ) for i in range(1, len(_lowerCamelCase ) ): # use last results for better performance - dyna...
281
0
"""simple docstring""" 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 ...
584
'''simple docstring''' import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simpli...
390
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : int = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } try: if not is_t...
651
from manim import * class A( UpperCamelCase ): '''simple docstring''' def a__ ( self : Optional[Any] ) -> List[str]: """simple docstring""" lowerCamelCase_ = Rectangle(height=0.5 , width=0.5...
651
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCamelCase__ (...
607
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): ...
607
1
'''simple docstring''' import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snake_case ( lowercase_, lowercase_ ): """simple docstring""" @register_to_config def _...
238
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) class ...
238
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Optional[Any] = { 'RWKV/rwkv-4-169m-pile': 'https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config...
643
def a__ ( snake_case__ : Tuple ): # noqa: E741 _UpperCAmelCase : Dict = len(snake_case__ ) _UpperCAmelCase : Tuple = 0 _UpperCAmelCase : Union[str, Any] = [0] * n _UpperCAmelCase : Union[str, Any] = [False] * n _U...
643
1
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase_ ( _lowerCamelCase ):...
541
def lowerCamelCase__ ( UpperCamelCase__ : list[int] , UpperCamelCase__ : int ) -> bool: '''simple docstring''' _snake_case = len(UpperCamelCase__ ) _snake_case = [[False] * (required_sum + 1) for _ in range(arr_len + 1 ...
541
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def _lowerCamelCase ( __lowerCamelCase ) -> List[Any]: '''simple docstring''' def wrapper(*__lowerCamelCase , ...
79
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) ...
684
0
"""simple docstring""" def _lowerCamelCase ( lowerCamelCase__ : float , lowerCamelCase__ : float ): if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 * mass * abs(lowerCamelCase__ ) * abs(lowerCamelCase__ ) if __name__ == "...
701
"""simple docstring""" import heapq def _lowerCamelCase ( lowerCamelCase__ : dict ): lowercase__ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq ...
128
0
'''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 UpperCamelCase ( lowercase_ : Tuple ) -> Optional[Any]: '''simple docstring''' ...
72
'''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 _UpperCAmelCase : Union[str, Any] = datasets.logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = '''\ @InP...
72
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 __lowerCamelCase : Any = logging.get_logger(__name__) __lowerCamelCase : int = { ...
38
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __lowerCamelCase : Dict = logging.get_logger(__name__) __lo...
38
1
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowercase_ : Optional[int] = {'''UserAgent''': UserAgent().random} def _lowerCAmelCase ( lowerCamelCase__ : ...
572
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load...
312
0
"""simple docstring""" from math import isclose, sqrt def lowercase__ ( snake_case_ :float , snake_case_ :float , snake_case_ :float ): __UpperCAmelCase = point_y / 4 / point_x __UpperCAmelCase = 2 * normal_gradient / (1 + normal_gradient * normal_gra...
397
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[int] ): __UpperCAmelCase = len(snake_case_ ) // 2 # choose the middle 3 elements __UpperCAmelCase = lst[m - 1 : m + 2] # if middle element is peak if thre...
397
1
"""simple docstring""" from __future__ import annotations from scipy.special import comb # type: ignore class UpperCamelCase__ : """simple docstring""" def __init__( self : Tuple , UpperCamelCase_ : list[tuple[float, float]] ): ...
545
"""simple docstring""" from maths.prime_check import is_prime def A ( __snake_case: int ) -> int: """simple docstring""" if not isinstance(__snake_case , __snake_case ): __magic_name__ = F"""Input value of [number={numbe...
545
1
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcesso...
705
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A : Any = logging.get_logger(__name__) _A : str = {'vocab_file': 'senten...
130
0
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): # noqa: E741 '''simple docstring''' while r - l > 1: UpperCAmelCase = ...
673
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : int = logging.get_logger(__name__) lowerCAmelCase_ : Any = { '''facebook/wav2vec2-base-960h''': '''https:...
673
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : str = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: if not is_torch_ava...
145
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Optional[Any] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig'...
145
1
class __lowerCamelCase : """simple docstring""" def __init__( self : List[str] , SCREAMING_SNAKE_CASE__ : str ) -> int: lowerCAmelCase__ = val lowerCAmelCase__ = None lowerCAmelCase__ = None ...
61
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_dim...
235
0
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter,...
718
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiec...
362
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 ...
539
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_g...
539
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Optional[Any] =logging.get_logger(__name__) __snake_case :Any ={ 'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/config.json', 'google/fnet-large': 'https://huggingface...
224
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput ...
224
1
'''simple docstring''' from collections.abc import Sequence def __snake_case ( lowerCAmelCase : Sequence[float] , lowerCAmelCase : bool = False ): if not arr: return 0 __UpperCAmelCase = 0 if allow_empty_subarrays else float('-inf' ) __UpperCAmelCase ...
396
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logg...
125
0
'''simple docstring''' # Imports import numpy as np class lowerCamelCase__ : '''simple docstring''' def __init__( self : int , __A : Tuple=None , __A : Union[str, Any]=None , __A : Optional[Any]=None , __A : int=Non...
211
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers i...
211
1
'''simple docstring''' import pickle import numpy as np from matplotlib import pyplot as plt class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE_...
329
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_ava...
451
0
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @require_torch @req...
701
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, StableDiffusionXLImgaImgPipeline, UNetaDCo...
203
0
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def lowercase__( __UpperCamelCase: Optional[int] ,__UpperCamelCase: List[Any] ,__UpperCamelCase: Optional[int] ): """simple docstring""" ...
28
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> --host <host> --k...
590
0
'''simple docstring''' from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def a ( __a ) -> str: '''simple docstring''' return getitem, k def a ( __a , __a ) -> Any: '''simpl...
719
'''simple docstring''' import torch from torch import nn class lowercase ( nn.Module ): """simple docstring""" def __init__( self , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_=1 , UpperCamelCase_=False...
280
0
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import ...
563
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBer...
563
1
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, ImageInp...
97
from timeit import timeit def _lowerCamelCase( lowerCAmelCase__ : int ): '''simple docstring''' if number < 0: raise ValueError('the value of input must not be negative' ) SCREAMING_SNAKE_CASE_ : Tuple = 0 while number: number &=...
97
1
def lowerCamelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : int ) -> list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(UpperCamelCase__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest i...
469
def lowerCamelCase_ ( UpperCamelCase__ : str ) -> bool: """simple docstring""" __lowerCamelCase = 0 for ch in input_str: __lowerCamelCase = ord(UpperCamelCase__ ) __lowerCamelCase = pow(2 , UpperCa...
469
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available lowerCamelCase = { """configuration_audio_spectrogram_transformer""": [ """AUDIO_SPECTROGRAM_TRANSFORMER_PRETRA...
14
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCamelCase = { """configuration_perceiver""": ["""PERCEIVER_...
14
1
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar _lowercase : Optional[int] = TypeVar("""T""") class UpperCamelCase__( ...
210
from typing import Dict, Iterable, 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_forma...
461
0
from math import loga def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError('''Input value must be a \'int\'...
702
lowerCAmelCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): lowercase__ = f'a bytes-like object is required, not \'{d...
429
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise Op...
61
_A = '''Alexander Joslin''' import operator as op from .stack import Stack def __UpperCamelCase ( _A ): lowerCAmelCase_ = {'''*''': op.mul, '''/''': op.truediv, '''+''': op.add, '''-''': op.sub} lowerCAmelCase_ = Stack() lowerCAmelCase_ = Stack() ...
431
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : str = logging.get_logger(__name__) a : Any = { """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.json""", """goo...
672
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a : Tuple = False class UpperCamelCase_ ( unit...
672
1
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( UpperCAmelCase__ : float , UpperCAmelCase__ : float , UpperCAmelCase__ : float ) -> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ...
209
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer el...
209
1
"""simple docstring""" 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...
700
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=_lowercase): '''simple docstring''' __magic_name__ : List[str] = ['''torch'''] def __init__( self , *lowerCamelCase__ , **...
150
0
def lowerCamelCase__ ( __lowerCamelCase : float , __lowerCamelCase : int ): if digit_amount > 0: return round(number - int(__lowerCamelCase ) , __lowerCamelCase ) return number - int(__lowerCamelCase ) if __name__ == "__main__": ...
63
def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> tuple[float, float]: # Check if the input is valid if not len(SCREAMING_SNAKE_CASE ) == len(SCREAMING_SNAKE_CASE ) == 3: raise ValueError('Please enter a valid equation.' ) i...
66
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMI...
557
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_distilbert": [ "DISTILBERT_PRETRAINED_...
557
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class A ( _a ): lowercase_ = 'WhisperFeatureExtractor' lowercase_ = 'WhisperTokenizer' def __init__( self : Union[str, Any] , ...
22
"""simple docstring""" import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def lowerCamelCase__ ( self : ...
115
0
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common im...
298
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.util...
298
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.set_ver...
613
import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def snake_case__ ( lowercase , l...
613
1
'''simple docstring''' from __future__ import annotations def UpperCAmelCase ( UpperCAmelCase__ : list[int]): lowerCamelCase : int = len(UpperCAmelCase__) // 2 # choose the middle 3 elements lowerCamelCase : List[str] = lst[m -...
449
'''simple docstring''' def UpperCAmelCase ( UpperCAmelCase__ : list[int]): if not nums: # Makes sure that the list is not empty raise ValueError('List is empty') lowerCamelCase : int = sum(UpperCAmelCase__) / len(UpperCAmelCase__) # Calculate the...
449
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_availab...
592
def lowerCamelCase__ ( snake_case_ : str , snake_case_ : list[str] ) -> str: __snake_case = '''''' for word_or_phrase in separated: if not isinstance(snake_case_ , snake_case_ ): raise Exception('''join() accepts only strings to be joine...
592
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """junnyu/roformer_chinese_small""": """https://huggingfa...
488
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import C...
488
1
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __UpperCAmelCase = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''...
90
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformer...
28
0
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def A__ ( snake_case_ : Tuple ): SCREAMING_SNAKE_CASE__: int= [ """encoder.version""", """decoder.version""", """model.encoder...
708
import re def A__ ( snake_case_ : str ): if len(re.findall('''[ATCG]''' , snake_case_ ) ) != len(snake_case_ ): raise ValueError('''Invalid Strand''' ) return dna.translate(dna.maketrans('''ATCG''' , '''TAGC''' ) ) if __name__ == "__main__": ...
107
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ : Dict = logging.get_logger(__name__) class _snake_case ( A__ ): def __init__( self , *a , **a) -> None: warnings.warn( 'The clas...
73
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from...
166
0
"""simple docstring""" 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__ ) -> tup...
705
"""simple docstring""" def a__ ( snake_case__ = 1_00_00_00 ) -> int: lowerCamelCase = 1 lowerCamelCase = 1 lowerCamelCase = {1: 1} for inputa in range(2 , snake_case__ ): lowerCamelCase = 0 lowerCamelCase ...
533
0
import colorsys from PIL import Image # type: ignore def a ( snake_case__: float , snake_case__: float , snake_case__: int ): '''simple docstring''' lowercase_ = x lowercase_ = y for step in range(snake_case__ ): # noqa: B007 lowercas...
97
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase : List[str] = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: i...
202
0
'''simple docstring''' from __future__ import annotations class __magic_name__ : """simple docstring""" def __init__( self , _lowercase , _lowercase ) -> List[Any]: lowercase_ , lowercase_ : Tuple = text, pattern lowe...
700
'''simple docstring''' def _UpperCAmelCase ( a : list[list[float]] ) -> list[list[float]]: """simple docstring""" lowercase_ : list[list[float]] = [] for data in source_data: for i, el in enumerate(a ): if len(a ) <...
7
0
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand A : Any = logging.get_logger(__name__) # pylint: disable=invalid-name def UpperCamelCase__ ( SCREAMING_S...
287
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ : int = 2_00_00_00 ) -> int: _lowercase = [0 for i in range(n + 1 )] _lowercase = 1 _lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_lis...
287
1
from math import ceil def A__ ( __A , __A ): '''simple docstring''' _lowerCamelCase : List[Any] = list(range(0 , __A ) ) _lowerCamelCase : List[str] = [item for sublist in list(device_map.values() ) for item in sublist] ...
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
# 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 # # Unless required by applic...
335
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class snake_case_ (lowerCam...
335
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _A = { '''configuration_m2m_100''': ['''M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''M2M100Config''', '''M2M100OnnxConfig'''], '''tokenization_m2m_10...
717
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_...
189
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : int = { 'vinvino02/glpn-kitti': 'https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.j...
226
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class A ( lowerCamelCase_ ): '''simple docstring''' lowerCamelCase : Any = """""" lowerCamelCase : s...
226
1
'''simple docstring''' from math import factorial def SCREAMING_SNAKE_CASE ( a_ : int , a_ : int ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or ...
490
'''simple docstring''' def SCREAMING_SNAKE_CASE ( a_ : str ): __a = '' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def SCREAMING_SNAKE_CASE ( a_ : str ): __...
490
1
def A_ ( _lowerCAmelCase = 1000 ) -> int: return sum(e for e in range(3 , _lowerCAmelCase ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f"""{solution() = }""")
629
def A_ ( _lowerCAmelCase ) -> bool: return str(_lowerCAmelCase ) == str(_lowerCAmelCase )[::-1] def A_ ( _lowerCAmelCase ) -> int: return int(_lowerCAmelCase ) + int(str(_lowerCAmelCase )[::-1] ) def A_ ( _lowerCAmelCase = 1_0000 ) -> int: UpperCamelCase...
629
1
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifie...
718
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Dict = logging.get_logger(__name__) lowercase : Optional[Any] = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/res...
94
0
import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.models.mbart....
234
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline _lowercase : str =argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argument("--dpm",...
136
0
from __future__ import annotations def lowerCAmelCase__ ( _a : int , _a : int ): if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes: raise ValueError("partitions can not > number_of_bytes!" ) snake_c...
718
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def lowerCAmelCase__ ( _a : str , _a : str , **_a : Optional[int] ): snake_case_ : Any = AutoConfig.from_pretrained(_a , **_a ) snake_case_ :...
114
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ 'CarlCochet/trajectory-transformer-halfcheetah-medium-v2': ( 'https://huggingface.co/CarlCochet/trajectory-transformer-ha...
263
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging lowercase__ ...
263
1
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class _SCREAMING_SNAKE_C...
709
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowerCAmelCase = Lock() def UpperCamelCase ( a , a , a , a , a , a , a ) -> Optional[Any]: '''simple docstring''' g...
245
0
import random def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = num - 1 __lowercase = 0 while s % 2 == 0: __lowercase = s // 2 t += 1 for _ in range(5 ): __lowercase = random.randrange(2 , num - 1 )...
639
'''simple docstring''' from collections.abc import Callable def __snake_case (__UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): """simple docstring""" lowerCamelCase_ : float = a lowerCamelCase_ : float = b if function(__UpperCAmelCase...
501
0
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": UpperCamelCase = pd.read_csv("""sample_data.csv""", header=None) U...
120
"""simple docstring""" import os def A( ): """simple docstring""" with open(os.path.dirname(snake_case_ ) + "/p022_names.txt" ) as file: lowercase__: str = str(file.readlines()[0] ) lowercase__: str = names....
120
1
from typing import Any def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , ): _validation( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCa...
21
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from ...
413
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowercase_ (A : Optional[Any] , A : Union[str, Any] , A : Optional[int] ): ...
706
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ :List[Any] = logging.get_logger(__name__) a_ :Union[str, Any] = {"vocab_file": ...
243
0
from math import asin, atan, cos, radians, sin, sqrt, tan a : Tuple = 6_37_81_37.0 a : Any = 6_35_67_52.31_42_45 a : Tuple = 6_378_137 def lowerCamelCase__ ( __lowerCamelCase : float , __lowerCamelCase : float ...
63
from __future__ import annotations import numpy as np def UpperCamelCase_( lowerCamelCase_ ) -> Optional[int]: return np.maximum(0 , lowerCamelCase_ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
89
0
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_m...
259
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { "configuration_layoutlmv3": [ "LAYOUTLMV3_PRETRAINED_CO...
259
1
"""simple docstring""" import random def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ : List[str] = [], [], [] for element in data: if element < pivot: ...
65
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: int = 600_851_475_143 ): try: SCREAMING_SNAKE_CASE__ = int(UpperCamelCase__ ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: raise ValueError("""P...
6
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _UpperCamelCase (unittest.TestCase , _UpperCAmelCase ): def __UpperCAmelCase ( self )-> Optional[Any]: __lowerCAmelCase = load_tool("text-classification" ...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : Tuple = { '''caidas/swin2sr-classicalsr-x2-64''': ( '''https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/m...
290
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
199
'''simple docstring''' SCREAMING_SNAKE_CASE = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottam...
199
1
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowercase__ : Tuple = argparse.ArgumentParser( description=( '''Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
485
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import Te...
485
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Any = { "configuration_blenderbot_small": [ ...
21
"""simple docstring""" 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 accele...
180
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "camembert-base": "https://huggingface...
664
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm imp...
664
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available...
323
"""simple docstring""" from collections.abc import Callable import numpy as np def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case, __snake_case, __snake_case ) -> np.array: """simple docstring""" _UpperCamelCase = int(np.cei...
19
0
"""simple docstring""" from functools import reduce __lowerCAmelCase : Optional[Any] = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511'''...
717
"""simple docstring""" import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __lowerCAmelCase ( __UpperCamelCase :...
21
0