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 json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.uti...
4
"""simple docstring""" def __lowerCAmelCase ( lowercase : int ) -> bool: """simple docstring""" if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True snake_case : Dict = 4 snake_case : str ...
203
0
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(): ...
113
# 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 ...
113
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable snake_case_ : Union[str, Any] = {"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXConfig"]} ...
51
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : str = {} class __snake_case ( a ): UpperCAmelCase__ : str = '''llama''' UpperCAmelCase__ : ...
51
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.ut...
128
"""simple docstring""" def a_ ( _lowercase = 100 ): _UpperCamelCase : List[Any] = 0 _UpperCamelCase : Optional[Any] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i ...
128
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : List[Any] = logging.get_logger(__name__) a__ : List[Any] = { '''google/bit-50''': '''https://hu...
313
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ : Optional[Any] = logging.get_logger(__name__) a__ : List[str] = { '''kssteven/ibert-roberta-base''': ...
313
1
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if ...
356
"""simple docstring""" def __a ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): # Return True if there is node that has not iterated. UpperCAmelCase_ : List[Any] = [False] * len(__lowerCamelCase ) UpperCAmelCase_ : Any = [] queue.append...
23
0
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 UpperCAmelCase_ : Any = 0B1011_0011_1110_1100_1001_0000_0111_1011_1011_0001...
38
'''simple docstring''' import os def lowerCamelCase ( UpperCAmelCase__ : str = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(UpperCAmelCase__ ) , UpperCAmelCase__ ) ) as input_file: lowercase_ : str = [ ...
239
0
'''simple docstring''' import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class a_ ( _lowe...
359
'''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, ) lowerCAmelCase : int ...
147
0
'''simple docstring''' from __future__ import annotations SCREAMING_SNAKE_CASE_: Any =[] def lowerCAmelCase_ ( snake_case_ : list[list[int]] , snake_case_ : int , snake_case_ : int ) -> bool: '''simple docstring''' for i in range(len(snak...
1
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import s...
1
1
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configurati...
360
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCAmelCase : Optional[int] = logging.get_logger(__name__...
202
0
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgu...
211
'''simple docstring''' import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokeni...
211
1
"""simple docstring""" from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE_ ( snake_case : list[Any] )-> None: create_state_space_tree(snake_case , [] , 0 ) def SCREAMING_SNAKE_CASE_ ( snake_case : list[Any] , snake_case ...
367
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : list )-> list: def merge(snake_case : list , snake_case : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0...
80
0
'''simple docstring''' from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging _lowerCAmelCase = logging.get_logger(__name__) def _SCREAMING_SNAKE...
37
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ , lowerCAmelCase__ : List[str] = an...
37
1
"""simple docstring""" import os from pathlib import Path def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ) -> str: """simple docstring""" lowerCAmelCase__ : List[str] = { """en""": """Machine learning is great, isn't it...
360
"""simple docstring""" from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import fl...
212
0
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_modeling_common import Model...
275
import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from ....
275
1
def a ( SCREAMING_SNAKE_CASE_ : Optional[Any] , SCREAMING_SNAKE_CASE_ : List[Any] , SCREAMING_SNAKE_CASE_ : Optional[Any] , SCREAMING_SNAKE_CASE_ : Optional[int] ): global f # a global dp table for knapsack if f[i][j] < 0: ...
355
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __UpperCAmelCase : str = logging.get_logger(__name__) def a ( SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : Optional...
315
0
'''simple docstring''' class _a : '''simple docstring''' def __init__( self ): '''simple docstring''' SCREAMING_SNAKE_CASE : Any = 0 SCREAMING_SNAKE_CASE : str = 0 ...
251
'''simple docstring''' class _a : '''simple docstring''' def __init__( self ): '''simple docstring''' SCREAMING_SNAKE_CASE : Any = 0 SCREAMING_SNAKE_CASE : str = 0 ...
251
1
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin fr...
308
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _lowerCAmelCase : Optional[Any] = numpy.array([0, 0]) _lowerCAmelCase : Dict = numpy.array([0.5, 0.8660254]) _lowerCAmelCase : Any = ...
308
1
'''simple docstring''' import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class ...
28
'''simple docstring''' import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_...
23
0
from pathlib import Path import fire from tqdm import tqdm def A_ ( _lowerCAmelCase="ro" , _lowerCAmelCase="en" , _lowerCAmelCase="wmt16" , _lowerCAmelCase=None ) -> List[str]: try: import datasets except (ModuleNotFoundError, ImportError): ra...
365
from scipy.stats import spearmanr import datasets __lowerCamelCase : List[str] = """ The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive...
140
0
'''simple docstring''' from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def UpperCamelCase_ ( snake_case_ : Namespace ) -> Any: '''simple docstring''' return ConvertCommand( ...
229
'''simple docstring''' def UpperCamelCase_ ( snake_case_ : int , snake_case_ : int ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) __lowerCAmelCase =...
229
1
def __lowercase ( _UpperCamelCase, _UpperCamelCase ) ->list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(_UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
173
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_cards - use...
173
1
'''simple docstring''' def __UpperCAmelCase ( a_: Tuple, a_: List[str], a_: List[str] ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(a_, n - 1, a_ ) * a) % mod else: _UpperCAmelCase : Any = binary...
145
'''simple docstring''' def __UpperCAmelCase ( a_: str, a_: str ): if len(a_ ) != len(a_ ): raise ValueError("String lengths must match!" ) _UpperCAmelCase : Dict = 0 for chara, chara in zip(a_, a_ ): if chara != chara: ...
145
1
"""simple docstring""" from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ): __SCREAMING_SNAKE_CASE = HfArgumentParser(UpperCamelCase_ ) __SCREAMING_SNAKE_CASE = parser.parse_args_into_dataclasses()[0] __SCREAMIN...
354
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): while b: __SCREAMING_SNAKE_CASE ,__SCREAMING_SNAKE_CASE = b, a % b return a def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): return a if b == 0 else euclidean_gcd_r...
255
0
"""simple docstring""" from __future__ import annotations def lowercase ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : int | None = None , _SCREAMING_SNAKE_CASE : int | None = None ): '''simple docstring''' if star...
260
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging __A : Union[str, Any] = "\\n\n" __A : Any = "\nPerplexity...
260
1
'''simple docstring''' import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="%(message)s") def SCREAMING_SNAKE_CASE__ ( __A ) -> np.ndarray: return input_array.reshape((input_array.size, 1) ) def ...
160
'''simple docstring''' class __UpperCAmelCase : def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case = name _snake_case = value _snake_case ...
160
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase_ = { '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''], } try: if not is_torch_available(): raise Option...
279
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torc...
279
1
import cva import numpy as np class UpperCamelCase__ : '''simple docstring''' def __init__( self : str ,lowerCamelCase__ : str ,lowerCamelCase__ : int ) -> Optional[Any]: '''simple docstring''' if k in ...
353
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ = {"""configuration_reformer""": ["""REFORMER_PRETRAINED_CONFIG_...
193
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorf...
70
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
0
def __lowerCamelCase ( lowerCamelCase__ : int , lowerCamelCase__ : int ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) lowerCamelCase = str(bin(lowerCamelCase__ ) )[2:] ...
66
def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = [] lowerCamelCase = 1 while len(lowerCamelCase__ ) < 1E6: constant.append(str(lowerCamelCase__ ) ) i += 1 lowerCamelCase = """""".join(lowerCamelCase__ ...
66
1
'''simple docstring''' from datetime import datetime import requests def _A ( A__ ): """simple docstring""" __lowercase = '''https://downloadgram.net/wp-json/wppress/video-downloader/video?url=''' __lowercase = requests.get(base_url + url ).json()[0]['''urls''']...
104
"""simple docstring""" _UpperCamelCase: Dict = [ 9_9_9, 8_0_0, 7_9_9, 6_0_0, 5_9_9, 5_0_0, 4_0_0, 3_9_9, 3_7_7, 3_5_5, 3_3_3, 3_1_1, 2_8_8, 2_6_6, 2_4_4, 2_2_2, 2_0_0, 1_9_9, 1_7_7, 1_5_5, ...
255
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
369
# 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 ap...
189
0
'''simple docstring''' def lowercase__ ( __lowercase : Union[str, Any] , __lowercase : List[Any] , __lowercase : Optional[int] ) -> Any: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_...
53
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __snake_case :Optional[int] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generati...
49
0
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import S...
370
"""simple docstring""" def _A ( _a : int ): """simple docstring""" A = abs(_a ) A = 0 while n > 0: res += n % 1_0 n //= 1_0 return res def _A ( _a...
77
0
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split lowercase__ : Tuple = datasets.load_iris() lowercase__ : Union[str, Any] = np.array(data['data']) lowercase__ : Lis...
324
"""simple docstring""" import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats...
153
0
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import...
244
"""simple docstring""" import math def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase = 0 UpperCamelCase = 0 while num > 0: UpperCamelCase = num % 8 UpperCamelCase = octal + (remainder * math.floor(math.pow(10 , _SCREAMING_SNAKE_CAS...
244
1
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase ...
69
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> int: while a != 0: snake_case_ , snake_case_ = b % a, a return b def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> int: ...
69
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBl...
359
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from i...
226
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : str ) -> list[int]: _a : Union[str, Any] =[0 for i in range(len(_UpperCAmelCase ) )] # initialize interval's left pointer and right pointer _a , _a : List[Any] =...
276
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__: Dict = logging.get_logger(__name__) A__: Tuple = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/reso...
276
1
'''simple docstring''' import unittest import numpy as np import requests 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_...
356
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ ) -> list: if any(not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ) or x < 0 for x in sequence ): raise TypeError('Sequence must be list of non-negative integers' ) for _ in range(len(lowerCAmelCase_ ) ): ...
107
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Optional[Any] = { """vocab_file""": """voc...
14
'''simple docstring''' import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_m...
239
0
'''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 i...
31
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase: str = logging.get_logger(__name__) __lowercase: Optional[Any] = { "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/r...
31
1
lowercase_ = "Alexander Joslin" import operator as op from .stack import Stack def _snake_case( SCREAMING_SNAKE_CASE__ : str ) -> int: '''simple docstring''' A__ = {'*': op.mul, '/': op.truediv, '+': op.add, '-': op.sub} A_...
7
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( __snake_case : int = 1_00 ): '''simple docstring''' lowercase = 0 lowercase = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_...
220
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __A : List[str] = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_CONFIG_A...
371
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from...
57
0
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vis...
210
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a : str = logging.get_logger(__name__) __a : int = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""", # See all W...
210
1
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import comp...
353
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate...
23
0
'''simple docstring''' from math import factorial lowerCAmelCase_ : Optional[int] = {str(d): factorial(d) for d in range(10)} def _lowerCamelCase ( lowercase : int ) -> int: return sum(DIGIT_FACTORIAL[d] for d in str(lowercase ) ) def _lowerCame...
63
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, ...
274
0
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class A_ : '''simple docstring''' def __init__( self : List[Any] ) -> Union[str, Any]: UpperCAmelCase : List[str] = ...
280
'''simple docstring''' import argparse import json from tqdm import tqdm def UpperCamelCase( ): UpperCAmelCase : List[Any] = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=UpperCAmelCase_ , default='biencoder-nq-dev.json' ...
280
1
import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''facebook/data2vec-base-960h''': '''https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json''', # S...
244
from collections.abc import Generator def __magic_name__ ( ): '''simple docstring''' UpperCamelCase__ , UpperCamelCase__ = 0, 1 while True: UpperCamelCase__ , UpperCamelCase__ = b, a + b yield b def __magic_name__ ( __a ...
244
1
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" if not nums: raise ValueError("""List is empty""" ) return sum(UpperCamelCase ) / len(UpperCamelCase ) if __name__ == "__main_...
184
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() cl...
184
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : List[Any] =logging.get_logger(__name__) a__ : Tuple ={ '''microsoft/focal...
53
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise Option...
53
1
"""simple docstring""" 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...
355
"""simple docstring""" import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowercase__ = argparse.ArgumentParser() parser.add_argument( "...
12
0
import numpy as np def A_ ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = 1e-12 , _lowerCAmelCase = 100 , ) -> tuple[float, np.ndarray]: assert np.shape(_lowerCAmelCase )[0] == np.shape(_lowerCAmelCase )[1] # Ensure proper dimensionality. assert ...
52
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, re...
52
1
from math import factorial def a ( SCREAMING_SNAKE_CASE_ : int = 1_0_0 ): """simple docstring""" return sum(int(lowerCAmelCase__ ) for x in str(factorial(lowerCAmelCase__ ) ) ) if __name__ == "__main__": print(solution(int(input(...
366
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase : Tuple = logging.get_logger(__name__) __UpperCAmelCase : Union[str, Any] = { "kssteven/i...
315
0
"""simple docstring""" import argparse import os import re lowercase_ = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowercase_ = re.compile(r"[A-Z_]+_MAPPING...
45
import os def a ( ): '''simple docstring''' lowercase_ = os.path.join(os.path.dirname(snake_case__ ) , '''num.txt''' ) with open(snake_case__ ) as file_hand: return str(sum(int(snake_case__ ) for line in file_hand ) )[:10] ...
30
0
import os _SCREAMING_SNAKE_CASE = {"""I""": 1, """V""": 5, """X""": 10, """L""": 50, """C""": 1_00, """D""": 5_00, """M""": 10_00} def SCREAMING_SNAKE_CASE__ ( __a ): snake_case_ : Union[str, Any] = 0 snake_case_ : Union[str, Any] = 0 while ...
88
from __future__ import annotations import pandas as pd def SCREAMING_SNAKE_CASE__ ( __a , __a , __a ): snake_case_ : Optional[Any] = [0] * no_of_processes snake_case_ : Tuple = [0] * no_of_processes # Copy the burst time into remaining_time[] ...
88
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configur...
104
def a_ ( lowerCAmelCase_ : int ): if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True __lowerCAmelCase = 4 __lowerCAmelCase = (1 << p) - 1 for _ in range(p - 2 ): __lowerCAmelCase = ((s * s) - 2) % m return s =...
284
0
import os import pytest from attr import dataclass __lowerCamelCase = """us-east-1""" # defaults region @dataclass class UpperCAmelCase : A__ : Union[str, Any] = 42 A__ : Optional[Any] = "arn:aws:iam::558105141721:role/sagemaker_execution_role" ...
368
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py __lowerCamelCase = """.""" if __name__ == "__main__": __lowerCamelCase = os.path.join(REPO_PATH, """utils/documentation_tests.txt""") ...
10
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : List[Any] = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_availab...
2
'''simple docstring''' from math import isclose, sqrt def snake_case_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : float ) -> tuple[float, float, float]: UpperCAmelCase : Optional[int] = point_y /...
23
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : str = logging.get_logger(__name__) lowercase__ : List[str] = {} class a__ ( UpperCamelCase__ ): a : Union[str, Any] = "llama" a : Union[str, Any] = ...
353
def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> bool: a = 0 a = number while duplicate > 0: a , a = ...
180
0
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils im...
43
"""simple docstring""" import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline _a : i...
172
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 logging l...
278
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __A = logging.get_logger(__name__) class lowercase_ ( __lowercase ): def __init__( self : Optional[Any] , *A__ : List[Any] , **A__ : ...
278
1
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavL...
209
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config....
79
0
import sys from pathlib import Path SCREAMING_SNAKE_CASE : Tuple = Path(__file__).resolve().parents[3] / "src" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import itertools # noqa import json # noqa import os # noqa import unittest # noqa from copy impo...
362
def __magic_name__ ( __lowerCAmelCase : int , __lowerCAmelCase : int ) -> str: if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __lowerCamelCase = str(bin(__lowerCAmelCase ) )[2:] # remove th...
339
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowerCAmelCase = { '''configuration_data2vec_audio''': ['''DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Data...
298
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils impo...
12
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowercase_ = logging.get_logger(__name__) class __lowerCAmelCase ( snake_case_ ): '''simple docstring''' def __init__( self , *_a ...
355
"""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, PyTorch...
11
0
"""simple docstring""" import requests from bsa import BeautifulSoup def __magic_name__ ( lowercase = "https://www.worldometers.info/coronavirus" ): SCREAMING_SNAKE_CASE_: List[str] =BeautifulSoup(requests.get(lowercase ).text , """html.parser""" ) ...
173
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import ...
173
1
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
70
# 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, TensorFormatter, format_table, query_table, ) ...
70
1
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class UpperCAmelCase : _lowercase: int = 42 # [batch_size x 3] _lowercase: Tuple = 42 # [batch_size x 3] ...
70
'''simple docstring''' from typing import List from .keymap import KEYMAP, get_character def lowerCamelCase ( __lowerCamelCase : str ) ->Optional[int]: def decorator(__lowerCamelCase : int ): _SCREAMING_SNAKE_CASE = getattr(__lowerCamelCase , """ha...
58
0
"""simple docstring""" from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''T''') def a__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return (position - 1) // 2 def a__ ( SCR...
359
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipeli...
133
0
'''simple docstring''' import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from u...
85
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow_...
10
0
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: snake_case_ : Tuple = ArgumentParser( description=( 'P...
370
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class SCREAMING_SNAKE_CASE_ ( snake_case_ , snake_case_ ): @register_to_config def __init__( self : Optional[Any] , *, ...
88
0
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = OrderedDict( [ ...
92
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import S...
83
0
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants _SCREAMING_SNAKE_CASE = Mapping[str, np.ndarray] _SCREAMING_SNAKE_CASE = M...
217
'''simple docstring''' _SCREAMING_SNAKE_CASE = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C''']...
217
1
from math import sqrt def _snake_case( SCREAMING_SNAKE_CASE__ ) -> bool: assert isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) and ( number >= 0 ), "'number' must been an int and positive" lowercase : Union[str, Any] = True...
20
import argparse import hashlib # hashlib is only used inside the Test class import struct class A__ : def __init__( self : Dict , a : str ): '''simple docstring''' lowerCAmelCase__ : Optio...
212
0
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
369
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester ...
126
0
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 ...
149
import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( A_ = "https://www.worldometers.info/coronavirus"): UpperCamelCase__: Union[str, Any] = BeautifulSoup(requests.get(A_).text ,"html.parser") UpperCamelCase__: Tuple = soup.fi...
149
1
from functools import reduce lowercase_ = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" ...
269
class SCREAMING_SNAKE_CASE (UpperCAmelCase ): pass class SCREAMING_SNAKE_CASE (UpperCAmelCase ): pass class SCREAMING_SNAKE_CASE : def __init__( self : Dict )-> Optional[int]: """simple docstring"""...
269
1
import numpy # List of input, output pairs _UpperCAmelCase : Union[str, Any] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Dict = (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) _UpperCAmelCase ...
50
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
11
0
'''simple docstring''' def a_ ( __snake_case : list[int] ) -> int: """simple docstring""" if not numbers: return 0 if not isinstance(UpperCAmelCase__ , (list, tuple) ) or not all( isinstance(UpperCAmelCase__...
370
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __UpperCamelCase ( ...
6
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer SCREAMING_SNAKE_CASE : str = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.jso...
21
def _SCREAMING_SNAKE_CASE ( lowercase : int , lowercase : int ): '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def _SCREAMING_SNAKE_CASE ( ): '''simple docstring''' assert or_gate(0 ,...
204
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ = { 'configuration_xlm_roberta_xl': [ 'XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMRobertaXLConfig', 'XLMRobertaXL...
247
import qiskit def lowerCAmelCase_ ( __UpperCAmelCase: int , __UpperCAmelCase: int ) -> qiskit.result.counts.Counts: UpperCamelCase__ : Optional[Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on ...
247
1
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_s...
113
'''simple docstring''' 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...
58
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : List[str] ={ 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', 'XCLIPVisionConfig', ],...
94
__snake_case : Any ='\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' __snake_case : Tuple =[{'type':...
94
1
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING a =logging.get_logger(__name__) a ={ ""...
73
'''simple docstring''' import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def UpperCAmelCase_ ( __lowerCamelCase : List[str] ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" ,set() ) @pytest....
223
0
import math def A ( lowercase = 100 ) -> int: '''simple docstring''' UpperCamelCase = sum(i * i for i in range(1 , n + 1 ) ) UpperCamelCase = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squares if __name__ == "__main__...
110
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")): raise OptionalDependencyNotAvailable() except...
110
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __Uppe...
105
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, l...
146
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=_lowerCAmelCase ): lowercase : str = ["keras_nlp"] def __init__( self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): requires_backe...
369
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_util...
27
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 t...
229
def __UpperCamelCase ( lowerCAmelCase__ : int = 5_0_0_0_0_0_0_0 ): __a : int = set() __a : str = int((limit - 2_4) ** (1 / 2) ) __a : int = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): if p...
216
0
"""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 import transformers from tr...
56
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a :Dict = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: if no...
56
1
"""simple docstring""" def _lowercase ( __snake_case ) -> bool: __lowerCAmelCase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowerCAmelCase : set[int] = set() return...
269
"""simple docstring""" import gc import threading import time import psutil import torch class A__ : '''simple docstring''' def __init__( self: str) -> Optional[Any]: """simple docstring""" __lowerCAmelCase : Optional[Any] ...
269
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusion...
365
'''simple docstring''' import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __magic_name__ ( ctypes.Structure): # _fields is a specific attr expected by ctypes UpperCamelCase__ ...
21
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = prime_factors(lowerCamelCase_ ) if is_square_free(lowerCamelCase_ ): return -1 if len(lower...
21
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup A : str = logging.get_logger(__name__) class __A( a ): def...
6
0
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __snake_case : int = logging.get_logger(__name__...
58
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class A__ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def __lt__( se...
58
1
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _SCREAMING_SNAKE_CASE ( ) -> Optional[int]: import os as original_os from os import path as original_path from os import rename as original_rename from os.pa...
247
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ...
247
1
"""simple docstring""" def a__ ( __lowercase ) -> int: if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] _A = ...
358
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a_ = logging.get_logger(__name__) a_ = { "t5-small": "https://huggingface.co/t5-smal...
163
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' if len(lowerCAmelCase_ ) == 0: raise ValueError("find_max() arg is an empty sequence" ) if...
54
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ = 100_0000 ): '''simple docstring''' __SCREAMING_SNAKE_CASE = set(range(3 , lowerCAmelCase_ , 2 ) ) primes.add(2 ) for p in range(3 , lowerCAmelCase_ , 2 ): if...
54
1
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
292
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can a...
292
1
"""simple docstring""" from math import pow, sqrt def _snake_case ( *snake_case__ : float ): A = len(snake_case__ ) > 0 and all(value > 0.0 for value in values ) return result def _snake_case ( snake_case__ : float , snake_case__ : float ...
74
lowerCamelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def snake_case_ ( ): __lowercase : List[str] = input("""Enter message: """ ) __lowercase : int = input("""Enter key [alphanumeric]: """ ) __lowercase : ...
233
0
def _a ( SCREAMING_SNAKE_CASE__ : Optional[int] = 2_00_00_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = [0 for i in range(n + 1 )] SCREAMING_SNAKE_CASE__ : Union[str, Any] = 1 SCR...
363
_lowerCamelCase : dict[tuple[int, int, int], int] = {} def _a ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> int: '''simple docstring''' if late == 3 or absent == 2: ...
191
0