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 re def __UpperCamelCase ( _lowerCAmelCase ): """simple docstring""" if len(re.findall("[ATCG]" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main...
333
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase =logging.get_logger(__name__) __lowerCAmelCase ={ "huggingface/informer-tourism-monthly": ( "https://huggingface.co/huggingface/informer-tourism-mon...
333
1
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ ( __a ): """simple docstring""" __magic_name__ = (PNDMScheduler,) __magic_name_...
700
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins lowerCAmelCase : List[str] = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def lowercase (_A , _A ): ...
630
0
import os import time import numpy as np import onnxruntime as ort lowerCamelCase__ : int = '1' lowerCamelCase__ : Optional[int] = '0' lowerCamelCase__ : Optional[Any] = '1' lowerCamelCase__ : int = ort.SessionOptions() lowerCamelC...
31
'''simple docstring''' def lowerCamelCase ( lowerCamelCase : int = 10**9): A_ : Optional[int] = 1 A_ : int = 2 A_ : List[Any] = 0 A_ : Optional[Any] = 0 A_ : str = 0 while perimeter <= max_perimet...
665
0
def UpperCamelCase_ ( __SCREAMING_SNAKE_CASE, __SCREAMING_SNAKE_CASE, __SCREAMING_SNAKE_CASE ): """simple docstring""" snake_case_ : Union[str, Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total...
701
'''simple docstring''' 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 f...
92
0
'''simple docstring''' from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import * ...
109
lowerCAmelCase_ = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __lowerCAmelCase ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ) ...
678
0
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : int = 4000000 ): '''simple docstring''' _lowerCAmelCase = [0, 1] _lowerCAmelCase = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 ...
716
'''simple docstring''' import math def __a(SCREAMING_SNAKE_CASE_ : int = 100 ): '''simple docstring''' _lowerCAmelCase = sum(i * i for i in range(1 , n + 1 ) ) _lowerCAmelCase = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) ...
489
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : int, __snake_case : int ) -> int: """simple docstring""" return abs(UpperCAmelCase__ ) if a == 0 else greatest_common_divisor(b % a, UpperCAmelCase__ ) def __lowerCamelCase ( __snake_case : ...
215
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowercase = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': operator.gt, } ...
272
0
def UpperCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ) -> str: '''simple docstring''' _A= '' for word_or_phrase in separated: if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): raise Excepti...
476
from jiwer import compute_measures import datasets UpperCAmelCase_ = '''\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER and WIL: improved evaluation measures ...
476
1
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets UpperCamelCase = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wang, Alex and Singh, Ama...
66
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase = { "configuration_gpt_neo": ["GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoConfig", "GPTNeoOnnxConfig"], } try: if not is_torch_availab...
66
1
from PIL import Image def A_ ( __a : Image ): """simple docstring""" a__ , a__ = image.size a__ = 0 a__ = image.load() for i in range(__a ): for j in range(__a ): a__ = pixels[j, i] ...
351
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class __snake_case ( SCREAMING_SNAKE_CASE ,SCREA...
351
1
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_increases def __lowercase ( __lower...
335
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets snake_case : str = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and Singh, Aman...
335
1
'''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...
718
'''simple docstring''' def lowercase ( lowerCAmelCase : int = 100_0000): """simple docstring""" _A : Any = 1 _A : str = 1 _A : Dict = {1: 1} for inputa in range(2 , lowerCAmelCase): _A : Any = 0 ...
417
0
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _lowerCamelCase = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed ...
71
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowerCamelCase ( lowercase_ , lowercase_ ): ...
215
0
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __a = TypeVar("KEY") __a = TypeVar("VAL") @dataclass(frozen=UpperCamelCase_ , slots=UpperCamelCase_ ) class lowerCamelC...
703
"""simple docstring""" import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging __a = logging.get_logger(__name__) class lowerCamelCase : '''simple docstring''' _A : Union[str, Any] = None...
310
0
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
301
'''simple docstring''' from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) # pylint: disab...
301
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json''' )...
719
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils impo...
387
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 if is_torch_availa...
48
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def A ( UpperCamelCase_ : List[Any] , UpperCamelCase_ : int , UpperCamelCase_ : List[Any] ) -> Dict: '''simple docstring''' lowerCAmelC...
48
1
"""simple docstring""" 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 .tokenizati...
709
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { 'facebook/s2t-small-librispeech-asr': ( 'https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json' ...
217
0
from manim import * class lowercase ( A__ ): '''simple docstring''' def snake_case_ ( self ) -> Union[str, Any]: """simple docstring""" UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) ...
254
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "facebook/encodec_24khz": "https://huggingface.co/facebook/encodec_24khz/res...
254
1
"""simple docstring""" import argparse import json 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_wa...
705
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.a...
397
0
from __future__ import annotations import numpy as np def _lowerCAmelCase ( _lowerCAmelCase ) -> int: '''simple docstring''' return np.maximum(0 , _lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) #...
371
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( _lowerCAmelCase = "AAPL" ) -> str: '''simple docstring''' __snake_case = F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' __snake_case = BeautifulSoup...
371
1
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop,...
716
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def lowercase ( _SCREAMING_SNAKE_...
95
0
from __future__ import annotations def _lowerCAmelCase ( UpperCamelCase__: list[int] ) -> list[int]: """simple docstring""" if len(UpperCamelCase__ ) == 0: return array A , A = min(UpperCamelCase__ ), max(UpperCamelCase__ ) # Compute the variabl...
641
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
1
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowerCamelCase__ : def __init__( self : str , Upp...
708
"""simple docstring""" from __future__ import annotations def lowerCamelCase ( _UpperCamelCase : int ) -> list[int]: '''simple docstring''' __UpperCAmelCase : Tuple = 2 __UpperCAmelCase : Optional[Any] = [] while i * i <= n: ...
299
0
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() __SCREA...
236
'''simple docstring''' from manim import * class A_ ( lowerCAmelCase_ ): def lowercase ( self : Dict ): _UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) _UpperCAmelCase = Rectangle(height=0.4_6 , width=0.4_6 ...
236
1
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel A ={ 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.self', 'self.proj': '...
710
'''simple docstring''' from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): ...
358
0
from __future__ import annotations def a__ ( lowercase__ , lowercase__ , lowercase__ , ): '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 valu...
54
from __future__ import annotations def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' if len(lowercase__ ) == 0: return False UpperCAmelCase_ =len(lowercase__ ) // 2 if a_list[midpoint] == item: return True ...
54
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : int = { """configuration_upernet""": ["""UperNetConfig"""], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opt...
584
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a__ ( __SCREAMING_SNAKE_CASE ): _A = ["image_processor", "tokenizer"] _A = "CLIPImageProcessor" _A = ("CLIPTokeni...
584
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertToken...
197
# 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 a...
197
1
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import Bat...
706
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase_ = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''], } try: if not is_torch_ava...
322
0
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transform...
62
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = { """configuration_jukebox""": [ """JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """JukeboxConfig""", """JukeboxPriorConfig""", """Jukeb...
62
1
"""simple docstring""" def lowercase__(A ) ->bool: lowercase__ : Tuple= (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def lowercase__(A = 5_000 ) ->int: lowercase__ : str= [(i * (3 * i - 1)) // 2 for i in range(1 ...
715
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def lowercase__(A ) ->bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True e...
85
0
def _UpperCAmelCase (UpperCamelCase_ : int = 100 ): '''simple docstring''' _lowerCAmelCase : Any = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : Tuple = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__":...
429
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=_a ) class __snake_case (_a ): lowerCAmelCase__ = field(default="audio-classification" , metad...
429
1
'''simple docstring''' 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 r...
707
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def _lowerCAmelCase ( __magic_name__ : Dict ) -> Dict: for param in module.parameters(): lowercase : List[str] =False def _lowerCAmelCase...
88
0
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _snake_case = str(bin(_SCREAMING_SNAKE_CASE ) )[2:] # remove the leading "0b" _s...
585
"""simple docstring""" import warnings from ..trainer import Trainer from ..utils import logging __UpperCAmelCase = logging.get_logger(__name__) class lowercase_ ( a_ ): def __init__( self : int , _lowercase : List[str]=None , **_lowerca...
308
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig,...
705
_UpperCamelCase : Optional[int] = 8.31_44_62 # Unit - J mol-1 K-1 def __UpperCamelCase ( snake_case , snake_case , snake_case ) -> float: '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('''Invalid inputs. Enter...
341
0
def _lowerCamelCase ( snake_case , snake_case ): assert x is not None assert y is not None _lowerCAmelCase = len(snake_case ) _lowerCAmelCase = len(snake_case ) # declaring the array for storing the dp values _lowerCAmelCase = [[0]...
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
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging loggin...
713
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging lowerCAmelCase__: List[Any] = logging.get_logger(__name__) class snake_case_ : __lowerCamelCase : Any = None @experimental def ...
311
0
"""simple docstring""" from __future__ import annotations import typing from collections import Counter def _A( lowerCAmelCase ): A__ : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(UpperCamelCas...
363
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCAmelCase ( _snake_case ...
467
0
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand UpperCamelCase__ = ( """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""", ""...
552
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing c...
552
1
from random import randint from tempfile import TemporaryFile import numpy as np def a_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): lowerCAmelCase__ = 0 if start < end: lowerCAmelCase__ = randint(lowercase_ , lowercase_ ) low...
615
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 _a (unittest.TestCase , __magic_nam...
456
0
"""simple docstring""" import pprint import requests SCREAMING_SNAKE_CASE_ = 'https://zenquotes.io/api' def lowercase (): return requests.get(API_ENDPOINT_URL + """/today""" ).json() def lowercase (): return requests.get(API_ENDPOINT_URL + """/random""" ).json() if ...
712
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowerCAmelCase_ ( A__ ): '''simple docstring''' def A__ ( self , snake_case_ ) -> Optional[int]: ...
573
0
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __magic_name__ : Tuple = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ (_a ): def __init__( self : List[str] , *__lo...
615
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaToken...
615
1
'''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 __UpperCAm...
98
'''simple docstring''' from math import pi, sqrt, tan def _snake_case ( A ) -> float: if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def _snake_case ( A ...
98
1
import os from collections import deque import torch from torch.utils.data import Dataset class a_ ( lowercase__ ): def __init__( self , SCREAMING_SNAKE_CASE="" , SCREAMING_SNAKE_CASE="train" ) -> Any: """simple docstring""" assert os.p...
205
import inspect import unittest from transformers import YolosConfig 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_configuration_common import ConfigTester from ...test_mo...
579
0
'''simple docstring''' import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import (...
707
'''simple docstring''' from PIL import Image def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE_ :List[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(SCREAMING_SNAKE_CASE ) -> int: return int(128 + f...
233
0
'''simple docstring''' import unittest from knapsack import knapsack as k class a__ ( unittest.TestCase ): '''simple docstring''' def lowerCAmelCase ( self : Optional[Any] ) -> Optional[Any]: __A= 0 __A= [0] __A= [0] __A= len(lowerCAme...
186
'''simple docstring''' # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git w...
186
1
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _SCREAMING_SNAKE_CASE ( _lowerCAmelCase ): a_ : Union[str, Any] = '''''' a_ : Dict = ( None # protocol passed i...
703
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_increases def SCREAMING_SNAKE_CASE ( ...
142
0
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
11
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' _lowercase : Tuple = (DDPMScheduler,) def _lowercase...
5
0
'''simple docstring''' from collections.abc import Sequence def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase = False ) -> float: '''simple docstring''' if not arr: return 0 __SCREAMING_SNAKE_CASE = 0 if allow_empty_subarrays...
701
'''simple docstring''' import sys from collections import defaultdict class __a : def __init__( self : Dict ): '''simple docstring''' __SCREAMING_SNAKE_CASE = [] def UpperCAmelCase__ ( self : List[Any] ,lowerCamelCase : ...
13
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, BlipImagePro...
201
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase = { 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeTowerConfig', 'BridgeTowerTextCo...
201
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_...
710
"""simple docstring""" import os import re import shutil import sys import tempfile import unittest import black A = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_copies # noqa: E402 # This is ...
487
0
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.mode...
103
"""simple docstring""" from copy import deepcopy class UpperCAmelCase : def __init__( self : Optional[Any] , __lowerCamelCase : list[int] | None = None , __lowerCamelCase : int | None = None ): """simple docstring""" ...
103
1
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, re...
247
from ..utils import DummyObject, requires_backends class A (metaclass=SCREAMING_SNAKE_CASE ): '''simple docstring''' __lowerCamelCase : Any = ['''keras_nlp'''] def __init__( self : Any , *__lowerCAmelCase : Any ...
247
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) class UpperCamelCase__ ( lowerCamelCase__ ): '''simple docstring''' __a : Tuple = """e...
458
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json""", # See all CANINE models at ht...
458
1
_lowerCamelCase : Any = 256 # Modulus to hash a string _lowerCamelCase : Dict = 1_000_003 def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> bool: SCREAMING_SNAKE_CASE : int = len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE ...
721
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[int] = logging.get_logger(__name__) _lowerCamelCase : List[str] = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json"...
308
0
"""simple docstring""" from __future__ import annotations lowerCAmelCase_ : Optional[int] = list[list[int]] # assigning initial values to the grid lowerCAmelCase_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0...
673
"""simple docstring""" import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLIComman...
673
1
__UpperCamelCase : Optional[Any] = 256 # Modulus to hash a string __UpperCamelCase : Any = 1000003 def _UpperCAmelCase ( UpperCAmelCase : str , UpperCAmelCase : str ): """simple docstring""" __lowerCamelCase...
458
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import...
458
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer __magic_name__: List[Any] = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"} __mag...
324
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, ...
324
1
from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ) -> str | Literal[False]: '''simple docstring''' __lowerCAmelCase = list(UpperCamelCase__ ) __l...
719
from __future__ import annotations def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ) -> list[str]: '''simple docstring''' if partitions <= 0: raise ValueError("""partitions must be a positive number!""" ) if partitions > number_of_bytes: ra...
334
0
'''simple docstring''' 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 ModelT...
667
'''simple docstring''' from collections.abc import Callable import numpy as np def a ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): '''simple docstring''' A_ : Union[str, Any] = int(np.ceil((x_end - xa) / step_s...
667
1
class _lowerCAmelCase : '''simple docstring''' def __init__( self : Tuple ): '''simple docstring''' _snake_case : dict[str, TrieNode] = {} # Mapping from char to TrieNode _snake_case : List[Any] = False def...
714
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/c...
669
0
import math def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> float: """simple docstring""" if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of initial intensity ...
662
"""simple docstring""" from __future__ import annotations UpperCamelCase : Any = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __snake_case ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ...
690
0
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_utils import ModelMixin from .prior_transforme...
709
import cva import numpy as np class UpperCamelCase__ : def __init__( self : List[str] , UpperCamelCase__ : float , UpperCamelCase__ : int ): '''simple docstring''' if k in (0.04, 0.06): lowercas...
650
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def _UpperCamelCase ( lowerCAmelCase_ = 3 ) ->qiskit.result.counts.Counts: if isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): raise TypeError("""number of...
377
from __future__ import annotations import math def _UpperCamelCase ( lowerCAmelCase_ ) ->bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not pr...
377
1
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data ...
645
"""simple docstring""" import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from ac...
645
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase ={ "con...
617
"""simple docstring""" import qiskit def _A ( _a : int , _a : int ): """simple docstring""" A = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register A = qiskit.QuantumCircu...
617
1
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_sh...
81
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict ...
81
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule SCREAMING_SNAKE_CASE_ = {"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys SCREAMING_SNAKE_CASE_ ...
597
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta imp...
507
0
def _lowerCAmelCase (_lowerCAmelCase): if not isinstance(_lowerCAmelCase , _lowerCAmelCase): raise ValueError("Input must be an integer") if input_num <= 0: raise ValueError("Input must be positive") return sum( divisor for divisor in range(1 , input_num // 2 + ...
504
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) UpperCAmelCase : Optional[Any] =pytest.mark.integration @pytest.mark.parametrize("path" , [...
504
1
import requests from bsa import BeautifulSoup def snake_case_ ( lowerCAmelCase_ : str = "AAPL" ): __lowercase : List[Any] = F"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}" __lowercase : List[Any] = BeautifulSoup(requests.get(lowerCAmelCase...
149
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase : List[str] = { '''configuration_conditional_detr''': [ '''CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Condition...
149
1
UpperCamelCase__ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def _UpperCamelCase (): """simple docstring""" UpperCamelCase__ = input("""Enter message: """ ) UpperCamelCase__ = input("""Enter key [alphanumeric]: """ ) UpperCamelCase__...
548
import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "facebook/data2vec-base-960h": "https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json", # Se...
548
1
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __UpperCamelCase: List[Any] = TypeVar("""T""") class __lowerCAmelCase ( Generic[T] ): '''simple docstring''' _A = 42 # Cache sto...
266
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def SCREAMING_SNAKE_CASE__ ( _lowercase : dict ) ->...
266
1
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE__ = [1] SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 0, 0, 0 SCREAMING_SNAKE_C...
379
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features ...
379
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : List[str] = logging.get_logger(__name__) UpperCamelCase : Optional[int] = { 'facebook/s2t-small-librispeech-asr': ( 'https://huggingface.co/face...
50
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline UpperCamelCase__ = logging.get_logger(__name__) # pylint: disable=invalid-name class ...
75
0
from math import isclose, sqrt def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> tuple[float, float, float]: snake_case__ = point_y / 4 / point_x snake_case__ = 2 * normal_gradient / (1 + normal_g...
208
# 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 require...
208
1
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" print('''\nThe shortest path matrix using Floyd Warshall algorithm\n''' ) for i in range(SCREAMING_SNAKE_CASE ): for j in range(SCREAMING_SNAKE_CASE ): if dist[i][j] != float('''inf''' )...
43
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = 'T5Config' class _a ( UpperCamelCase__ ): _l...
43
1
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _lowercase = logging.get_logger(__name__) class lowerCamelCase__ ( A__ ): def __init__( self : List[str] , *__a : int , **__a : Dict ...
242
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_bac...
242
1
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import...
207
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class UpperCAmelCase ( snake_case_ ): def __init__( self :...
207
1
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class __magic_name__ ( __SCREAMING_SNAKE_CASE ): UpperCamelCase__ = 'EncodecFeatureExtractor' UpperCamelCase__ = ('T5Tokenizer', 'T5...
145
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() _UpperCAmelCase : List[str] = logging.get_logger(__name__) def UpperCamelCase ( lowercase_ : O...
145
1
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedL...
73
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIF...
73
1
import os import time import numpy as np import onnxruntime as ort __snake_case : Any = "1" __snake_case : int = "0" __snake_case : Any = "1" __snake_case : List[str] = ort.SessionOptions() __snake_case : Union[str, ...
720
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", "microsoft/markuplm-large...
181
0
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase = logging.get_logger(__name__) def UpperCamelCase_( _A :Tuple , _A :str , _...
551
from __future__ import annotations import math import random from typing import Any class lowerCamelCase__ : """simple docstring""" def __init__( self ): '''simple docstring''' UpperCamelCase__ = [] UpperCamelCase__ = 0 Uppe...
551
1
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 tensorflow as tf from transformers import TFXLMRobertaMod...
713
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Optional[Any] = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } try: ...
148
0
"""simple docstring""" from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function _a = 1.054571817E-34 # unit of ℏ : J * s _a = 3E8 # unit of c : m * s^-1 def lowerCamel...
19
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_commo...
658
0
from ....configuration_utils import PretrainedConfig from ....utils import logging __A =logging.get_logger(__name__) __A ={ """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json""" ), } class _SCREAMING_S...
700
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 __A =logging.get_logger(__name__) __A ={ '''google/vit-base-patch16-224''': '''https://huggin...
313
0
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging...
628
"""simple docstring""" from collections.abc import Sequence def _SCREAMING_SNAKE_CASE ( UpperCamelCase : Sequence[int] | None = None ): if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) A__ = nums...
574
0
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from t...
700
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class __lowercase ( a__ ): def __init__( self : List[Any] , *lowercase__ : ...
143
0
'''simple docstring''' import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_...
577
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate...
577
1
'''simple docstring''' import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_wei...
603
'''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 __snake_case = logging.get_logger(__name__) ...
603
1
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __A =[ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ '''text-classification''', '''language-model...
463
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __A =logging.getLogger(__name__) def lowerCamelCase_ ( ): lowerCamelCase_ = argparse.ArgumentParser( description="Prepare TFRecord shards from pr...
463
1
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERA...
717
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(__lowercase ) , 'Tatoeba direc...
638
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class UpperCAmelCase ( A__ ...
251
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseScheduler, ...
73
0
'''simple docstring''' def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" assert ( isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) and number_of_steps > 0 ), f'''number_of_steps needs to be positive integer, your input {number_of_steps}''' if number_of_st...
271
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorSt...
271
1
'''simple docstring''' def UpperCamelCase_ ( snake_case_ : int=2_81_23 ) -> Tuple: '''simple docstring''' __lowerCAmelCase = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_...
427
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( snake_case_ : list[int | float] , snake_case_ : int , snake_case_ : int ) -> int | float: '''simple docstring''' if len(snake_case_ ) == 0: raise ValueError("""find_max() ...
427
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCAmelCase = { 'configuration_chinese_clip': [ 'CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ChineseCLIPConfi...
708
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" def __a ( self ,__SCREAMING_S...
220
0
from collections import defaultdict from math import ceil, sqrt def A ( lowercase__ : int = 100_0000 , lowercase__ : int = 10 ) -> int: UpperCamelCase__ :defaultdict = defaultdict(lowercase__ ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer_width * outer_width >...
45
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging snake_case__ = logging.get_logger(__name__) def lowerCamelCase__ ...
395
0
from typing import Any import numpy as np def A_ ( snake_case : np.ndarray ) -> bool: '''simple docstring''' return np.array_equal(snake_case , matrix.conjugate().T ) def A_ ( snake_case : np.ndarray , snake_case : np.ndarray ) -> ...
451
def A_ ( snake_case : float ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(snake_case , snake_case ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def A_ ( s...
451
1
from timeit import timeit lowerCamelCase__ = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan a canal panama" } # Ensure our test data is valid as...
547
"""simple docstring""" 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, logg...
115
0
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def a__ ( _SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CASE : int=1 ) -> Tuple: """simple docstring""...
710
'''simple docstring''' from __future__ import annotations from typing import Any def a__ ( _SCREAMING_SNAKE_CASE : list ) -> int: """simple docstring""" if not postfix_notation: return 0 UpperCAmelCase_ : Tuple = {"+", "-", "*", "/"} ...
323
0