code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""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 impor...
197
def __lowercase ( lowerCamelCase : str ): UpperCamelCase_ : Dict = 0 for ch in input_str: UpperCamelCase_ : Tuple = ord(lowerCamelCase ) UpperCamelCase_ : str = pow(2 , lowerCamelCase ) # If we already turned on bit for current character's unicode ...
175
0
from copy import deepcopy class __lowerCamelCase : """simple docstring""" def __init__( self , UpperCAmelCase = None , UpperCAmelCase = None ) -> None: '''simple docstring''' if arr is None and size is not None: lowercase_ ...
356
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
297
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_at...
44
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE = { """configuration_convnext""": ["""CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ConvNextConfig"...
343
0
from math import pow, sqrt def __lowerCamelCase ( *lowerCAmelCase__ ): lowerCAmelCase__ = len(lowerCAmelCase__ ) > 0 and all(value > 0.0 for value in values ) return result def __lowerCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): re...
367
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer lowerCAmelCase__ = logging.get_logger(__name__) lowerCAme...
119
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # See all CANI...
104
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''KT''') lowerCAmelCase__ = TypeVar('''VT''') class lowercase_ (Generic[KT, VT] ): """simple docstring""" def __init...
104
1
'''simple docstring''' import pickle import numpy as np from matplotlib import pyplot as plt class UpperCamelCase : """simple docstring""" def __init__( self : Dict , UpperCAmelCase_ : Optional[int] , UpperCAmelCase_ : Union[str, Any] , UpperCA...
356
'''simple docstring''' import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCase ( a_ , unittest.TestCase ): """simple docstring""...
345
0
"""simple docstring""" import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCase ( lowercase_ ...
213
"""simple docstring""" import enum import warnings from ..tokenization_utils import TruncationStrategy 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 from ..models....
213
1
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _lowercase : str = datasets.load_iris() _lowercase : Optional[Any] = np.array(data['data']) _lowercase : Optional...
368
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : List[Any] = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], ...
86
0
"""simple docstring""" lowerCAmelCase_ = 'Alexander Joslin' import operator as op from .stack import Stack def __UpperCAmelCase ( __lowerCamelCase ) -> int: lowercase__ : str = {'''*''': op.mul, '''/''': op.truediv, '''+''': op.add, '''-...
16
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) f...
347
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { 'configuration_blenderbot': [ 'BLENDERBOT_PRETRAINED_CONFIG_ARCH...
119
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, Distr...
119
1
import math def A_ ( _UpperCAmelCase ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: Any = f"Input value of [number={number}] must be an integer" raise TypeError(_UpperCAmelCase ) if number < 1: S...
13
def A_ ( _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: List[str] = [0] * len(_UpperCAmelCase ) SCREAMING_SNAKE_CASE_: List[Any] = [] SCREAMING_SNAKE_CASE_: str = [] SCREAMING_SNAKE_CASE_: List[str] = 0 for values in graph.values(): ...
13
1
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_visi...
355
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/...
230
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCamelCase : str = logging.get_logger(__name__) __lowerCamelCase : str = { """facebook/c...
52
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_available(check_device=Fa...
99
0
from __future__ import annotations def snake_case_(_UpperCamelCase ) -> bool: """simple docstring""" _snake_case = str(_UpperCamelCase ) return len(_UpperCamelCase ) == 9 and set(_UpperCamelCase ) == set('''123456789''' ) def snake_case_() ->...
278
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __A = { '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''], } try: if not is_torch_available(): raise OptionalDependenc...
278
1
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : int ): """simple docstring""" if upper_limit < 0: raise ValueError("""Limit for the Catalan sequence must be ≥ 0""" ) __a = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 __a = 1 ...
302
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
302
1
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1337 , num_examples=4...
355
import os def A_ ( ) -> int: UpperCamelCase : List[str] = os.path.dirname(os.path.realpath(_lowerCAmelCase ) ) UpperCamelCase : Any = os.path.join(_lowerCAmelCase , "triangle.txt" ) with open(_lowerCAmelCase ) as f: UpperCamelCase ...
140
0
"""simple docstring""" import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_comm...
217
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class snake_case ( __snake_case ): # to overwrite at featu...
217
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ = 10_00 ) -> int: A__ = 3 A__ = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __name__ == "__main__": print(f'{solution() = }') ...
230
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRober...
230
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCamelCase = { '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxConfig'''], '''tokenization_mvp''': ['''MvpTok...
275
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class UpperCAmelCase : def __init__( self : str , __snake_case : Any ) -> str: _lowerCAmelCase = str(id_ ) _lo...
70
0
# 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 Confi...
370
def __lowercase ( __lowerCAmelCase : Optional[Any] ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7...
109
0
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def SCREAMING_SNAKE_CASE ( ) -> str: _lowerCAmelCase : Optional[Any] = ArgumentParser(...
44
'''simple docstring''' import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap lowercase_ = """Usage of script: script_name <size_of_canvas:int>""" lowercase_ = [0] * 100 + [1] * 10 random.shuffle(choice) def lowerCamelCase ...
58
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : Any = logging.get_logger(__name__) _lowerCamelCase : Dict = { '''google/bigbird-robe...
356
from functools import lru_cache @lru_cache def a_ ( __lowercase : int ) -> int: if num < 0: raise ValueError('Number should not be negative.' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod()
130
0
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
270
from queue import PriorityQueue from typing import Any import numpy as np def __magic_name__ ( __lowerCAmelCase : dict , __lowerCAmelCase : str , __lowerCAmelCase : set , __lowerCAmelCase : set , __lowerCAmelCase : dict , __lowerCAmelCase : dict , __lowerCAmelCase : ...
270
1
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 n...
355
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow ...
265
0
"""simple docstring""" def lowercase ( A_ , A_ , A_ )-> int: '''simple docstring''' if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(_A , n - 1 , _A ) * a) % mod else: a : Optional[int] ...
40
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput fr...
307
0
"""simple docstring""" from __future__ import annotations def __lowerCamelCase ( a_ : List[str] , a_ : Union[str, Any] , a_ : Optional[Any] ) -> tuple[float, list[float]]: __SCREAMING_SNAKE_CASE :Optional[Any] = list(ra...
364
"""simple docstring""" import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class _SCREAMING_SNAKE_CASE( A ): ...
239
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable UpperCAmelCase = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''...
141
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __UpperCamelCase ( lowercase__ : Optional[int], lowercase__ : str, lowercase__ : int ): '''simple docstring''' __...
141
1
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig, ) def ...
285
import math from datetime import datetime, timedelta def _snake_case( SCREAMING_SNAKE_CASE__ ) -> datetime: lowercase : Any = year % 19 lowercase : Optional[int] = year % 4 lowercase : Any = year % 7 lowercase ...
285
1
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image...
49
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( a , a , a ) -> float: if days_between_payments <= 0: raise ValueError('days_between_payments must be > 0' ) if daily_interest_rate < 0: raise ValueError('daily_interest_rate must...
280
0
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArguments ...
266
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def lowerCAmelCase_ ( _lowercase : ...
266
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } class __magi...
89
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from .....
235
0
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging __A = logging.get_logger(__name__) def __A ( ): ...
75
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class SCREAMING_SNAKE_CASE ...
75
1
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
343
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand _SCREAMING_SNAKE_CASE = ( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH QH""", """TS KS 5S 9S AC""", ""...
343
1
from __future__ import annotations import math from collections.abc import Callable def lowerCAmelCase__ ( a__: Callable[[int | float], int | float] , a__: int | float , a__: int | float , a__: int = 1_0_0 , ) -> float: '''simple docstring''' _UpperCAmelCa...
185
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class __a ( UpperCAmelCase ): _a : Union[List[np.ndarray], torch....
185
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__ (lowe...
48
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, UNeta...
244
0
SCREAMING_SNAKE_CASE__ : int = [0, 2, 4, 6, 8] SCREAMING_SNAKE_CASE__ : Dict = [1, 3, 5, 7, 9] def __magic_name__ ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : list[int] , __lowerCAmelCase : int ...
339
from datetime import datetime as dt import os from github import Github SCREAMING_SNAKE_CASE__ : Any = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __magic_name__ ( ) -> Any: ...
339
1
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import...
178
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impo...
178
1
'''simple docstring''' lowerCAmelCase__ = ''' # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git ''' lowerCAmelCase__ = [{'''type''': '''code''', '''content''': IN...
371
'''simple docstring''' lowerCAmelCase__ = { "joule": 1.0, "kilojoule": 1000, "megajoule": 100_0000, "gigajoule": 10_0000_0000, "wattsecond": 1.0, "watthour": 3600, "kilowatthour": 360_0000, "newtonmeter": 1.0, "calorie_nutr": 4186.8, "kilocalorie_nutr": 418_6800...
52
0
'''simple docstring''' import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class a_ ( _lowerCAmelCase , unittest.TestCase ): __A ...
223
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[int] =logging.get_logger(__name__) lowerCAmelCase : Tuple ={ '''huggingface/autoform...
223
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case : Optional[int] ={ 'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'], 'processing_vi...
94
import flax.linen as nn import jax import jax.numpy as jnp class lowerCamelCase__ ( nn.Module): '''simple docstring''' snake_case_ =42 snake_case_ =jnp.floataa def lowerCAmelCase__ (self ) -> List[str]: """simple docstring""" lowerCAmelCase...
94
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase : List[str] ={ "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "ChineseCL...
237
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black __lowerCAmelCase : Any =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 # noqa: E402...
237
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def __lowerCAmelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )-> np.ndarray: """simple docstring...
267
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> Tuple: """simple docstring""" if ( (cp >= 0X4E00 and cp <= 0X9FFF) or (cp >= 0X3...
267
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=UpperCamelCase) class snake_case__ ( UpperCamelCase): a_ = field(default="aud...
304
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
253
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase__ : Tuple = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartCo...
301
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impo...
301
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json', # See all ViT MAE models at https://huggingface.co/models?filter=...
330
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : List[Any] = { 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface.co/google/realm-c...
2
0
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import...
49
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 utils import ROUGE_KEYS loggin...
49
1
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransform...
302
# 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 appli...
302
1
from math import factorial def UpperCamelCase ( _A = 20 ): """simple docstring""" __magic_name__ : Any = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... __magic_name__ : Any = n...
352
__magic_name__: List[Any] = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __magic_name__: Dict = [{"type": "code", "content": INSTALL_CONTENT}...
138
0
"""simple docstring""" import functools from typing import Any def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase ): # Validation if not isinstance(_UpperCamelCase , _UpperCamelCase ) or len(_UpperCamelCase ) == 0: raise ValueError('the string should be not empty string' ) i...
86
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments ...
74
0
'''simple docstring''' def UpperCamelCase_ ( A__ : int , A__ : int ): '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_ ( ): '''simple docstring''' assert or_gate(0 ,...
367
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer __A : Any = {"vocab_file": "vocab.txt", "tokenizer_...
89
0
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake snake_case_ : List[Any] = numpy.array([0, 0]) snake_case_ : Optional[Any] = numpy.array([0.5, 0.8_66_02_54]) snake_case_ : int = nu...
83
def __UpperCamelCase ( _lowerCAmelCase ) -> list: """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(_lowerCAmelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("""doctest""").testmod()
116
0
"""simple docstring""" from collections.abc import Sequence def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return sum(c * (x**i) for i, c in enumerate(_UpperCamelCase ) ) def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '...
259
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.append(_UpperCamelCase ) __...
259
1
lowerCAmelCase__ = [ (1_0_0_0, '''M'''), (9_0_0, '''CM'''), (5_0_0, '''D'''), (4_0_0, '''CD'''), (1_0_0, '''C'''), (9_0, '''XC'''), (5_0, '''L'''), (4_0, '''XL'''), (1_0, '''X'''), (9, '''IX'''), (5, '''V'''), (4, '''IV'''), (1, '''I'''), ] def __low...
130
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.utils impo...
130
1
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient A_ :List[Any] = WebClient(token=os.environ['''CI_SLACK_BOT_TOKEN''']) def A ( a_...
367
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
245
0
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class A ( __UpperCAmelCase ): __snake_case = 'Wav2Vec2FeatureExtractor...
278
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
1
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _A (__a , __a , __a = "x" , __a = 10**-10 , __a = 1 , ) -> complex: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = symb...
318
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev...
318
1
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_availab...
134
'''simple docstring''' def __lowerCamelCase ( __snake_case : int, __snake_case : int, __snake_case : list[list[int]] ) -> int: """simple docstring""" def update_area_of_max_square(__snake_case : int, __snake_case : int ) -> in...
134
1
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 torch from torch.utils.data import Dataset from t...
365
from itertools import count def _A ( __magic_name__ = 50 ): lowercase__ = [1] * min_block_length for n in count(__magic_name__ ): fill_count_functions.append(1 ) for block_length in range(__magic_name__ , n + 1 ): for block_start in range(n - block_length ): ...
201
0
"""simple docstring""" class a : def __init__( self : List[Any] ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE_: dict[str, TrieNode] ={} # Mapping from char to TrieNode SCREAMING_SNAKE_CASE_: int =False ...
173
"""simple docstring""" def a__ ( lowerCAmelCase , lowerCAmelCase ) -> bool: UpperCAmelCase__ : Any = len(lowerCAmelCase ) UpperCAmelCase__ : List[Any] = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum o...
171
0
'''simple docstring''' from math import sqrt def _a( UpperCamelCase__ : int ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Dict =0 for i in range(1, int(sqrt(UpperCamelCase__ ) + 1 ) ): ...
222
'''simple docstring''' import math def _a( UpperCamelCase__ : int ): '''simple docstring''' return math.sqrt(UpperCamelCase__ ) * math.sqrt(UpperCamelCase__ ) == num def _a( UpperCamelCase__ : int ): ...
222
1
'''simple docstring''' import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_...
161
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 UpperCamelCase__ = get_tests_dir("""fixtures/spiece.mode...
92
0
__A = { "a": "AAAAA", "b": "AAAAB", "c": "AAABA", "d": "AAABB", "e": "AABAA", "f": "AABAB", "g": "AABBA", "h": "AABBB", "i": "ABAAA", "j": "BBBAA", "k": "ABAAB", "l": "ABABA", "m": "ABABB", "n": "ABBAA", "o": "ABBAB", "p": "A...
360
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_dat...
348
0
'''simple docstring''' import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def UpperCamelCase_( snake_case : Optional[i...
85
"""simple docstring""" import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm...
81
0
"""simple docstring""" from typing import Any class __lowerCamelCase : def __init__(self , lowerCamelCase ): '''simple docstring''' _lowerCAmelCase = data _lowerCAmelCase = None class __lowerCamelCase : def __init__(self...
317
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
317
1
import math def _lowercase ( lowercase__ , lowercase__ ): return math.pow(lowercase__ , 2 ) - a def _lowercase ( lowercase__ ): return 2 * x def _lowercase ( lowercase__ ): __lowerCAmelCase : str = 2.0 while start...
275
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STAND...
275
1
"""simple docstring""" # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union lowercase__ = re.compile(r'^(?P<major>\d+)' r'\.(?P<minor>\d+)' r'\.(?P<patch>\d+)$') @total_ordering @dataclass class __snak...
203
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def __a ( _SCREAMING_SNAKE_CASE ) ->Tuple: a__: Tuple = {} a__: Tuple = job['started_at'] a__: int = ...
203
1
"""simple docstring""" from collections import defaultdict class a__ : def __init__( self , _a , _a ): lowercase : List[Any] = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initially all values are ...
202
"""simple docstring""" from __future__ import annotations from functools import lru_cache from math import ceil _A : Optional[Any] = 1_00 _A : Optional[int] = set(range(3, NUM_PRIMES, 2)) primes.add(2) _A : int for prime in range(3, ceil(NUM_PRIMES**...
202
1
"""simple docstring""" UpperCamelCase_ = {str(digit): digit**5 for digit in range(10)} def UpperCamelCase ( UpperCAmelCase ) ->Union[str, Any]: """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(UpperCAmelCase ) ) def UpperCamelCase ( ) ->Any...
360
"""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 IM...
303
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenizati...
206
"""simple docstring""" from sklearn.metrics import recall_score import datasets UpperCAmelCase__ = """ Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN...
289
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices A : Tuple = logging.get_logger(__name__) A : Dict = { 'facebook/convnextv2-tiny-1k-224': 'https://...
351
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor A : List[Any] = logging.get_logger(__name__) class A ( UpperCAmelCase__ ): '''simple docstring''' def __init__(self : List[Any] , *_UpperCAm...
146
0
"""simple docstring""" import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tok...
266
"""simple docstring""" from __future__ import annotations from typing import Any def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" if not postfix_notation: return 0 __A = {'''+''', '''-''', '''*''', '''/'''} __A = [] for token in postfix_n...
266
1
class _lowercase : """simple docstring""" def __init__(self ): """simple docstring""" a = {} # Mapping from char to TrieNode a = False def UpperCamelCase_ (self , lowerCamelCase_ ): """simple docstring""" for word in words: ...
355
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from...
71
0
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requir...
285
from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=UpperCamelCase ): '''simple docstring''' __A : Any = ["flax"] def __init__( self , *__A , **__A ): """simple docstring""" ...
283
0
'''simple docstring''' class __magic_name__ : def __init__( self : Optional[Any] ): lowercase_ : int = """""" lowercase_ : str = """""" lowercase_ : Dict = [] def SCREAMING_SNAKE_CASE_ ( self ...
354
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available _lowercase : Union[str, Any] = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise Optional...
21
0
import enum import warnings from ..tokenization_utils import TruncationStrategy 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 from ..models.auto.modeling_tf_auto import TF_MODEL_FOR...
195
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimen...
195
1
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class lowerCamelCase__ ( snake_case ): def __init__( self ,*A ,**A ): super().__init__(*A ,**A ) UpperCAmelCase = {} def _UpperCamelCase ...
234
"""simple docstring""" _UpperCamelCase = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCamelCase = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCamelCase = { 0: """Sunday""", 1: """Monday""", 2: """Tuesday""", 3: """Wednesday""", 4: """Thursday""", 5: ""...
234
1
"""simple docstring""" # 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-...
247
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
1
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...
297
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableUn...
297
1
"""simple docstring""" def A ( snake_case__ , snake_case__ ): '''simple docstring''' if not (isinstance(snake_case__ , snake_case__ ) and isinstance(snake_case__ , snake_case__ )): raise ValueError("""longest_common_substring() takes two strings for in...
165
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Dict = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerC...
165
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_blenderbot''': [ ''...
369
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) f...
154
0
def A ( _lowerCamelCase = 50 ): '''simple docstring''' _lowerCAmelCase : Optional[Any] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start ...
36
'''simple docstring''' import math class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Union[str, Any] , UpperCamelCase__ : Optional[Any]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" ...
28
0
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') _SCREAMING_SNAKE_CASE = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) _SCREAMING_SNAKE_CASE ...
81
def snake_case ( ) -> Any: for n in range(1 , 1_000_000): yield n * (n + 1) // 2 def snake_case ( snake_case__ :Dict) -> Optional[Any]: _A = 1 _A = 2 while i * i <= n: _A ...
81
1
'''simple docstring''' from math import sqrt def snake_case__ ( _A: int = 1000000 ) -> int: '''simple docstring''' lowerCAmelCase = 0 lowerCAmelCase = 0 lowerCAmelCase = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides ...
272
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension fro...
168
0
def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" A : Tuple = int(__lowerCamelCase ) if decimal in (0, 1): # Exit cases for the recursion return str(__lowerCamelCase ) A , A : Any = divmod(__lowerCamelC...
368
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
115
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowerCamelCase : str = { """configuration_owlvit""": [ ...
52
def A_ ( _lowerCAmelCase = 50 ) -> int: UpperCamelCase : List[Any] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): different_co...
52
1
'''simple docstring''' # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatt...
187
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification ...
187
1
'''simple docstring''' import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def a_ ( lowerCamelCase : Tuple , lowerCamelCase : ...
4
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transfor...
351
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask ...
125
0
from typing import Dict, Optional import numpy as np import datasets lowerCamelCase = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes) or multi-clas...
199
import os import pytest from attr import dataclass lowerCamelCase = 'us-east-1' # defaults region @dataclass class A : UpperCamelCase__ : str UpperCamelCase__ : Dict ='arn:aws:iam::558105141721:role/sagemaker_execution_role' UpperCamelCase__ : int ...
199
1
from __future__ import annotations from collections.abc import Generator def lowerCAmelCase_ ( ) -> Generator[int, None, None]: """simple docstring""" a__ : dict[int, int] = {} a__ : Union[str, Any] = 2 while True: a_...
371
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class snake_case__ (A__ ): """simple docstring""" def __init__( self , __lowercase , __lowercase ) -> int: """simple docstring""" ...
266
0
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch...
193
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 a__: List[str] = False class SCREAMING_SNAKE_CASE...
193
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase: Union[str, Any] = logging.get_logger(__name__) _UpperCamelCase: Union[str, Any] = { 'sayakpaul/vit-msn-base': 'https://huggingface.c...
368
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if ...
53
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> Optional[int]: if length <= 0 or not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(SCREAMING_SNAKE_CASE__ )] if __nam...
73
from ..utils import DummyObject, requires_backends class snake_case_ ( metaclass=__A ): '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = ["note_seq"] def __init__( self : Optional[int] , *_UpperCamelCase : ...
8
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : Union[str, Any] = { """configuration_timesformer""": ["""TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimesformerConfig"""], } try: if not is_torc...
355
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate dep...
286
0
"""simple docstring""" from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class a ( _lowerCamelCase ): """simple docstring""" def __init__( self: ...
335
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_...
335
1
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast fro...
29
UpperCAmelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCAmelCase_ = ['a', 'b', 'c', 'd', 'e'] def lowerCamelCase__ ( A__ : Union[str, Any] , A__ : Optional[int] , A__ : str ): '''simple docstring''' __lowerCamelCase ...
29
1
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusi...
56
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef lowerCamelCase = ( """This metric will be removed from the lib...
166
0
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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_mod...
126
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ...
126
1
import math def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase )-> float: '''simple docstring''' if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial inten...
348
import argparse import math import traceback import dateutil.parser as date_parser import requests def a ( A__ : Dict ) -> str: """simple docstring""" _lowercase ={} _lowercase =job['started_at'] _lowercase =job['com...
205
0
"""simple docstring""" from math import factorial A: dict[str, int] = {str(digit): factorial(digit) for digit in range(1_0)} def _snake_case ( UpperCamelCase : int ): if not isinstance(UpperCamelCase , UpperCamelCase ): raise TypeError("""Parameter number m...
76
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def _snake_case ( UpperCamelCase : str ): def decorator(UpperCamelCase : Optional[int] ): UpperCAmelCase : List[Any] = getattr(UpperCamelCase , """handle_key""" ,...
76
1