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
'''simple docstring''' import os A : Union[str, Any] = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1_000} def _a ( lowerCamelCase_ ): snake_case : Optional[int] =0 snake_case : List[str] =0 while index < len(_UpperCA...
349
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer snake_case_ : Tuple = loggin...
212
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = [ ['attention', 'attn'], ['encoder_atten...
185
def UpperCamelCase_( _A :str )-> str: UpperCamelCase__ = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def UpperCamelCase_( _A :str )-> dict[str, str]: UpperCamelCase__ = [chr(i...
185
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __snake_case = logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE ( __UpperCAmelCase ): """simple docstring""" def __init__( self , *lo...
200
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = '▁'...
200
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCamelCase ( unittest.Test...
703
'''simple docstring''' def _A ( A ) -> list: lowercase : Optional[Any] = False while is_sorted is False: # Until all the indices are traversed keep looping lowercase : List[str] = True for i in range(0 ,len(A ) - 1 ,2 ): # iterating over...
425
0
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging ...
635
0
'''simple docstring''' import argparse a = "docs/source/_static/js/custom.js" def __magic_name__ ( __UpperCAmelCase ) -> Tuple: '''simple docstring''' with open(__UpperCAmelCase , encoding="""utf-8""" , newline="""\n""" ) as f: __SCRE...
711
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequen...
13
0
from __future__ import annotations from collections.abc import Callable def _A ( SCREAMING_SNAKE_CASE__ : Callable[[int | float], int | float] , SCREAMING_SNAKE_CASE__ : int | float , SCREAMING_SNAKE_CASE__ : int | float , SCREAMING_SNAKE_CASE__ : int = 100 ...
658
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : tuple[int, int] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase , UpperCamelCase :List[Any] = position UpperCamelCase :Any = [ (y + 1, x + 2), (y - 1, x + 2)...
658
1
'''simple docstring''' import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax fr...
654
'''simple docstring''' import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
654
1
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class __lowercase : """simple docstring""" _UpperCAmelCase : Optional[Union[str, Path]] = None _UpperCAmelCase : bool = False _UpperCAm...
671
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __lowercase ( UpperCAmelCase_ ): """simple docstring""" def _SCREAMING_SNAKE_CASE ( self : List[Any] , lowerCAmelCase__ ...
671
1
from __future__ import annotations from math import ceil, floor, sqrt def _lowercase ( lowercase__ = 2_0_0_0_0_0_0 ): __lowerCAmelCase : list[int] = [0] __lowerCAmelCase : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_nu...
583
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transformers.utils import...
583
1
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import Pr...
609
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } cla...
609
1
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor _snake_case = logging.getLogger(__name__) _sn...
659
"""simple docstring""" import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient _snake_case = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"]) def sna...
659
1
'''simple docstring''' from functools import lru_cache def snake_case ( a_ : int ) -> set: """simple docstring""" UpperCamelCase_ : Any = 2 UpperCamelCase_ : int = set() while i * i <= n: if n % i: ...
208
'''simple docstring''' from __future__ import annotations from collections import namedtuple def snake_case ( a_ : float , a_ : float , a_ : float ) -> tuple: """simple docstring""" UpperCamelCase_ : Tuple = namedtuple("""r...
208
1
"""simple docstring""" import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig ...
197
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, ...
197
1
"""simple docstring""" import colorsys from PIL import Image # type: ignore def _lowerCamelCase ( lowerCamelCase__ : str , lowerCamelCase__ : Optional[Any] , lowerCamelCase__ : int ): lowercase__ : Tuple = x lowercase__ : int = ...
200
'''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.apache.o...
685
0
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import e...
655
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
1
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _a ( SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ ...
663
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobert...
663
1
'''simple docstring''' import os __a = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} def __snake_case( _lowerCAmelCase ) -> int: snake_case__ : str = 0 snake_case__ : List[Any] = 0 while index < len(__A ) - 1: ...
708
'''simple docstring''' def __snake_case( _lowerCAmelCase ) -> Dict: # noqa: E741 snake_case__ : List[Any] = len(_lowerCAmelCase ) snake_case__ : str = 0 snake_case__ : str = [0] * n snake_case__ : Optional[Any] ...
301
0
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerat...
357
"""simple docstring""" import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_sta...
357
1
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : str ): '''simple docstring''' _UpperCAmelCase : int ='' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def ...
331
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils...
331
1
'''simple docstring''' 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, DDIMSchedule...
28
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_...
309
0
'''simple docstring''' import math import tensorflow as tf from packaging import version def UpperCAmelCase__ ( UpperCAmelCase__ ) -> Dict: A_ = tf.convert_to_tensor(UpperCAmelCase__ ) A_ = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ), x...
717
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia a...
667
0
'''simple docstring''' from __future__ import annotations def a ( __a , __a , __a , __a ) -> list: '''simple docstring''' UpperCamelCase__ :List[str] = [] UpperCamelCase__ , UpperCamelCase__ :Any = input_list[low:mid], input_...
189
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowercase ( A__ ): """simple doc...
189
1
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_ava...
701
'''simple docstring''' def _A ( snake_case__ : int = 4_00_00_00 ): snake_case__ : int = [] snake_case__ ,snake_case__ : Union[str, Any] = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(snake_case__ ) snake_case__ ,snake_case__ : Any = b, a + b return s...
694
0
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class snake_case_ ( __A ): '''simple docstring''' def snake_case__( self : Tuple ) ->Optional[Any]: return [ ...
39
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def UpperCAmelCase__ ...
288
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : Tuple = { '''configuration_electra''': [''...
265
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase_ : List[str] = TypeVar('''T''') lowerCamelCase_ : Optional[int] = TypeVar('''U''') class _SCREAMING_SNAKE_CASE ( Generic[T, U] ...
265
1
from torch import nn def _snake_case (__lowercase): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f"""Unsupported activation function:...
23
import math from datetime import datetime, timedelta def _snake_case (__lowercase): UpperCamelCase_ = year % 19 UpperCamelCase_ = year % 4 UpperCamelCase_ = year % 7 UpperCamelCase_ = math.floor(year / 100) UpperCamelCase_ = math.flo...
23
1
from sklearn.metrics import mean_squared_error import datasets lowercase_ = "\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, ...
390
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to have ...
390
1
"""simple docstring""" 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_...
77
"""simple docstring""" import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging __UpperCAmelCase =logging.get_logger(__name__) def __a ( A=None , A=None ) -> int: ...
337
0
'''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 .te...
570
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.uti...
570
1
'''simple docstring''' from math import pi, sqrt def _A ( UpperCAmelCase ): '''simple docstring''' if num <= 0: raise ValueError('math domain error' ) if num > 1_71.5: raise OverflowError('math range error' ) elif num - int(UpperCAmelCase...
531
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from t...
531
1
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( __snake_case : int , __snake_case : int ) -> list[list[int]]: __A : list[list[int]] = [] create_all_state(1 , __snake_case , __snake_case ...
703
'''simple docstring''' import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxMod...
338
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Union[str, Any] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
633
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[Any] = logging.get_logger(__name__) a : List[Any] = { '''microsoft/unispeech-sat-base-100h-libri-ft''': (...
633
1
def lowerCamelCase_ ( _a : int = 10**12 ): '''simple docstring''' UpperCAmelCase_ : Optional[Any] = 1 UpperCAmelCase_ : List[Any] = 0 UpperCAmelCase_ : Tuple = 1 UpperCAmelCase_ : Union[str, Any] = 1 w...
705
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration UpperCamelCase_ = 50000 UpperCamelCase_ = 5000 UpperCamelCase_ ,UpperCamelCase_ = os.path.split(__file__) UpperCamelCase_ = os.path.join(RESULTS_BAS...
322
0
import re from ..utils import cached_file # docstyle-ignore snake_case__ : Union[str, Any] = '\nHuman: <<task>>\n\nAssistant: ' snake_case__ : str = 'huggingface-tools/default-prompts' snake_case__ : Optional[int] = {'chat': 'chat_prompt_template.txt', 'run': 'run_prom...
408
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available A = { """configuration_ernie""": ["""ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ErnieConfig""", """ErnieOnnxConfig"""], } ...
77
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available, ...
700
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class __magic_name__ : def __init__( self : Optional[int] ) -> Optional[Any]: UpperCAmelCase = "" UpperCAmelCase = "" UpperCAmelCase = [] UpperCAmel...
1
0
def lowerCAmelCase ( UpperCamelCase__ : list ) -> list: """simple docstring""" __SCREAMING_SNAKE_CASE: Tuple = False while is_sorted is False: # Until all the indices are traversed keep looping __SCREAMING_SNAKE_CASE: Any = True...
202
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test...
202
1
"""simple docstring""" # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatt...
327
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from...
327
1
'''simple docstring''' def _lowercase ( lowerCamelCase__ , lowerCamelCase__ ) -> str: """simple docstring""" __UpperCAmelCase : list[list[str]] = [[] for _ in range(lowerCamelCase__ )] __UpperCAmelCase : Dict =...
168
'''simple docstring''' def _lowercase ( lowerCamelCase__ = 1000 ) -> int: """simple docstring""" __UpperCAmelCase : Union[str, Any] = 2**power __UpperCAmelCase : Optional[int] = 0 while n: __Upper...
168
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = { 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LlamaConfig'], } t...
708
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCamelCase = { 'configuration_mobilenet_v2': [ 'MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileNetV2Config', 'MobileNetV2Onnx...
185
0
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class _lowercase ( _A , unittest.Tes...
385
import os __lowerCamelCase : int = {"""I""": 1, """V""": 5, """X""": 10, """L""": 50, """C""": 1_00, """D""": 5_00, """M""": 10_00} def A__ ( _a : str ): '''simple docstring''' snake_case__ : int =0 snake_case__ : Any =0 wh...
385
1
"""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() SCREAM...
708
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerT...
509
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { '''configuration_git''': ['''GIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GitConfig''', '''GitVisionConfig'''], '''processing_git''': ['''GitProcessor'''],...
646
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require...
646
1
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class _lowerCamelCase ( _lowercase ): def __lt__(self , __a ) -> Optional[int]: return self[...
544
"""simple docstring""" def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
544
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowercase = Lock() def _A (UpperCamelCase : Tuple , UpperCamelCase : List[Any] , UpperCamelCase : List[str] , UpperCamelCase : List[st...
157
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import...
157
1
_snake_case = 8.314_4598 def lowercase_( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("Molar mass cannot be less than or...
714
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
231
0
import random def _UpperCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) ->int: UpperCAmelCase = a[left_index] UpperCAmelCase = left_index + 1 for j in range(left_index + 1 , lowerCAmelCase_ ): if a[j] < pivot: UpperCAmelCase...
377
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class __low...
377
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase__ ( A_ ): __a = ["""image_processor""", """tokenizer"""] __a = """ChineseCLIPImageProcessor"""...
430
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _UpperCAmelCase ( __lowerCamelCase : str ) -> None: _snake_case , _snake_case = analyze_text(__lowerCamelCase ) _snake_case ...
430
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from transfor...
457
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer UpperCAmelCase : Any = logging.getLogger(__name__) def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = argparse.ArgumentParser( ...
457
1
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 : Any = logging.get_logger(__name__) __A : Dict = { 'hustvl/yolos-small': 'ht...
709
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, ...
698
0
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging A_ : Optional[Any] = "\\n\n" A_ : int = "\nPerplexity (PPL) is one of the most common m...
38
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create s...
8
0
'''simple docstring''' from __future__ import annotations def UpperCAmelCase ( lowerCamelCase_ :int , lowerCamelCase_ :int ): '''simple docstring''' if b == 0: return (1, 0) (snake_case_) : List[str] = extended_euclid(lowerCamelCase_ , a %...
719
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaP...
267
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tenso...
0
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pyto...
11
0
import math def lowercase__ ( __A: int ): '''simple docstring''' __magic_name__ : List[str] = [] __magic_name__ : Optional[Any] = 2 __magic_name__ : List[str] = int(math.sqrt(__A ) ) # Size of eve...
704
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowerCamelCase : int = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_avail...
501
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=_a ) class __a( _a ): """simple docstring""" lowerCAmelCase = field(default='''image-classifi...
30
import numpy as np import datasets __a = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was introduced by Prof. P. C. M...
30
1
"""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 SCREAMING_SNAKE_CASE_ : List[str] = logging.get_lo...
500
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICE...
500
1
'''simple docstring''' a__ : int = 8.314_462 # Unit - J mol-1 K-1 def __snake_case ( SCREAMING_SNAKE_CASE_ : Tuple , SCREAMING_SNAKE_CASE_ : List[Any] , SCREAMING_SNAKE_CASE_ : Any ) -> float: """simple docstring""" if moles < 0 or kelvin < 0 o...
51
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property fr...
217
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
712
'''simple docstring''' from scipy.stats import pearsonr import datasets a : str = """ Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies...
672
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configur...
472
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 = { """cola""": ...
472
1
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_tor...
197
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_...
197
1
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class lowercase__ (...
475
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 = { "facebook/deit-base-distilled-patch16-22...
475
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.ut...
691
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __snake_case : Union[st...
691
1
import random from .binary_exp_mod import bin_exp_mod def _lowerCamelCase ( __lowerCamelCase , __lowerCamelCase=1000 ) -> List[Any]: '''simple docstring''' if n < 2: return False if n % 2 == 0: return n == 2 # this ...
79
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _snake_case ( unittest.TestCase ): """simple docstring""" def __SCREAMING_SNAKE_CASE ( self ) ->...
697
0
'''simple docstring''' def lowerCAmelCase__ ( a_ : list ) -> list: for i in range(len(a_ ) - 1 , 0 , -1 ): UpperCAmelCase__ : Dict = False for j in range(a_ , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: ...
708
'''simple docstring''' import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, ...
599
0
lowerCAmelCase : Dict = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def _lowercase ...
214
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor lowerCAmelCase : int = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( __a ): '''simple docstring''' def __init__( self : Tuple , *low...
214
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class SCREAMING_SNAKE_CASE__ (...
258
"""simple docstring""" import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def _A ( __lowercase , __lowercase , __lowercase ...
258
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case__ : List[str] = logging.get_logger(__name__) snake_case__ : Any = ...
23
"""simple docstring""" def _snake_case ( UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : list[list[int]] ): def update_area_of_max_square(UpperCamelCase : int , UpperCamelCase : int ) -> int: # BASE CASE if row >= rows or col >= cols...
160
0
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( """split_dict""" , [ SplitDict(), SplitDict({"""train""": SplitInfo(name="""train""" , num_bytes=1337 , num_examples=42 , dataset_name="""m...
715
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class _a (datasets.BeamBasedBuilder ): '''simple docstring''' def __A ( self ):...
64
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Tuple = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['LukeTokenizer'], } try: if not is_torch_av...
557
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : Optional[int] , _lowerCamelCase : List[A...
557
1
a_ : List[Any] = [ [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 _SCREAMING_SNAKE_CASE ( snake_case_ : Union[str, Any] , snake_case_ : Optional[int] , snake_case...
678
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available a_ : Union[str, Any] = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: if not is_to...
678
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.fu...
263
'''simple docstring''' def lowerCamelCase ( lowerCamelCase : Tuple): A_ : str = [0] * len(lowerCamelCase) A_ : Union[str, Any] = [] A_ : Union[str, Any] = [] A_ : Tuple = 0 for values in graph.values(): f...
665
0
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """weiweishi/roc-bert-base-zh""": """https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json""", } class SCRE...
218
0
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def _lowerCAmelCase ( _UpperCamelCase ): """simple docstring""" if "cls_token" in name: _lowercase: Tuple ...
353
import warnings warnings.warn( """memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: """ """`from accelerate import find_executable_batch_size` to avoid this warning.""", FutureWarning, )
137
0
import glob import os import random from string import ascii_lowercase, digits import cva __lowercase : str = """""" __lowercase : Optional[int] = """""" __lowercase : List[Any] = """""" __lowercase : Dict = 1 # (0 is vertical, 1 is horizontal) def lowerCamelCase...
702
"""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_common import ...
66
0
'''simple docstring''' from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_...
638
'''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.co...
638
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A: List[str] = { """configuration_luke""": ["""LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LukeConfig"""], """tokenization_luke""": ["""LukeTokeni...
617
'''simple docstring''' # 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...
617
1
'''simple docstring''' import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCri...
107
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch ...
428
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
711
"""simple docstring""" snake_case__ : List[Any] = '''Tobias Carryer''' from time import time class snake_case_: def __init__( self : Optional[Any] , UpperCamelCase_ : Optional[Any] , UpperCamelCase_ : Tuple , UpperCamelCase_ : Optional[int...
637
0
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import...
153
"""simple docstring""" import enum import shutil import sys A__ , A__ : Optional[Any] = shutil.get_terminal_size() A__ : List[Any] = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class lowercase__ ( enum.Enum ): _UpperCAmelCase :Optional[A...
153
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCamelCase__( snake_case_ ): def __init__( self , __Up...
708
'''simple docstring''' from __future__ import annotations def lowercase__ ( __UpperCamelCase : list[float] ): '''simple docstring''' __lowercase = 0.00 __lowercase = 0 for resistor in resistors: if resistor <= 0: __lowercase ...
339
0
def __lowerCAmelCase ( UpperCamelCase ) -> List[str]: lowerCAmelCase__ : List[str] = [] lowerCAmelCase__ : List[str] = [] lowerCAmelCase__ : Dict = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, '''...
678
lowerCAmelCase_ = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Zm""", """yottametre""": """Ym""", } # Exp...
678
1
"""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...
442
"""simple docstring""" import inspect import unittest class lowerCamelCase__ ( unittest.TestCase ): def SCREAMING_SNAKE_CASE_ ( self : int ): '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: ...
442
1
# 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 won't be considered # sin...
324
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging __magic_name__: Dict = logging.ge...
324
1
class a__ : def __init__( self ): """simple docstring""" __lowerCAmelCase = "" __lowerCAmelCase = "" __lowerCAmelCase = [] def __SCREAMING_SNAKE_CASE( self , _A , _A ): ...
552
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset,...
552
1
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( lowercase_ , lowercase_ , lowercase_=None ) -...
12
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import Co...
323
0
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_availa...
710
"""simple docstring""" import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask a_ = logging.getLogger(__name__) class __lowercase ( _UpperCAmelCase): """simple docstri...
48
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file, a...
45
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailable() ex...
112
0
def lowerCamelCase__ ( _lowercase ): '''simple docstring''' if not isinstance(UpperCamelCase__ , UpperCamelCase__ ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) UpperCAmelCase_ : List[Any] = str(UpperCamelCase__ )...
720
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCamelCase__ ( _lowercase ): '''simple docstring''' ...
300
0
"""simple docstring""" import functools def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = len(_UpperCamelCase ) __lowerCAmelCase = len(_UpperCamelCase ) @functools.cache def min_distance(...
636
"""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 .token...
636
1
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def UpperCamelCase ( _A : str , _A : Dict , _A : Tuple )-> Optional[Any]: """simple ...
232
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : int = { "configuration_electra": ["ELECTRA_PRETRAINED_CONFIG...
232
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : int , _UpperCAmelCase : int ): if b == 0: return 1 if (b % 2) == 0: return actual_power(_UpperCAmelCase , int(b / 2 ) ) * actual_power(_UpperCAmelCase , int(b / 2 ) ) else: return a * actual_pow...
4
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : List[Any] = logging.get_logger(__name__) __a : List[Any] = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/c...
534
0
"""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_bart im...
215
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_conf...
215
1
"""simple docstring""" _lowerCAmelCase = {str(digit): digit**5 for digit in range(1_0)} def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_lowerCamelCase ) ) def lowerCamelCase__ ( ...
259
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _A ( snake_case , snake_case , snake_case , snake_case , ) -> list[float]: _lowercase , _lowercase : Union[st...
245
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers im...
391
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 lowercase ( A__ , A__ ): '''simple do...
391
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...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Union[str, Any] = {"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]} try: if no...
564
0
'''simple docstring''' import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py _lowercase = 'src/transformers'...
709
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { ...
242
0
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping snake_case = tuple[int, int] class UpperCAmelCase : def __init__( self : List[Any] , __lowerCamelCase : set[int] , __l...
103
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCAmelCase_ = { '''...
39
0
"""simple docstring""" import baseaa def UpperCAmelCase__ ( lowerCAmelCase__ :str ) -> Union[str, Any]: '''simple docstring''' return baseaa.baaencode(string.encode("""utf-8""" ) ) def UpperCAmelCase__ ( lowerCAmelCase__ :bytes ) -> Optional[i...
710
"""simple docstring""" import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __lowerCAmelCase : Optional[Any] =( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", ...
197
0
"""simple docstring""" from __future__ import annotations def __snake_case ( UpperCamelCase__ , UpperCamelCase__ ) -> tuple[int, int]: """simple docstring""" if b == 0: return (1, 0) ((A) , (A)) = extended_euclid(UpperCamelCase__ , ...
690
"""simple docstring""" import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase__ : def __init__( self : Optional[Any] , _lowercase : int=2 , _lowercase : Option...
690
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configu...
703
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging loggi...
119
0