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''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class A__ ( snake_case_ ): def __init__( self : Tup...
405
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { 'configuration_pix2struct': [ 'PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Pix2StructConfig', 'Pix2StructTextConfig', 'Pix2S...
417
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : Any = logging.get_logger(__name__) __snake_case : Union[str, Any] = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingf...
713
"""simple docstring""" import string from math import logaa def _lowercase ( __snake_case ,__snake_case ) -> int: __lowerCAmelCase : int = document.translate( str.maketrans("" ,"" ,string.punctuation ) ).replace("\n" ,"" ) ...
615
0
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_roformer': ['ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP...
300
import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProcessor from diffusers.pipel...
300
1
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> float: """simple docstring""" def get_matched_characters(lowercase_ , lowercase_ ) -> str: A__ = [] A__ = min(len(_stra ) , len(_stra ) ) // 2 ...
706
from collections import namedtuple import requests from lxml import html # type: ignore _lowerCamelCase : Optional[int] = namedtuple("""covid_data""", """cases deaths recovered""") def SCREAMING_SNAKE_CASE ( lowercase_ = "https://www.worldometers.info/coronavirus/" ) -> covid_data...
177
0
'''simple docstring''' from __future__ import annotations from typing import Any def __snake_case ( _UpperCAmelCase : list[Any]): create_state_space_tree(_UpperCAmelCase, [], 0) def __snake_case ( _UpperCAmelCase : list[Any], _UpperCAmelCase ...
212
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : Optional[Any] = { 'configuration_blende...
212
1
'''simple docstring''' _lowerCAmelCase : List[str] = {str(digit): digit**5 for digit in range(10)} def __UpperCamelCase ( _A : int ) -> int: """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_A ) ) def __UpperCamelCase ( ) ...
646
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCamelCase ( _A : np.ndarray , _A : float ) -> np.ndarray: """simple docstring""" lowerCAmelCase : Union[str, Any] = math.sqrt(_A ) lowerCAmelCase : ...
646
1
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowercase_ (A : Union[dict, list, tuple, torch.Tensor] ): snake_case__ : ...
478
from ....utils import logging a_ :Optional[int] = logging.get_logger(__name__) class snake_case__ ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Optional[Any], _snake_case : List[str], _snake_case : Any=None, _snake_case : Tu...
478
1
'''simple docstring''' import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ...
718
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler...
324
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sep...
589
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : List[str] = { """configuration_distilbert""...
589
1
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _a : Optional[Any] = logging.get_logger(__name__) ...
10
'''simple docstring''' def _lowercase ( lowerCamelCase__ , lowerCamelCase__ ) -> List[str]: """simple docstring""" __UpperCAmelCase : Dict = (boundary[1] - boundary[0]) / steps __UpperCAmelCase : Tuple = boundary[0...
10
1
import colorsys from PIL import Image # type: ignore def a_ ( SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : int ): '''simple docstring''' _lowerCamelCase : List[Any] =x _lowerCamelCase ...
464
"""simple docstring""" def snake_case_ ( A_ : int, A_ : int ): '''simple docstring''' return int(input_a == input_a == 0 ) def snake_case_ ( ): '''simple docstring''' print('''Truth Table of NOR Gate:''' ) print('''| I...
83
0
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( """files""" , [ ["""full:README.md""", """dataset_infos.json"""], ["""empty:README.md""", """dataset_infos.j...
719
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
322
0
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
637
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optuna, ...
558
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { '''configuration_lilt''': ['''LILT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LiltConfig'''], } try: if not is_torch_available(): raise Opt...
635
"""simple docstring""" from __future__ import annotations def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , )-> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("""You cannot supply more o...
635
1
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( a__ ): _UpperCAmelCase = (CMStochasticIterativeScheduler,) _UpperCAmelCase = 10 ...
259
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import to...
259
1
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction...
721
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixi...
468
0
UpperCAmelCase = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 10: '''a''', 11: '''b''', 12: '''c''', 13: '''d''', 14: '''e''', 15: '''f''', } def UpperCAmelCa...
84
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 from ..auto import CONFIG_MAPPING __lowercase = logging.get_logger(__name__) __lowercase ...
203
0
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as j...
659
"""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 ...sched...
659
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black UpperCAmelCase__ : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies #...
48
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 ...
61
0
'''simple docstring''' import unittest from knapsack import knapsack as k class snake_case_ ( unittest.TestCase ): """simple docstring""" def __UpperCAmelCase ( self): lowerCamelCase__ = 0 lowerCamelCase__ = [0] lowe...
426
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization i...
426
1
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 TestCommand from datasets.ut...
540
from random import randint from tempfile import TemporaryFile import numpy as np def _UpperCAmelCase ( a__ , a__ , a__): '''simple docstring''' a_ : List[Any] = 0 if start < end: a_ : Dict = randint(a__ , a__) a_ : List[str] ...
540
1
"""simple docstring""" import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import...
538
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME _A = ['small', 'medium', 'large'] _A = 'lm_head.decoder.weight' _A = 'lm_head.weight' def SCREAMING_SNAKE_CASE ( __UpperCAmelCase , ...
538
1
'''simple docstring''' class SCREAMING_SNAKE_CASE : def __init__( self , _UpperCAmelCase): '''simple docstring''' __A : Union[str, Any] = val __A : Tuple = None __A : Any = None...
8
"""simple docstring""" import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig if TYPE_CHECKIN...
338
0
'''simple docstring''' from __future__ import annotations def _snake_case ( A_ : int | str ): """simple docstring""" a_ : List[str] = str(A_ ) return n == n[::-1] def _snake_case ( A_ : int = 100_0000 ): ...
460
'''simple docstring''' from math import factorial __snake_case: List[Any] = {str(d): factorial(d) for d in range(10)} def _snake_case ( A_ : int ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(A_ ) ) def _sna...
460
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENE...
48
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCondit...
521
0
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) UpperCAmelCase = logging.getLogger() ...
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 UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = {"""vocab...
351
0
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import MvpTokenizer ...
340
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _snake_case = False try: _snake_case = _is_package_av...
340
1
import math def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(__magic_name__ ) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: return 1 # any nu...
206
def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): return abs(__magic_name__ ) if a == 0 else greatest_common_divisor(b % a , __magic_name__ ) def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): while y: # --> when y=0 then loop will terminate and retu...
206
1
'''simple docstring''' from timeit import timeit lowercase : str = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan ...
649
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare...
422
0
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration...
653
'''simple docstring''' import os def SCREAMING_SNAKE_CASE ( ): lowercase = os.path.join(os.path.dirname(lowercase_ ) , """num.txt""" ) with open(lowercase_ ) as file_hand: return str(sum(int(lowercase_ ) for line in file_hand ) ...
653
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
584
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import...
327
0
import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils ...
720
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils im...
332
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A__ = { '''configuration_roberta_prelayernorm''': [ '''ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARC...
252
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property ...
574
0
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import In...
678
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( snake_case_ : Tuple , snake_case_ : Union[str, Any] , snake_case_ : List[str] , snake_case_ : Union[str, Any] ): __magic_name__ = { '''en''': '''Machine learni...
678
1
import math def UpperCamelCase_( _snake_case : int = 100 ): """simple docstring""" __a =sum(i * i for i in range(1 , n + 1 ) ) __a =int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_s...
242
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_availabl...
106
0
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase = [[0] ...
702
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : float ): '''simple docstring''' if (voltage, current, resistance).count(0 ) !...
393
0
"""simple docstring""" import argparse import os import re _a : Dict = """src/diffusers""" # Pattern that looks at the indentation in a line. _a : Union[str, Any] = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. _a : Optional[Any] = ...
213
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(""".""") def lowerCAmelCase( __lowerCamelCase ): __a = test_file.split(os.path.sep ) if components[0:2] != ["te...
559
0
import math class UpperCamelCase : def __init__( self : List[str] , snake_case__ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" SCREAMING_SNAKE_CASE = n SCREAMING_SNAKE_CASE = [ [math.inf for j in rang...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
1
from __future__ import annotations def lowerCamelCase_ ( _UpperCamelCase ) -> list[int]: """simple docstring""" return [ord(_UpperCamelCase ) - 96 for elem in plain] def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring"""...
60
'''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 ...test_configuration_commo...
11
0
"""simple docstring""" from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self : Tuple , lowerCAmelCase : int , lowerCAmelCase : int , lowerCAmelCase : float = 0 ): ...
529
"""simple docstring""" from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { 'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-mont...
529
1
from ....utils import logging __lowerCAmelCase : Any =logging.get_logger(__name__) class _lowercase ( A__ ): '''simple docstring''' def __init__( self :Any , lowerCAmelCase__ :List[str] , lowerCAmelCase__ :Any=None , lowerCAmelCase_...
696
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : List[Any] =logging.get_logger(__name__) __lowerCAmelCase : Tuple ={ 'transfo-xl-wt103': 'https://huggingface.co/transfo-xl-wt103/resolve/main/config.json', } class _lowe...
696
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', # See all Cvt models at https://hug...
73
__magic_name__ = { "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": ...
73
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Tuple = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } cl...
49
'''simple docstring''' import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename lowerCAmelCase_ : ...
527
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ = {"p...
539
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create sim...
539
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation lowerCamel...
381
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import...
381
1
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_simplify, requir...
702
import cmath import math def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase )-> complex: """simple docstring""" lowercase = math.radians(UpperCAmelCase ) lowercase = math.radians(UpperCAme...
479
0
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock ...
169
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def _snake_case (__lowercase , __lowercase , __lowercase): # Initialise PyTorch model Upp...
23
0
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
719
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def lowerCAmelCase_ ( UpperCamelCase__ : str ): """simple docstring""" def decorator(UpperCamelCase__ : Tuple ): __lowercase = getattr(UpperCamelCase__ , """han...
442
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import ...
53
# Copyright 2022 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 app...
53
1
import string from math import logaa def _A ( A__ , A__ ): """simple docstring""" __lowercase = document.translate( str.maketrans('''''' , '''''' , string.punctuation ) ).replace('''\n''' , '''''' ) __lowercase = document_witho...
719
'''simple docstring''' from collections.abc import Callable import numpy as np def _A ( A__ , A__ , A__ , A__ , A__ ): """simple docstring""" __lowercase = int(np.ceil((x_end - xa) / step_size ) ) __lowercase = np.zeros((n + 1,...
624
0
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(): import torch lowerCamelCase__ ...
122
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def a ( __snake_case : float, __snake_case : float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance...
608
0
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __SCREAMING_SNAKE_CASE ( lower...
700
'''simple docstring''' import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast 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 Toke...
88
0
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class _snake_case : def __init__( self : Optional[int] ,SCREAMING_SNAKE_CASE__ : list[tuple[float, float]] ): SCREAMING_SNAKE_CASE:List[Any] = lis...
143
"""simple docstring""" from __future__ import annotations import math class lowerCAmelCase__ : def __init__( self : int , _lowerCamelCase : int ): _snake_case = size # approximate the overall size of segment tree with given valu...
224
0
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowercase : List[Any] = TypeVar("""T""") def UpperCAmelCase_ ( _UpperCAmelCase ): return (position - 1) // 2 def UpperCAmelCase_ ( _UpperCAmelCase ): ...
584
from __future__ import annotations import os from collections.abc import Mapping lowercase : str = tuple[int, int] class a__ : def __init__( self : Optional[Any] , A_ : set[int] , A_ : Mapping[EdgeT, int] ) -> N...
584
1
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class SCREAMING_SNAKE_CASE : """simple docstring""" A_ = 42 A_ = 42 class SCREAMING_SNAKE_CASE ...
484
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileBertConf...
484
1
class lowercase_ : def __init__( self , __A ) -> List[Any]: SCREAMING_SNAKE_CASE_ : int =val SCREAMING_SNAKE_CASE_ : Optional[Any] =None SCREAMING_SNAKE_CASE_ : str =None def _snake_case ...
711
def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : str ) -> str: return " ".join( ''''''.join(word[::-1] ) if len(UpperCAmelCase_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_...
431
0
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase ): '''simple docstring''' if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) UpperCAmelCase__ : List[Any] = sorted(string.lowe...
65
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tenso...
65
1
"""simple docstring""" from __future__ import annotations from collections import namedtuple def _lowerCamelCase ( UpperCAmelCase_ : float, UpperCAmelCase_ : float, UpperCAmelCase_ : float ) -> tuple: """simple docstring""" ...
704
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class UpperCamelCase__ : """simple docstri...
562
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available __a: Optional[Any] = {'''tokenization_herbert''': ['''HerbertTokenizer''']} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except Opti...
108
'''simple docstring''' from typing import Any def A__ ( A_ ) -> list[Any]: if not input_list: return [] _lowercase = [input_list.count(A_ ) for value in input_list] _lowercase = max(A_ ) # Gets the maximum count in the input list. # Gets values of modes ...
497
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
612
"""simple docstring""" import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_mo...
612
1
import unittest from typing import Dict, List, Optional, Union 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, prepa...
43
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_com...
259
0
'''simple docstring''' import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import Paddi...
700
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_sa...
226
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import...
94
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class UpperCAmelCase_ ( __A ): """simple docstring""" def A__ ( self : Optional[int] ) -> List[str]: '''simple docstr...
94
1
__snake_case :Optional[int] ='\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' __snake_case :Tuple ...
224
__snake_case :List[Any] =range(2, 20 + 1) __snake_case :Dict =[10**k for k in range(ks[-1] + 1)] __snake_case :dict[int, dict[int, list[list[int]]]] ={} def lowerCamelCase_ ( lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : Union[str, Any] , lowerCAmelCase__ : Dict , lo...
224
1
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> None: if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and ar...
228
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase : List[str] = """\ """ _lowerCamelCase : Optional[int] = """ Perplexity (PPL...
352
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCamelCase__ : List[Any] = logging.get_logger(__name__) class _UpperCamelCase ( A_ ): '''simple docstring''' def __init__( ...
486
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def A_( A ): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.config , args.finetuning_...
486
1
'''simple docstring''' from __future__ import annotations from collections import namedtuple def lowerCAmelCase_ ( snake_case_ : float , snake_case_ : float , snake_case_ : float ) -> tuple: '''simple docstring''' UpperCAmelCase_ ...
78
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
78
1
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, get_...
107
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
1
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from dif...
602
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class SCREAMING_SNAKE_CASE_ ( nn.Module ): '''simple docstring''' def __init__( self : Union[str, Any] , SCREAMING_SNAKE_CASE__ : ...
305
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
718
def SCREAMING_SNAKE_CASE ( lowerCAmelCase ): _UpperCamelCase = [] if len(lowerCAmelCase ) == 1: return [nums.copy()] for _ in range(len(lowerCAmelCase ) ): _UpperCamelCase = nums.pop(0 ) ...
105
0
'''simple docstring''' def UpperCAmelCase_ ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: lowerCAmelCase__ : Tuple = mf_knapsack(i...
378
'''simple docstring''' 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 snake_case = logging.get_logger(__name__) snake_case = { ""...
378
1
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_util...
718
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch_available(): ...
81
0
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from ...
630
'''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 ModelTesterM...
158
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nic...
716
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def a ( ): '''simple docstring''' with offline(OfflineSimulationMode.CONNECT...
686
0
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''nielsr/canine-s''': 2_0_4_8, } # Unicode defines 1,114,112 total “codepoints...
250
'''simple docstring''' import warnings 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 UpperCAmelCase_ = logging.get_logger(__n...
539
0
# 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 ...
290
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
290
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class lowerCamelCase ( ...
579
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class lowerCamelCase ( lowercase__ ): '''simple docstring''' def __init__( self , *lowerCAmel...
579
1
'''simple docstring''' def lowercase ( lowerCAmelCase : Optional[Any]): """simple docstring""" _A : List[Any] = [1] _A : Union[str, Any] = 0, 0, 0 _A : Optional[int] = ugly_nums[ia] * 2 _A : Any = ugly_nums[ia] *...
711
'''simple docstring''' import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def lowercase ( lowerCAmelCase : str , lowerCAmelCase : Optional[int] , lowerCAmelCase : Any , lowerCAmelCase : List[str]...
417
0
import pytest import datasets # Import fixture modules as plugins __snake_case = ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def _A ( _lowercase , _lowercase ) -> Tuple: """simple docstring""" for item in ...
1
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> list[tuple[int, int]]: __lowercase , __lowercase = position __lowercase = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y -...
375
0
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .em...
715
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
73
0
class lowercase_ : def __init__( self) -> str: a__ =0 a__ =0 a__ ={} def __UpperCamelCase ( self , lowercase_) -> Dict: if vertex not in self.adjacency: a__ ={} self...
20
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : List[str] =logging.get_logg...
359
0
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 from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
639
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokeniz...
639
1
'''simple docstring''' import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _UpperCamelCase : Dict = get_tests_dir("fixtur...
284
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCamelCase : str = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeo...
284
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface i...
161
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase_ = logging.get_logger(__name__) def UpperCamelCase( lowercase_ , lowercase_ ...
161
1
'''simple docstring''' def __UpperCAmelCase ( a_: int ): if n == 1 or not isinstance(a_, a_ ): return 0 elif n == 2: return 1 else: _UpperCAmelCase : Dict = [0, 1] for i in range(2, n + 1 ): sequence.append(sequence[i - 1] + sequence[i ...
494
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json', } class A__ ...
494
1
"""simple docstring""" import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP lowerCamelCase_ : Tuple = False...
710
"""simple docstring""" def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=False ): """simple docstring""" if isinstance(_UpperCAmelCase , _UpperCAmelCase ) and isinstance(_UpperCAmelCase , _UpperCAmelCase ): A_ :...
302
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
508
'''simple docstring''' from math import isqrt def __snake_case ( lowercase : int ): snake_case_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , lowercase , lowercase ): ...
508
1
import argparse import os import re import packaging.version UpperCAmelCase_ = 'examples/' UpperCAmelCase_ = { 'examples': (re.compile(R'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(R'^__version__\s+=\s+"...
369
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device UpperCAmelCase_ = False class lowercase__ ( u...
369
1
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _lowerCamelCase ( UpperCAmelCase_ : str, UpperCAmelCase_ : complex, UpperCAmelCase_ : str = "x", UpperCAmelCase_ : float = 10**-10, UpperCAme...
104
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import e...
593
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, ...
702
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _A ( unittest.TestCase ): ...
469
0
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A__ ( unittest.TestCase ): def snake_case_ ...
288
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""", [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""", ["""default""", 0, 1_00 * 2**20, 9_00 * ...
288
1
from __future__ import annotations def _a ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): a_ : Any = list(range(len(__UpperCamelCase ) ) ) a_ : Union[str, Any] = [v / w for v, w in zip(__UpperCamelCase , __UpperCamelCase )] index.sort(...
478
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __lowerCamelCase = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generation and must be sm...
478
1
def lowercase__ ( A_: Tuple ) -> str: """simple docstring""" __UpperCAmelCase =len(A_ ) __UpperCAmelCase =sum(A_ ) __UpperCAmelCase =[[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n ...
68
def __lowerCAmelCase ( _UpperCamelCase = 1000000 ) -> int: '''simple docstring''' lowerCamelCase__: Optional[int] = set(range(3 , _UpperCamelCase , 2 ) ) primes.add(2 ) for p in range(3 , _UpperCamelCase , ...
306
0
"""simple docstring""" import numpy as np from PIL import Image def _snake_case ( snake_case__ : np.ndarray , snake_case__ : int , snake_case__ : int ): A = np.array(snake_case__ ) if arr.shape[0] != arr.shape[1]: raise ValueError('The input array is ...
717
"""simple docstring""" import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter _lowercase =...
22
0
'''simple docstring''' import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a_ = get_te...
296
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www...
296
1
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_ti...
665
'''simple docstring''' def _a( UpperCamelCase__ : str, UpperCamelCase__ : str ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[int] =len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ : Optional[Any] ...
665
1
"""simple docstring""" from math import sqrt def __lowerCamelCase ( UpperCamelCase__ ): """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 primes ...
657
"""simple docstring""" def __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" return 10 - x * x def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" if equation(UpperCamelCase__ ) * equation(UpperCamelCase__ ) >= 0: raise Val...
657
1
"""simple docstring""" import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from tran...
707
"""simple docstring""" from __future__ import annotations import requests _a : List[str] = set( """approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_...
87
0
from __future__ import annotations import numpy as np def A__ ( _a : np.ndarray ): '''simple docstring''' snake_case__ , snake_case__ : str =np.shape(_a ) if rows != columns: snake_case__ : Any =( """'table' has to be of ...
385
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...
385
1
'''simple docstring''' def lowercase ( __magic_name__ , __magic_name__ , __magic_name__ ): '''simple docstring''' if exponent == 1: return base if exponent % 2 == 0: UpperCAmelCase : Tuple = _modexpt(__magic_name__ , ...
609
'''simple docstring''' import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from...
609
1