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
from __future__ import annotations def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = str(_UpperCamelCase ) return len(_UpperCamelCase ) == 9 and set(_UpperCamelCase ) == set('''123456789''' ) def lowercase_ ( ): '''simple docstring''' for bas...
639
a : Any = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from .f...
639
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging snake_case_ : Union[str, Any] = logging.get_logger(__n...
350
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def __snake_case ( _UpperCAmelCase : Optional[int], _UpperCAmelCase : Tuple, _UpperCAmelCase : Any): UpperCamelCase = 0 if start < end:...
350
1
def UpperCamelCase_ ( __a ) -> bool: return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("""Program to check whether a number is a Perfect number or not...""") UpperCamelCase : Union[str, Any] = ...
37
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = { """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
314
0
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_...
694
'''simple docstring''' from __future__ import annotations def _A ( snake_case__ : float , snake_case__ : float , snake_case__ : float ): if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: raise ValueError('...
694
1
'''simple docstring''' import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __a ( A__ , A__ , A__ ...
649
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare...
422
0
'''simple docstring''' 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 _SCREAMING_SNAKE_CASE (lowercase__, lowercase__ ...
574
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : List[Any] ={ "configuration_pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"], } try: if not is_torch_available...
574
1
'''simple docstring''' import os from distutils.util import strtobool def a__ ( a__ , a__ ): """simple docstring""" for e in env_keys: __SCREAMING_SNAKE_CASE = int(os.environ.get(a__ , -1 ) ) if val >= 0: return val return de...
627
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfi...
627
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 __lowerCAmelCase = logging.get_...
666
'''simple docstring''' import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet i...
666
1
from bisect import bisect from itertools import accumulate def lowerCAmelCase_ ( A_ ,A_ ,A_ ,A_): UpperCamelCase__: Tuple = sorted(zip(A_ ,A_) ,key=lambda A_: x[0] / x[1] ,reverse=A_) UpperCamelCase__ , UpperCamelCase__: Tuple = [i[0] for i in...
380
import logging from transformers import PretrainedConfig A__: Dict = logging.getLogger(__name__) A__: List[Any] = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', } ...
380
1
"""simple docstring""" import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transfor...
710
"""simple docstring""" import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class _snake_case ( __snake_case ): """simple docstring""" a = "M-CLIP" def __init__( self : Optional[Any] , _A : List[s...
635
0
'''simple docstring''' def __a ( lowerCAmelCase__ : float , lowerCAmelCase__ : int ): if digit_amount > 0: return round(number - int(lowerCAmelCase__ ) , lowerCAmelCase__ ) return number - int(lowerCAmelCase__ ) if __name__ == "__main__": prin...
688
'''simple docstring''' def __a ( lowerCAmelCase__ : list , lowerCAmelCase__ : list , lowerCAmelCase__ : int ): a__ : List[str] = len(lowerCAmelCase__ ) a__ : int = [[0] * n for i in range(lowerCAmelCase__ )] for i in rang...
688
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, ...
715
'''simple docstring''' from manim import * class lowerCamelCase__ ( __lowerCamelCase ): """simple docstring""" def lowerCAmelCase_ ( self : Optional[Any] ): a__ = Rectangle(height=0.5 ,width=0.5 ) ...
394
0
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __UpperCAmelCase ( __a : bytes ,__a : int ) -> np.array: """simple docstring""" _a : int = F"""{sampling_rate}""" _...
14
from math import factorial def _lowerCAmelCase ( lowerCAmelCase_ :int = 20 )->int: '''simple docstring''' snake_case_ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... snake_case_ = n /...
283
0
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTo...
127
import re import string import numpy as np import datasets lowercase_: Optional[Any] = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' lowercase_: Optional[int] = '\...
127
1
_a: str = 6_5521 def __lowerCAmelCase ( A ): UpperCAmelCase_ = 1 UpperCAmelCase_ = 0 for plain_chr in plain_text: UpperCAmelCase_ = (a + ord(_snake_case )) % MOD_ADLER UpperCAmelCase_ = (b + a) % MOD_ADLER return...
162
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKIN...
181
0
from __future__ import annotations snake_case_ : int = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowerCamelCase( a__ ,a__ ,a__ ,a__ ,a__ ,): _SCREAMING_SNAKE_CASE =[ [0 for col in range(len(grid[0]))] for row in r...
191
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Optional[Any] = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab/lilt-rob...
191
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = '''▁''' lowerCA...
60
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import require_lza, require...
60
1
import os from collections.abc import Iterator def lowercase_ ( _A : str = "." ): """simple docstring""" for dir_path, dir_names, filenames in os.walk(_A ): lowerCamelCase__ : Union[str, Any] = [d for d in dir_names if d != "scripts" and d[0] not...
5
import os def lowercase_ ( _A : str = "input.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(_A ) , _A ) ) as input_file: lowerCamelCase__ : List[Any] = [ [int(_A ) for element in line.split("," ...
5
1
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversat...
34
"""simple docstring""" from scipy.stats import pearsonr import datasets SCREAMING_SNAKE_CASE_ = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value...
34
1
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() a = logging.get_logger(__name__) a = { "post_extract_proj": "feature_projection.project...
175
from __future__ import annotations from scipy.special import comb # type: ignore class _A : def __init__( self , _SCREAMING_SNAKE_CASE ): _UpperCAmelCase = list_of_points # Degree determines the flexibility of the curve. # Degre...
175
1
'''simple docstring''' import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput UpperCamelCase__: int = "sched...
127
'''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__: str = logging.get_lo...
127
1
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") A : Union[str, Any] = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) A : str = requests.get(u...
714
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 TFCa...
5
0
"""simple docstring""" from bisect import bisect from itertools import accumulate def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> List[str]: __lowerCAmelCase: Optional[Any] ...
346
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils imp...
119
0
"""simple docstring""" 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_batc...
21
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : bool = False ): '''simple docstring''' if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n ...
21
1
"""simple docstring""" import os def __UpperCAmelCase ( __UpperCamelCase = "matrix.txt" ): with open(os.path.join(os.path.dirname(__snake_case ) , __snake_case ) ) as in_file: __lowercase : int = in_file.read() __lowercase : Tuple ...
76
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
10
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate...
717
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def A ( _lowercase ): SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Union[str, Any] = analyze_text(_lowercase ) SCREAMING_SNAKE_CASE ...
34
0
from __future__ import annotations def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): snake_case_ = len(SCREAMING_SNAKE_CASE__ ) // 2 # choose the middle 3 elements snake_case_ = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[0...
39
from PIL import Image def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ ): def brightness(lowerCAmelCase__ ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError("""level must be between -255.0 (black) and 255.0 (white)""" )...
428
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def lowerCamelCase_(lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ = 100 , ) -> float: UpperCAmelCase = x_start UpperCAmelCase = ...
710
import os import re import shutil import sys import tempfile import unittest import black __lowerCamelCase : str = 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...
457
0
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) lowerCAmelCase : Optional[Any] = logging.getLogger(__name__) if __name_...
202
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : List[Any] = { 'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json', # See all ...
587
0
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi...
718
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
156
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline...
565
'''simple docstring''' class lowerCAmelCase_: '''simple docstring''' def __init__( self ,__UpperCAmelCase ) -> Any: lowerCAmelCase__ : str = n lowerCAmelCase__ : Optional[Any] = [None] * self.n lowerCAmelCase__ : Tuple = 0 ...
565
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase : int = logging.get_logger(__name__) UpperCamelCase : Option...
91
"""simple docstring""" from statistics import mean, stdev def __snake_case ( UpperCamelCase__ , UpperCamelCase__ = 3 ) -> list: """simple docstring""" A = min(UpperCamelCase__ ) A = max(UpperCamelCase__ ) # normalize data return [round((x - x_min)...
91
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def A__ ( __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = [ 'encoder.version', 'decoder.version...
589
"""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(): f...
589
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __lowerCAmelCase ( __UpperCamelCase : Union[str, Any] ): '''simple docstring''' snake_cas...
21
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : int ): '''simple docstring''' snake_case_ : Any = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): ...
21
1
"""simple docstring""" def lowerCAmelCase_ ( UpperCamelCase__ : list , UpperCamelCase__ : int = 0 ): """simple docstring""" __lowercase = length or len(UpperCamelCase__ ) __lowercase = False for i in range(length - 1 ): if l...
616
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCAmelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : str , UpperCamelCase__ : Optional[str] = None ): ...
616
1
'''simple docstring''' from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( "stable diffusion controlnet", "0.22.0", "Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable...
719
'''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: import t...
10
0
def snake_case ( lowerCamelCase ): '''simple docstring''' if not head: return True # split the list to two parts __lowercase , __lowercase = head.next, head while fast and fast.next: __lowercase = fast.next.next __lowercase = slow.next __lowe...
80
'''simple docstring''' from __future__ import annotations from random import choice def a_ ( lowerCamelCase : Optional[Any] ): return choice(lowerCamelCase ) def a_ ( lowerCamelCase : list[int] , lowerCamelCase : int...
133
0
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "huggingface/time-series-transformer-tourism-monthly": ( "https://huggingface.co/huggingface/time-s...
583
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class...
583
1
def __a ( __UpperCAmelCase : int ) -> Any: """simple docstring""" return 10 - x * x def __a ( __UpperCAmelCase : List[str] , __UpperCAmelCase : Dict ) -> int: """simple docstring""" if equation(UpperCamelCase_...
488
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''YituTech/conv-bert-ba...
657
0
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorfl...
125
from __future__ import annotations def _A ( lowerCAmelCase_ : list[int | str] ): """simple docstring""" create_state_space_tree(lowerCAmelCase_ , [] , 0 , [0 for i in range(len(lowerCAmelCase_ ) )] ) def _A ( l...
125
1
import os def _UpperCamelCase (): """simple docstring""" with open(os.path.dirname(a__ ) + """/grid.txt""" ) as f: UpperCamelCase__ = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) fo...
619
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. UpperCamelCase__ = 10 def _UpperCamelCase (a__ :int , a__ :int , a__ :list[int] , a__ :int ...
619
1
'''simple docstring''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
718
'''simple docstring''' import math def __lowercase () -> None: """simple docstring""" __lowerCamelCase : Optional[int] = input("""Enter message: """ ) __lowerCamelCase : Optional[Any] = int(input(f"Enter key [2-{len(_lowercase ) - 1}]: ...
483
0
import random def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CASE :float , SCREAMING_SNAKE_CASE :bool = False ) -> dict: __lowerCAmelCase : Any = {i: [] for i in range(UpperCAmelCase_ )} # if prob...
504
"""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(__na...
104
0
"""simple docstring""" import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class UpperC...
477
"""simple docstring""" import numpy as np def lowercase__( __SCREAMING_SNAKE_CASE : np.array ): return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
477
1
"""simple docstring""" from math import pi, sqrt, tan def lowercase__ ( snake_case_ :float ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def lowercase__ ( ...
49
'''simple docstring''' from math import loga def __lowerCamelCase ( UpperCAmelCase_ ) ->int: if a < 0: raise ValueError('Input value must be a positive integer' ) elif isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): raise TypeError('Input value ...
368
0
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, UNe...
472
import math class UpperCAmelCase__ : """simple docstring""" def lowercase_ ( self : int , __lowerCamelCase : list[list[float]] , __lowerCamelCase : list[int] ) -> int: SCREAMING_SNAKE_CASE__ = 0.0 SCREAMING_SNAKE_CASE__ = 0.0 f...
472
1
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import...
542
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 transforme...
542
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase : Tuple = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig']} try: if not is_vis...
711
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : str = logging.get_logger(__name__) _lowerCamelCase : Optional[int] = { """microsoft/git-base""": """https://huggingfa...
308
0
import datasets UpperCAmelCase_ : str = '''\ @InProceedings{conneau2018xnli, author = "Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. and Schwenk, Holger ...
17
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class A__( unittest.TestCase ): def _a ( self : List[str] ) -> str: """simple docstring""" __SCREAM...
482
0
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel from transf...
717
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowercase__( A ): snake_case__ : List[str] = [] embed...
303
0
from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_pipeline_mixin i...
488
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transform...
179
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ : str =logging.get_logger(__name__) snake_case_ : i...
205
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class a__ ( lowerCAmelCase__ ): # `task` is not a ClassVar since we want it to be pa...
205
1
"""simple docstring""" from __future__ import annotations lowercase__ = 10 def __magic_name__ ( _lowerCamelCase : list[int] ): __a : List[str] = 1 __a : str = max(_lowerCamelCase ) while placement <= max_digit: ...
581
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowercase__ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise ...
581
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _lowercase ( lowercase__): """simple docstring""" A__ = "Speech2TextFeatureExtractor" A__ = "Speech2TextTokenizer" ...
5
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, id...
5
1
import numpy as np def A__ ( lowerCamelCase ) -> np.array: return 1 / (1 + np.exp(-vector )) def A__ ( lowerCamelCase ) -> np.array: return vector * sigmoid(1.702 * vector ) if __name__ == "__main__": import doctest doctest.te...
548
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ..utils...
548
1
def A__ ( __A , __A ): '''simple docstring''' _lowerCamelCase : int = word.split() def justify(__A , __A , __A ) -> str: _lowerCamelCase : List[str] = max_width - width _lowerCamelCase : Any = len(__A ) ...
15
from math import log from scipy.constants import Boltzmann, physical_constants lowerCAmelCase : List[Any] =300 # TEMPERATURE (unit = K) def A__ ( __A , __A , __A , ): '''simple docstring''' if donor_conc <= 0: raise ValueError("""Dono...
15
1
'''simple docstring''' def A__ ( __lowerCAmelCase : list[int] ): if not numbers: return 0 if not isinstance(__lowerCAmelCase , (list, tuple) ) or not all( isinstance(__lowerCAmelCase , __lowerCAmelCase ) for number in numbers ): ...
50
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A__ ( __lowerCAmelCase : Any ): # This defines a "chinese character" as anything in the CJK Unicode block: ...
50
1
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_util...
556
"""simple docstring""" from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, ...
556
1
'''simple docstring''' import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_a...
467
'''simple docstring''' 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 __lowerCamelCase = logging.get_logger(_...
467
1
'''simple docstring''' from __future__ import annotations def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_) -> float: UpperCamelCase__ : Dict = sorted(numsa + numsa) UpperCamelCase__, UpperCamelCase__ : Dict = ...
6
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_a...
6
1
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowercase ( __lowerCamelCase : str = "isbn/0140328726" ) -> dict: '''simple docstring''' UpperCamelCase__ : Optional[int] = olid.strip().stri...
344
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, Auto...
344
1
"""simple docstring""" from __future__ import annotations from random import choice def a_ ( _lowerCAmelCase : List[Any] ): '''simple docstring''' return choice(_lowerCAmelCase ) def a_ ( _lowerCAmelCase : list[int] , _lowerCAmelCase ...
645
"""simple docstring""" import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import I...
645
1
'''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_a...
92
"""simple docstring""" from __future__ import annotations import math def _lowerCamelCase ( __a ): if num <= 0: SCREAMING_SNAKE_CASE_ = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__a ) SCREAMING_SNAKE_CASE_ = [True] * (num + 1) ...
626
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : Union[str, Any] =logging.ge...
197
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( lowerCAmelCase__ :list[float] , lowerCAmelCase__ :list[float] ) -> float: '''simple docstring''' lowercase = sorted(numsa + numsa ) lowercase , l...
197
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ = { """configuration_electra""": ["""ELECTRA_PRETRAINED...
458
"""simple docstring""" import string def _UpperCAmelCase ( __lowerCamelCase : str ) -> str: _snake_case = '''''' for i in sequence: _snake_case = ord(__lowerCamelCase ) if 65 <= extract <= 90: output += chr(1_55 - extract ) elif 97 <= extract <=...
224
0
class lowerCAmelCase_ : '''simple docstring''' def __init__( self , __UpperCAmelCase ): SCREAMING_SNAKE_CASE_ : int =len(__UpperCAmelCase ) SCREAMING_SNAKE_CASE_ : List[str] =[0] * len_array if len_array > 0: ...
153
def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : list[int] ,lowerCAmelCase_ : list[int] ,lowerCAmelCase_ : int ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neigh...
153
1
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCAmelCase_ = TypeVar("""KEY""") lowerCAmelCase_ = TypeVar("""VAL""") @dataclass(frozen=UpperCAmelCase_ , slots=UpperCAmelCase_ ) class _lowerCAmelCas...
411
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowerCAmelCase_ = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """))) pr...
411
1
import os import re import shutil import sys import tempfile import unittest import black _lowerCAmelCase = 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 the reference code that wi...
709
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCAmelCase_ ( __lowercase ): UpperCAmelCase = (...
71
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['LukeTokenizer'], } try: if not is_torch_available(): ...
500
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _a ( UpperCAmelCase ) -> Any: """simple docstring""" return getitem, k def _a ( UpperCAmelCase , UpperCAmelCase ) -> Union[s...
315
0
'''simple docstring''' import os from collections import deque import torch from torch.utils.data import Dataset class a__( lowerCAmelCase__ ): '''simple docstring''' def __init__( self , __lowerCAmelCase="" , __lowerCAmelCase="train"): """simple docstring""" ...
605
'''simple docstring''' from __future__ import annotations import time __lowercase = list[tuple[int, int]] __lowercase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, ...
605
1
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def Upp...
13
def SCREAMING_SNAKE_CASE__ ( snake_case__ :str ) -> list: _lowercase = [0] * len(snake_case__ ) for i in range(1 , len(snake_case__ ) ): # use last results for better performance - dynamic programming _lowercase = prefix_result[i - 1] w...
67
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Optional[Any] = logging.get_logger(__name__) _snake_case : Optional[Any] = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/...
712
def a_ ( lowerCAmelCase_ : str, lowerCAmelCase_ : str ): if not (isinstance(lowerCAmelCase_, lowerCAmelCase_ ) and isinstance(lowerCAmelCase_, lowerCAmelCase_ )): raise ValueError('longest_common_substring() takes two strings for inputs' ) __lowerCAmelCase ...
421
0
'''simple docstring''' from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import StableDiffusionControlNetPipeline # noqa: F401 deprecate( """stable diffusion controlnet""", """0.22.0""", """Importing `StableD...
378
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
236
0
from typing import Dict, Optional import numpy as np import datasets _lowercase = ''' IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For binary (two classes) or multi-class segmentati...
713
import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin...
683
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/r...
80
'''simple docstring''' import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = """▁""" snake_c...
507
0
"""simple docstring""" import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowerCAmelCase : Dict = argparse.ArgumentParser() parser.add_argument( """--checkp...
720
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __magic_name__ ...
533
0
'''simple docstring''' from collections import deque from .hash_table import HashTable class _snake_case ( _UpperCAmelCase ): def __init__( self , *_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CASE ): '''simple docstring''' super().__init__(*_lowerCAmelCase , **...
284
'''simple docstring''' from heapq import heappop, heappush import numpy as np def SCREAMING_SNAKE_CASE ( lowercase_ : np.ndarray , lowercase_ : tuple[int, int] , lowercase_ : tuple[int, int] , lowercase_ : bool , ): lowercase , lowercase = grid.shape ...
588
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
1
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.utils import cached_property from ...test_tok...
1
1
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_...
78
"""simple docstring""" import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index,...
49
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch if is_vision_availabl...
60
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
1
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_image_inputs if is_...
258
'''simple docstring''' import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configura...
209
0
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers...
91
"""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_warmup, set_seed f...
91
1
"""simple docstring""" __SCREAMING_SNAKE_CASE : int = 9.8_0665 def lowerCAmelCase_( lowercase_ : float , lowercase_ : float , lowercase_ : float = g ) -> float: if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) if volu...
661
"""simple docstring""" import inspect import unittest from transformers import BitConfig 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 BackboneTest...
661
1
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 AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tes...
706
def lowercase ( _a = 2000000 ) -> int: UpperCAmelCase_: List[str] = [0 for i in range(n + 1 )] UpperCAmelCase_: str = 1 UpperCAmelCase_: Union[str, Any] = 1 for i in range(2 ,int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in ...
306
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ : Union[str, Any] =logging.get_logger(__name__) A_ : List[str] ={ """vocab_file""": """vocab...
483
def lowerCamelCase_ ( UpperCAmelCase__ = 100 ): """simple docstring""" a_ = (n * (n + 1) // 2) ** 2 a_ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F'''{solution() = }''')
483
1
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulator, create_opt...
525
# Function to print upper half of diamond (pyramid) def __A ( _A ): """simple docstring""" for i in range(0 , _A ): for _ in range(0 , n - i - 1 ): # printing spaces print(" " , end="" ) for _ in range(0 , i + 1 ): # printing ...
525
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class __lowerCAmelCase : '''simple docstring''' def __init__(self : List[Any] , UpperCamelCase : Any ): '''simple docstring''...
460
'''simple docstring''' from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def _SCREAMIN...
460
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
479
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() A_ = logging.get_logger(__name__) def __UpperCAmelCase ( UpperCAmelCase )-> Tuple: ...
479
1
import heapq def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ ): UpperCamelCase__ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works wi...
285
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase =logging.get_logger(__name__) lowerCamelCase ={ "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json", } class _lowerCamelCase ( UpperCamelCase_...
285
1
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _lowerCAmelCase = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _lowerCAmelCase = typing.Union[np.floataa, int, float] # noqa: UP007 def a__ ( a , ...
236
from math import loga def a__ ( a ) -> int: if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(a , a ): raise TypeError('''Input value must be a \'int\' type''' ) return 0 if (a == 0) els...
236
1
class lowerCAmelCase_ : def __init__( self, SCREAMING_SNAKE_CASE_ ) -> Optional[int]: UpperCamelCase : Tuple = n UpperCamelCase : List[Any] = [None] * self.n UpperCamelCase : str = 0 # ind...
40
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class lowerCAmelCase_ ...
40
1
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import To...
231
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging _snake_case = { ...
231
1
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class _A : __a = None def UpperCAmelCase ( self ): _UpperCAmelCase = self.feature_extraction_class(**self.f...
518
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP a = False try: a = _is_package...
518
1
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager impor...
705
'''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 fro...
305
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( lowerCAmelCase : list[int] , lowerCAmelCase : int ): """simple docstring""" if len(_UpperCAmelCase ) < k or k < 0: raise ValueError('Invalid Input' ) __magic_na...
561
import enum import shutil import sys a__ , a__ : int = shutil.get_terminal_size() a__ : Tuple = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class UpperCAmelCase_ ( enum.Enum ): __lowerCAmelCase : int = 0 __lowerCAmelCase : Optio...
188
0
'''simple docstring''' import pickle import numpy as np from matplotlib import pyplot as plt class lowercase : '''simple docstring''' def __init__( self : Tuple , __lowerCamelCase : str , __lowerCamelCase : Optional[Any] , __lowerCamelCa...
187
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A...
187
1
"""simple docstring""" import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitesp...
19
"""simple docstring""" from PIL import Image def A_ ( snake_case_ : Image ,snake_case_ : int ): '''simple docstring''' UpperCamelCase : Optional[int] = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(snake_case_ : int...
499
0
"""simple docstring""" lowercase = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', ...
720
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase = { '''configuration_roberta...
24
0
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch SCREAMIN...
257
from __future__ import annotations def UpperCamelCase ( _a , _a = None , _a = None ) -> None: '''simple docstring''' if start is None: lowercase_ :Optional[int] = 0 if end is None: lowercase_ :...
257
1
"""simple docstring""" def snake_case_ ( A_ : Any, A_ : Union[str, Any] ): '''simple docstring''' _enforce_args(_lowercase, _lowercase ) if n == 0: return 0 _lowerCamelCase : List[Any] = float('''-inf''' ) ...
704
"""simple docstring""" import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow lowerCAmelCase__ = False class __snake_case ( unittest.TestCase): d...
598
0