code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params impo...
458
from __future__ import annotations import numpy as np def __magic_name__ ( lowercase ) -> Tuple: """simple docstring""" return np.maximum(0 , lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
458
1
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def lowercase ( _a ,_a ,_a ,_a ) -> Union[str, Any]: UpperCAmelCase_: str = s.rsplit(_a ,_a ) return new.join(_a ) def lowercase ( _...
710
_lowerCAmelCase = frozenset( [ """prompt""", """height""", """width""", """guidance_scale""", """negative_prompt""", """prompt_embeds""", """negative_prompt_embeds""", """cross_attention_kwargs""", ] ) _lowerCAmelCase = ...
306
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCAmelCase__ : List[str] = logging.get_logger(__name__) class lowerCAmelCase_ (a__ ): """simple docstring""" ...
223
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent UpperCAmelCase__ : Optional[Any] = {'UserAgent': UserAgent().random} def lowercase_ ( _snake_case ): SCREAMIN...
223
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"]} t...
708
def lowerCAmelCase_ ( lowercase: float ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(lowercase , lowercase ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def lowerCAmelCase_ ...
264
0
'''simple docstring''' from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput ...
22
from __future__ import annotations def _UpperCAmelCase ( a__): '''simple docstring''' if len(a__) == 0: return [] a_ , a_ : List[Any] = min(a__), max(a__) a_ : Tuple = int(max_value - min_value) + 1 a_ : list[list] = ...
540
0
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position snake_case__ : Dict = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < versi...
707
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor snake_case__ : List[str] = logging.get_logger(__name__) class _a ( UpperCAmelCase__ ): """simple docstring""" def __init__( ...
618
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowerCAmelCase_ = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and Mik...
326
from __future__ import annotations def A_ ( lowercase_ ) -> bool: _snake_case : Tuple = str(lowercase_ ) return len(lowercase_ ) == 9 and set(lowercase_ ) == set('''123456789''' ) def A_ ( ) -> int | None: for base_num in range(9999 , ...
326
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github SCREAMING_SNAKE_CASE__ = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] ...
711
"""simple docstring""" import os import string import sys SCREAMING_SNAKE_CASE__ = 1 << 8 SCREAMING_SNAKE_CASE__ = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, ...
104
0
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate __A =TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('''''', '''|''', '''|'''), datarow=DataRow(''''''...
463
"""simple docstring""" import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_...
617
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class SCREAMING_SNAKE_CASE ( ...
218
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """weiweishi/roc-bert-base-zh""": """https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json""", } class SCRE...
218
1
from __future__ import annotations def a ( A__ ) -> list[int]: '''simple docstring''' if len(A__ ) == 0: return array SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = min(A__ ), max(A__ ) # Compute th...
35
"""simple docstring""" def __snake_case ( ) -> Union[str, Any]: lowercase : str = 0 for i in range(1 ,1001 ): total += i**i return str(__A )[-10:] if __name__ == "__main__": print(solution())
607
0
'''simple docstring''' from __future__ import annotations def _UpperCAmelCase ( _UpperCamelCase : list[int], _UpperCamelCase : int ) -> list[int]: A_ = 0 A_ = len(_UpperCamelCase ) - 1 while i < j: if nums[i] + nums[j] == ...
716
'''simple docstring''' from itertools import product def _UpperCAmelCase ( _UpperCamelCase : int, _UpperCamelCase : int ) -> list[int]: A_ = sides_number A_ = max_face_number * dice_number A_ = [0] * (max_total + 1) ...
174
0
'''simple docstring''' 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_...
26
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer...
117
0
from __future__ import annotations import unittest from transformers import RoFormerConfig, 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_attenti...
641
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 ( ...
641
1
from collections.abc import Sequence def UpperCamelCase ( snake_case__ , snake_case__): return sum(c * (x**i) for i, c in enumerate(lowercase_)) def UpperCamelCase ( snake_case__ , snake_case__): lowerCAmelCase_ : Tuple = 0.0 for coeff in reversed(lowerc...
659
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin ...
661
0
from math import factorial def __A ( _A = 100 ): """simple docstring""" return sum(int(_A ) for x in str(factorial(_A ) ) ) if __name__ == "__main__": print(solution(int(input("""Enter the Number: """).strip())))
525
def __A ( _A ): """simple docstring""" __a = [] for data in source_data: for i, el in enumerate(_A ): if len(_A ) < i + 1: data_lists.append([] ) data_lists[i].append(float(_A ) ) return data_lists def __A ( _A , _A ): ...
525
1
from __future__ import annotations def lowerCamelCase_ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: raise ValueError('''daily_inter...
141
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 t...
141
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __UpperCAmelCase : Optional[Any] = (3, 9, -11, 0, 7, 5, 1, -1) __UpperCAmelCase : int = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class lowerCamelCase : UpperCAmelCase : ...
712
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def lowerCamelCase_ ( UpperCamelCase_ = 8 ): _a : int = ascii_letters + digits + punctuation return "".join(secrets.choice(UpperCamelCase_ ) fo...
249
0
"""simple docstring""" from random import randint, random def _UpperCamelCase ( A , A , A , A = False , A = False , A = 5 , ): UpperCamelCase_ =[[-1] * number_of_cells] # Create a highway without any car UpperCamelCase_ ...
391
'''simple docstring''' from statistics import mean, stdev def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 3 ): __a : List[str] = min(SCREAMING_SNAKE_CASE__ ) __a : Tuple = max(SCREAMING_SNAKE_CASE...
597
0
"""simple docstring""" def snake_case__ ( __lowerCamelCase : str , __lowerCamelCase : str ): """simple docstring""" if not (isinstance(__lowerCamelCase , __lowerCamelCase ) and isinstance(__lowerCamelCase , __lowerCamelCase )): raise ValueError(''...
705
"""simple docstring""" 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, ) _lowercase : Optional[Any] = { "conf...
625
0
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def _SCREAMING_SNAKE_CASE...
239
from collections.abc import Iterable from typing import Any class _A: """simple docstring""" def __init__( self , _A = None ): __A : Any = value __A : Node | None = None # Added in order to delete a node easier __A :...
239
1
def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ) ->str: _UpperCAmelCase ="" for word_or_phrase in separated: if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separator ret...
592
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 snake_case__ : Union[str, Any] = logging.get_logger(__name__) snake_case__ : Union[st...
592
1
'''simple docstring''' import datasets UpperCAmelCase__ = '''\ @InProceedings{conneau2018xnli, author = "Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. and Schwenk, H...
186
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
186
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class lowerCAm...
188
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import Fla...
188
1
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
31
def __magic_name__ ( __lowerCAmelCase : Any , __lowerCAmelCase : Optional[int] ) -> Optional[Any]: __lowerCamelCase = [1] for i in range(2 , __lowerCAmelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * ...
298
0
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_comm...
427
'''simple docstring''' from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be check...
427
1
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.schedul...
14
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_enco...
14
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase__ : Tuple = { "configuration_poolformer": [ "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PoolFormerConfig", "Po...
719
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 UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : O...
620
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ...
208
'''simple docstring''' def snake_case ( a_ : list ) -> list: """simple docstring""" UpperCamelCase_ : List[str] = False while is_sorted is False: # Until all the indices are traversed keep looping UpperCamelCase_ : Tuple ...
208
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_commo...
489
'''simple docstring''' 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 _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE ...
489
1
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def lowercase__ ( snake_case_ :list[list[float]] ): __UpperCAmelCase = Decimal # Check if the provided matrix has 2 rows and 2 columns # since ...
49
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class __SCREAMING_SNAKE_CASE ( _lowerCAmelCase ): def __init__( self , *lowerCamelCase , **lowerCamelCase ) ->Union[str, Any]: '''simple docstring''' ...
448
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""", """data...
83
def snake_case ( snake_case__ :int , snake_case__ :int) -> int: return int(input_a == input_a == 0) def snake_case ( ) -> None: print("""Truth Table of NOR Gate:""") print("""| Input 1 | Input 2 | Output |""") print(F'''| 0 ...
83
1
def __UpperCAmelCase ( __A , __A ) -> int: '''simple docstring''' return abs(__A ) if a == 0 else greatest_common_divisor(b % a , __A ) def __UpperCAmelCase ( __A , __A ) -> int: '''simple d...
475
def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase ) ->int: """simple docstring""" return abs(UpperCAmelCase ) if a == 0 else greatest_common_divisor(b % a, UpperCAmelCase ) def lowerCAmelCase ( UpperCAmelCase, ...
154
0
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import loggin...
557
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 SCREAMING_SNAKE_CASE_ ( _a ): """simple docstring...
557
1
# flake8: noqa # Lint as: python3 lowerCamelCase : Any = [ "VerificationMode", "Version", "disable_progress_bar", "enable_progress_bar", "is_progress_bar_enabled", "experimental", ] from .info_utils import VerificationMode from .logging import disabl...
70
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase ) -> int: '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def __magic_name__ ( ) -> None: '''simple docstring''' assert and_...
640
0
"""simple docstring""" def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> Any: # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) lowerCAmelCase__ : List[Any] = (boundary[1] - boundary[0]) / steps lowerCAmelCase__ : Opt...
705
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class _lowerCamelCase ( nn.Module ): def __init__( self : Optional[Any] , UpperCamelCase : int = 16 , UpperCamelCase : int ...
507
0
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch....
50
lowerCamelCase_ : Tuple = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottametre""": """Ym""", } # Expo...
548
0
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class SCREAMING_SNAKE_CASE__ ( unittest.TestCase): @requir...
718
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class SCREAMING_SNAKE_CASE__ ( tf.keras.layers.Layer): ...
432
0
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokeniz...
663
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterM...
663
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase ): """simple docstring""" return x if y == 0 else greatest_common_divisor(_UpperCamelCase , x % y ) def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamel...
721
'''simple docstring''' from math import factorial _lowerCAmelCase = {str(d): factorial(d) for d in range(10)} def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(UpperCamelCase ) ) def _SCREAMING_SNAKE_CA...
160
0
'''simple docstring''' from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils i...
640
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _UpperCamelCase ( unittest.TestCase ): """simple docstring""" def _SCREAMING_SNAKE_CASE ( self ) -> int: '''simple docstring''' ...
534
0
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested ...
666
'''simple docstring''' import sys __lowerCAmelCase = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '1254069874715852386305071569329096329522...
666
1
'''simple docstring''' import numpy as np import datasets lowerCAmelCase_ = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distanc...
531
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW fro...
531
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ :Union[str, Any] = { '''configuration_luke''': ['''LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LukeConfig'''], '''tokenization_luke''': ['''LukeTokenizer'''], }...
154
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) A_ :Dict = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block''': 2, '...
154
1
'''simple docstring''' def lowerCAmelCase (__A): """simple docstring""" _a = 0 while len(a__) > 1: _a = 0 # Consider two files with minimum cost to be merged for _ in range(2): _a = files.index(min(a__))...
11
'''simple docstring''' from collections import deque class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : int , snake_case : str , snake_case : int , snake_case : int ): """simple docstring""" ...
517
0
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __lowerCAmelCase : Dict =["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def UpperCAmelCase__ ( lowerCAmelCase__ :Dict , lowerCAmelCase__ :O...
197
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy...
197
1
'''simple docstring''' def __UpperCamelCase( _A : str , _A : str = " " ): '''simple docstring''' UpperCAmelCase__ : List[Any] = [] UpperCAmelCase__ : Any = 0 for index, char in enumerate(_A ): if char == separator: split_words.append(...
614
'''simple docstring''' import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def __UpperCamelCase( _A : Any , _A : List[str]=() , _A : List[str]=None ...
614
1
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
718
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[str] = { '''google/pix2struct-textcaps-base''': ...
581
0
from __future__ import annotations def UpperCamelCase ( __lowercase : list[int] ,__lowercase : int ): '''simple docstring''' if len(__lowercase ) < k or k < 0: raise ValueError('Invalid Input' ) A_ : Dict = sum(array[:k] ) for i ...
558
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
1
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :Tuple , __magic_name__ :Optional[int] ): if b == 0: return (1, 0) (UpperCAmelCase_) = extended_euclid(__magic_name__ , a % b ) UpperCAmelCase_ = a // ...
719
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def _lowerCAmelCase ( __magic_name__ :list , __magic_name__ :list , __magic_name__ :list , ...
407
0
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor ...
2
def A__ ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase = str(bin(SCREAMING_SNAKE_C...
32
0
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class __UpperCAmelCase : '''simple docstring''' def __init__( self , _UpperCAmelCase...
599
'''simple docstring''' def lowerCAmelCase__ ( a_ : float , a_ : list[float] ) -> float: if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: raise ValueError('''Cash flows list cannot be emp...
599
1
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_opt...
2
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 transfo...
2
1
import argparse import copy def UpperCamelCase_( __magic_name__ : Tuple ): """simple docstring""" _lowerCAmelCase :int = {} with open(__magic_name__ ) as f: for line in f: if line.split()[0] not in dict_o...
708
from __future__ import annotations from math import pow, sqrt def UpperCamelCase_( __magic_name__ : float , __magic_name__ : float , __magic_name__ : float ): """simple docstring""" if (resistance, reactance, impedance).count(0 ) != 1: ...
382
0
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lower...
590
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) A_ : List[Any] = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LxmertConfig'...
303
0
class _a : '''simple docstring''' def __init__( self ): __A : Union[str, Any] = "" __A : Optional[Any] = "" __A : Dict = [] def __UpperCAmelCase( self , __UpperCAmelCase , __UpperCAmelCase ): ...
714
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, Diffusio...
387
0
'''simple docstring''' import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def UpperCAmelCase_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_...
310
'''simple docstring''' from math import sqrt def UpperCAmelCase_ ( lowerCAmelCase_ ): """simple docstring""" lowercase = 0 for i in range(1 , int(sqrt(lowerCAmelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCAmelCase_ ): total...
310
1
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ...
105
def SCREAMING_SNAKE_CASE ( lowerCAmelCase ): _UpperCamelCase = 0 for ch in input_str: _UpperCamelCase = ord(lowerCAmelCase ) _UpperCamelCase = pow(2 , lowerCAmelCase ) # I...
105
1
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 lowerCamelCase_ ( _SC...
31
from __future__ import annotations from typing import TypedDict class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = 42 lowercase_ = 42 def UpperCAmelCase_ ( __UpperCAmelCase : str ) -> list[str]:...
31
1
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
715
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE_ ( _a , unittest.TestCase ): """simple docstring""" __low...
557
0
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 ( IMAG...
291
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_atten...
510
0
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: if exponent == 1: return base if exponent % 2 == 0: A =_modexpt(a_ , exponent // 2 , a_ ) % modulo_value return (x * x) % modulo_value else: return (base * _modexpt(a_ , exponent - 1 ...
689
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __a = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitle = \"Proceedings of the Tenth Wo...
689
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : Union[str, Any] = { """configuration_convnext""": ["""CONVNEXT_PRETRAINED_CONFI...
141
'''simple docstring''' import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ...
448
0
'''simple docstring''' def _a ( __UpperCamelCase ): if len(__UpperCamelCase ) <= 1: return [tuple(__UpperCamelCase )] a_ : List[Any] = [] def generate(__UpperCamelCase , __UpperCamelCase ): a_ : Optional[Any] = [0] * n ...
720
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __lowerCamelCase = ( '''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''', '''K...
478
0
UpperCAmelCase_ = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottametre""": """Ym""", }...
2
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A_ ( __UpperCamelCase ): '''simple docstring''' __snake_case = ["""image_processor""", """tokenizer"""] __snake_case = """CLIPImageProcessor"""...
669
0
import qiskit def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ ): lowerCamelCase_ = qiskit.Aer.get_backend("aer_simulator" ) lowerCamelCase_ = qiskit.QuantumCircuit(4 , 2 ) # encode inputs in qubits 0 and 1 if bita == 1: qc...
313
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 .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
313
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class a ( lowercase__ ): ...
63
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_image...
78
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __lowerCAmelCase = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIV...
719
'''simple docstring''' 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_tor...
319
0
"""simple docstring""" def lowerCAmelCase__ ( __magic_name__ = 1_0 ) ->str: if not isinstance(__magic_name__ , __magic_name__ ) or n < 0: raise ValueError("Invalid input" ) __lowercase = 1_0**n __lowercase = 2_8_4_3_3 * (pow(2 ,...
118
"""simple docstring""" import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger _lowercase = get_logger(__name__) class __a ( enum.Enum ): '''simple docstring''' ...
118
1
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, Res...
146
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 ConfigTes...
146
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_...
70
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import...
70
1
import os import sys import transformers __lowerCAmelCase : str = '''3''' print('''Python version:''', sys.version) print('''transformers version:''', transformers.__version__) try: import torch print('''Torch version:''', torch.__version__) print('''Cuda available:''', torch.c...
705
"""simple docstring""" import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): ...
158
0
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchv...
83
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } cla...
609
0
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, requ...
619
from __future__ import annotations def lowerCAmelCase ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , )-> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values''' ) elif electron_conc < 0: rai...
619
1
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor A__ = logging.get_logger(__name__) class _lowerCAmelCase ( __lowercase ): def __init__( self : List[Any] , *__snake_case : List[Any] , ...
166
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokenizati...
298
0
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_re...
657
# 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 a...
657
1
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer A_ : Optional[int] = logging.get_logger(__name__) A_ : Optional[Any] ...
57
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.util...
221
0
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger lowerCAmelCase_ : Dict = '''<<<<<<< This should probably be modified because it m...
378
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchau...
378
1
from __future__ import annotations from math import gcd def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase = 2 , __lowerCAmelCase = 1 , __lowerCAmelCase = 3 , ) -> int | None: """simple docstring""" if num < 2: raise ValueError('''The...
252
from __future__ import annotations from typing import Any class a : def __init__( self :Union[str, Any] ,__lowercase :int ,__lowercase :int ,__lowercase :float = 0 ): snake_case__ , snake_case__ : Dict = row, column snake_case__ : Tuple ...
252
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available lowerCAmelCase = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDe...
675
def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> list: '''simple docstring''' __UpperCAmelCase : Optional[Any] = int(lowercase_ ) if n_element < 1: __UpperCAmelCase : str = ValueError('''a should be a positive number''' ) ...
675
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __snake_case = { """configuration_efficientformer""": [ """EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
658
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__lowerCamelCase ) class UpperCAmelCase ( __lowerCamelCase ): a__: str = fi...
583
0
"""simple docstring""" import gc import threading import time import psutil import torch class __snake_case: def __init__( self ): '''simple docstring''' _SCREAMING_SNAKE_CASE = psutil.Process() _SCREAMING_SNAKE_...
168
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A__ ( UpperCamelCase__ ): '''simple docstring''' if ( (cp >= 0x4E00 and cp <= 0x...
168
1
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def snake_case__ ( _A: Optional[int] , _A: Union[str, Any] , _A: Any ) ->...
370
'''simple docstring''' from collections.abc import Sequence def a_ ( __snake_case : Sequence[float] , __snake_case : float ) -> float: """simple docstring""" return sum(c * (x**i) for i, c in enumerate(__snake_case ) ) def a_ ( __snake_case : Se...
676
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy __lowerCAmelCase = logging.get_logg...
712
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Sque...
319
0
'''simple docstring''' 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 lowerCAmelCase_ ( _lowerCamelCase: Union[dict, list, tup...
578
# 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...
419
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING a = logging.get_logger(__name__) a = { 'SenseTime/deformable-detr': 'https://huggingface.co/sensetime/def...
347
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class a_ ( snake_cas...
347
1
'''simple docstring''' 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_uti...
158
'''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_common import Mode...
158
1
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A ( a ): __UpperCAmelCase : ...
691
'''simple docstring''' __snake_case : List[str] = "Tobias Carryer" from time import time class A : def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_=int(time() ) ) -> str: # noqa: B008 _a = mul...
691
1
"""simple docstring""" import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets lowerCamelCase_ = '''\ @article{hendrycksmath2021, title={Measuring Mathematical Problem Solving With the MATH Dataset}, author={Dan Hendrycks and Collin Burns and Saurav K...
95
'''simple docstring''' import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): ...
446
0
"""simple docstring""" from functools import lru_cache def a__ ( __lowercase ) -> set: _A = 2 _A = set() while i * i <= n: if n % i: i += 1 else: n //= i factors.add(__lowercase ) if n > 1: ...
718
"""simple docstring""" import numpy as np def a__ ( __lowercase , __lowercase ) -> np.ndarray: return np.where(vector > 0 , __lowercase , (alpha * (np.exp(__lowercase ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
621
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( AutoCon...
309
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel...
309
1
"""simple docstring""" snake_case_ : List[str] = 6_5_5_2_1 def lowercase_ ( _lowercase : str ): '''simple docstring''' UpperCAmelCase : Dict = 1 UpperCAmelCase : Optional[int] = 0 for plain_chr in plain_text: UpperCA...
712
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_av...
292
0
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase: Any = logging.get_logger(__name__) _lowercase: List[Any] = {"""vocab_file""": """sentencepiec...
192
"""simple docstring""" import colorsys from PIL import Image # type: ignore def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): UpperCamelCase : Optional[int] = x UpperCamelCase : str = ...
102
0
"""simple docstring""" from __future__ import annotations def lowerCAmelCase__ ( lowerCamelCase__ , lowerCamelCase__ ) -> list[tuple[int, int]]: A , A = position A = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1,...
109
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCAmelCase__ ( ) -> Optional[Any]: import os as original_os from os import path as original_path from os import rename as original_rename ...
109
1
'''simple docstring''' from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_uti...
116
'''simple docstring''' def lowerCamelCase__ ( __lowercase ): if not isinstance(__lowercase , __lowercase ): snake_case : int = F'''Input value of [number={number}] must be an integer''' raise TypeError(__lowercase ) ...
116
1
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_common import Sequen...
708
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""", ...
70
0
def lowerCamelCase_ ( UpperCamelCase__ : str, UpperCamelCase__ : Any ): '''simple docstring''' UpperCamelCase__ = (boundary[1] - boundary[0]) / steps UpperCamelCase__ = boundary[0] UpperCamelCase__ = boundary[1]...
240
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.ut...
240
1
"""simple docstring""" from bisect import bisect from itertools import accumulate def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): """simple docstring""" __A = sorted(zip(__UpperCamelCase , __UpperCamelCase ) , key...
703
"""simple docstring""" lowercase_ = 8.31_4462 # Unit - J mol-1 K-1 def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): """simple docstring""" if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('''Invalid inputs. Enter positiv...
215
0
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase : Dict = transf...
568
from __future__ import annotations def a_ ( lowerCAmelCase_ : list[float] ): if len(lowerCAmelCase_ ) < 2: raise ValueError('Monogons and Digons are not polygons in the Euclidean space' ) if any(i <= 0 for i in nums ): raise ValueError('All values must be g...
53
0
"""simple docstring""" def lowercase__ ( lowercase_ ) -> list[list[int]]: """simple docstring""" _UpperCamelCase : List[str] = [] if len(lowercase_ ) == 1: return [nums.copy()] for _ in range(len(lowercase_ ) ): _Upper...
710
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
51
0