code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding...
40
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vis...
40
1
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase , _UpperCAmelCase : str = analyze_text(__lowerCAmelCase ) _...
40
'''simple docstring''' import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, se...
40
1
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean lowerCamelCase__ = 0 lowerCamelCase__ = [ [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, ...
40
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
40
1
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase__ : def __init__( self : Optional[int] ) ->Optional[int]: '''simple docstring''' _UpperCAmelCase : ...
40
'''simple docstring''' from __future__ import annotations import numpy as np def __lowerCAmelCase (__lowerCAmelCase ): return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
40
1
'''simple docstring''' import qiskit def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : int = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register _UpperCAmelCase : List[Any] ...
40
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowe...
40
1
'''simple docstring''' from __future__ import annotations import queue class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Tuple ) ->Dict: '''simple docstring''' _UpperCAmelCase : str = data ...
40
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
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_torch...
40
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def ...
40
1
'''simple docstring''' from collections import Counter from timeit import timeit def __lowerCAmelCase (__lowerCAmelCase = "" , ): return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def __lowerCAmelCase (__lowerCAmelCase = ""...
40
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
40
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase__ ( UpperCAmelCase__ ): lowerCAmelCase : Dict = ["image_processor", "tokenizer"] lowerCAmelCase : Tuple ...
40
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): # noqa: E741 _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) _UpperCAmelCase : str = 0 _UpperCAmelCase : List[str] = [0] * n _UpperCAmelCase : int = ...
40
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class lowerCAmelCase__ : def __init__( self : Any , lowerCamelCase__ : Any ) ->Union[str, Any]: '''simple docstring''' ...
40
'''simple docstring''' def __lowerCAmelCase (): _UpperCAmelCase : str = 0 for i in range(1 , 1_001 ): total += i**i return str(__lowerCAmelCase )[-10:] if __name__ == "__main__": print(solution())
40
1
'''simple docstring''' from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowerCamelCase__ = HfArgumentParser(InitializationArguments) lowerCamelCase__ = parser.parse_args() # Lo...
40
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__lowerCAmelCase , __lowerCAmelCa...
40
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', ...
40
'''simple docstring''' 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 ...
40
1
'''simple docstring''' from math import isclose, sqrt def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : Dict = point_y / 4 / point_x _UpperCAmelCase : List[str] = 2 * normal_gradient / (1 + n...
40
'''simple docstring''' from math import factorial class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Union[str, Any] , lowerCamelCase__ : str ) ->Dict: '''simple docstring''' _UpperCAmelCase : Optional[...
40
1
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class lowerCAmelCase__ ( UpperCAmelCase__ ): def __init__( self : Union[str, Any] , *lowerCamelCase__ : List[str] , **lowerCamelCase__ : str ) ->int: '''si...
40
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -...
40
1
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): if index == number_of_items: return 0 _UpperCAmelCase : int = 0 _UpperCAmelCase : List[Any] = ...
40
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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 ...
40
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule lowerCamelCase__ = {'tokenization_tapex': ['TapexTokenizer']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys lowerCamelCase__ = ...
40
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', ...
40
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import...
40
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
1
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddin...
40
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torc...
40
1
'''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 lowerCamelCase__ = 'src/transformers' lo...
40
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Op...
40
1
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : List[Any] = [ "encoder.version", "decoder.versi...
700
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
0
'''simple docstring''' from math import pow, sqrt def __lowerCAmelCase (*__lowerCAmelCase ): _UpperCAmelCase : str = len(__A ) > 0 and all(value > 0.0 for value in values ) return result def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ...
701
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_b...
40
0
import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() lowerCamelCase__ = ...
702
'''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...
40
0
'''simple docstring''' import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : List[A...
703
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vis...
40
0
'''simple docstring''' from __future__ import annotations import math def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ) -> float: _UpperCAmelCase : str = u for i in range(1 , _lowercase ): _UpperCAmelCase : str = ...
704
'''simple docstring''' import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, se...
40
0
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase = 100 ): _UpperCAmelCase : Union[str, Any] = 0 _UpperCAmelCase : str = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squar...
705
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
40
0
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ = collections.namedtuple('_Dataset...
706
'''simple docstring''' from __future__ import annotations import numpy as np def __lowerCAmelCase (__lowerCAmelCase ): return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
40
0
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = list[list[int]] # assigning initial values to the grid lowerCamelCase__ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0...
707
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowe...
40
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = { 'configuration_rembe...
708
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
0
'''simple docstring''' from __future__ import annotations from fractions import Fraction def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def __lowerC...
709
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def ...
40
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowerCamelCase__ = logging.get_logger(__name__) def __lowerCAmelCase (__lowerCAmelCase ): if isinstance(lowerCamelCase__ , np.n...
710
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
40
0
'''simple docstring''' from __future__ import annotations from fractions import Fraction def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den...
711
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): # noqa: E741 _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) _UpperCAmelCase : str = 0 _UpperCAmelCase : List[str] = [0] * n _UpperCAmelCase : int = ...
40
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken fro...
712
'''simple docstring''' def __lowerCAmelCase (): _UpperCAmelCase : str = 0 for i in range(1 , 1_001 ): total += i**i return str(__lowerCAmelCase )[-10:] if __name__ == "__main__": print(solution())
40
0
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging lowerCamelCase__ = logging.get_logger(__name__) class lowerCAmelCase__ (...
713
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__lowerCAmelCase , __lowerCAmelCa...
40
0
'''simple docstring''' import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate lowerCamelCase__ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerr...
714
'''simple docstring''' 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 ...
40
0
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta i...
715
'''simple docstring''' from math import factorial class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Union[str, Any] , lowerCamelCase__ : str ) ->Dict: '''simple docstring''' _UpperCAmelCase : Optional[...
40
0
'''simple docstring''' from math import factorial def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes < 0: raise Valu...
716
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -...
40
0
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCAmelCase__ ( unittest.TestCase ): def lowerCAmelCase__ ( self : int ) ->Tuple: ...
717
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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 ...
40
0
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common imp...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', ...
40
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor ...
719
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
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...
720
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torc...
40
0
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : List[str] = sorted(numsa + numsa ) _UpperCAmelCase : Dict = divmod(len(__UpperCamelCase ) , 2 ) if mod == 1: ...
721
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Op...
40
0
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , ): _UpperCAmelCase : Optional[int] = [redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for p in ...
700
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
0
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_...
701
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_b...
40
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, Ef...
702
'''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...
40
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/ma...
703
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vis...
40
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decisio...
704
'''simple docstring''' import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, se...
40
0
'''simple docstring''' from __future__ import annotations from math import ceil, floor, sqrt def __lowerCAmelCase (__lowerCAmelCase = 2_000_000 ): _UpperCAmelCase : list[int] = [0] _UpperCAmelCase : int for idx in range(1 , ceil(sqrt(target * 2 )...
705
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
40
0
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : List[str] = set(snake_case__ ), [start] while stack: _UpperCAmelCase : Dict = stack.pop() explored.add(snake_ca...
706
'''simple docstring''' from __future__ import annotations import numpy as np def __lowerCAmelCase (__lowerCAmelCase ): return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
40
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizer...
707
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowe...
40
0
'''simple docstring''' import colorsys from PIL import Image # type: ignore def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : Union[str, Any] = x _UpperCAmelCase : int = y for step in ...
708
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
0
'''simple docstring''' import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeq...
709
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def ...
40
0
'''simple docstring''' import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ...
710
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
40
0
'''simple docstring''' lowerCamelCase__ = 'Alexander Joslin' import operator as op from .stack import Stack def __lowerCAmelCase (__lowerCAmelCase ): '''simple docstring''' _UpperCAmelCase : List[str] = {"*": op.mul, "/": op.truediv, "+": op....
711
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): # noqa: E741 _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) _UpperCAmelCase : str = 0 _UpperCAmelCase : List[str] = [0] * n _UpperCAmelCase : int = ...
40
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_AR...
712
'''simple docstring''' def __lowerCAmelCase (): _UpperCAmelCase : str = 0 for i in range(1 , 1_001 ): total += i**i return str(__lowerCAmelCase )[-10:] if __name__ == "__main__": print(solution())
40
0
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import Pretraine...
713
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__lowerCAmelCase , __lowerCAmelCa...
40
0
'''simple docstring''' import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, requir...
714
'''simple docstring''' 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 ...
40
0
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): if length <= 0 or not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(SCREAMING_SNAKE_CASE_ )] if __name_...
715
'''simple docstring''' from math import factorial class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Union[str, Any] , lowerCamelCase__ : str ) ->Dict: '''simple docstring''' _UpperCAmelCase : Optional[...
40
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=__snake_case ): lowerCAmelCase : str = ['torch'] def __init__( self : Any , *lowerCamelCase__ : Any , **lowerCamelCase__ : List[Any] ) ...
716
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -...
40
0
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models im...
717
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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 ...
40
0
'''simple docstring''' import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) lowerCamelCase__ = logging.getLogger() ...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', ...
40
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCamelCase__ = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: i...
719
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
0
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers...
720
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torc...
40
0
'''simple docstring''' import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask fr...
721
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Op...
40
0
'''simple docstring''' import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap lowerCamelCase__ = 'Usage of script: script_name <size_of_canvas:int>' lowerCamelCase__ = [0] * 100 + [1] * 10 random.shuffle(choic...
700
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
0
'''simple docstring''' 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 impo...
701
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_b...
40
0
class lowerCAmelCase__ : def __init__( self : Dict , lowerCamelCase__ : Dict ) ->None: '''simple docstring''' _UpperCAmelCase : List[str] = size _UpperCAmelCase : Optional[int] = [0] * size _UpperCAmelCa...
702
'''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...
40
0
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : Optional[Any] = 2 _UpperCAmelCase : Optional[Any] = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append...
703
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vis...
40
0
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, s...
704
'''simple docstring''' import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, se...
40
0
'''simple docstring''' from PIL import Image def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): def brightness(__lowerCAmelCase ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError("level must be betwee...
705
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
40
0
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
706
'''simple docstring''' from __future__ import annotations import numpy as np def __lowerCAmelCase (__lowerCAmelCase ): return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
40
0
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def...
707
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowe...
40
0
'''simple docstring''' import math class lowerCAmelCase__ : def lowerCAmelCase__ ( self : int , lowerCamelCase__ : list[list[float]] , lowerCamelCase__ : list[int] ) ->int: '''simple docstring''' _UpperCAmelCase : ...
708
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
0
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMSchedul...
709
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def ...
40
0
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ): @require_torch def low...
710
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
40
0
'''simple docstring''' import math from collections import defaultdict 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 KarrasDiffusionSchedulers, SchedulerMixin, Scheduler...
711
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): # noqa: E741 _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) _UpperCAmelCase : str = 0 _UpperCAmelCase : List[str] = [0] * n _UpperCAmelCase : int = ...
40
0
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
712
'''simple docstring''' def __lowerCAmelCase (): _UpperCAmelCase : str = 0 for i in range(1 , 1_001 ): total += i**i return str(__lowerCAmelCase )[-10:] if __name__ == "__main__": print(solution())
40
0
'''simple docstring''' import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def __lowerCAmelCase (__lowerCAmelCase ): return 1 / (1 + np.exp(-z )) def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return (-y * np.log(a_...
713
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__lowerCAmelCase , __lowerCAmelCa...
40
0
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): ...
714
'''simple docstring''' 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 ...
40
0
'''simple docstring''' lowerCamelCase__ = range(2, 20 + 1) lowerCamelCase__ = [10**k for k in range(ks[-1] + 1)] lowerCamelCase__ = {} def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase...
715
'''simple docstring''' from math import factorial class lowerCAmelCase__ : def __init__( self : int , lowerCamelCase__ : Union[str, Any] , lowerCamelCase__ : str ) ->Dict: '''simple docstring''' _UpperCAmelCase : Optional[...
40
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase__ = logging.get_logger(__name__) # TODO: upload to AWS lowerCamelCase__ = { 'yjernite/retribert-base-uncased': ( 'https://huggingface.co/yjernite/re...
716
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -...
40
0
'''simple docstring''' import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils imp...
717
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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 ...
40
0
'''simple docstring''' lowerCamelCase__ = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': ...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', ...
40
0
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowerCamelCase__ = 3 def __lowerCAmelCase (__lowerCAmelCase ): print("Generating primitive root of p" ) while True: _UpperCAmelCas...
719
'''simple docstring''' import os def __lowerCAmelCase (): _UpperCAmelCase : List[Any] = os.path.join(os.path.dirname(__lowerCAmelCase ) , "num.txt" ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand...
40
0
'''simple docstring''' from math import factorial def __lowerCAmelCase (__lowerCAmelCase = 100 ): return sum(int(lowerCAmelCase__ ) for x in str(factorial(lowerCAmelCase__ ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
720
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torc...
40
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not is_torch_availab...
721
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Op...
40
0
'''simple docstring''' from itertools import permutations def __lowerCAmelCase (__lowerCAmelCase ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False _UpperCAmelCase : Tuple = ...
700
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
0
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_asyn...
701
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_b...
40
0
def __lowerCAmelCase (__lowerCAmelCase ): assert isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ), F"""The input value of [n={number}] is not an integer""" if number == 1: return 2 elif number < 1: _UpperCAmelCase : Dict = F"""The input value of [n={numb...
702
'''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...
40
0
'''simple docstring''' import functools def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : Tuple = len(__lowercase ) _UpperCAmelCase : Any = len(__lowercase ) @functools.cache def min_distance(__lowerCAmelCase , __low...
703
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vis...
40
0
'''simple docstring''' 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.test...
704
'''simple docstring''' import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, se...
40
0
'''simple docstring''' import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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...
705
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
40
0
'''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 lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = ...
706
'''simple docstring''' from __future__ import annotations import numpy as np def __lowerCAmelCase (__lowerCAmelCase ): return np.maximum(0 , __lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
40
0
'''simple docstring''' from __future__ import annotations from statistics import mean def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : int = [0] * no_of_processes _UpperCAmelCase : Dict = ...
707
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowe...
40
0
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : Optional[int] = "" for i in table: res += inp[i - 1] return res def __lowerCAmelCase (__lowerCAmelCase ): return data[1:] + data[0] de...
708
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCamelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for T...
40
0
'''simple docstring''' # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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/license...
709
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def ...
40
0
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance lowerCamelCase__ = 6_378_137.0 lowerCamelCase__ = 6_356_752.314_245 lowerCamelCase__ = 6_378_137 def __lowerCAmelCase (__lowerCAmelCase , ...
710
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType ...
40
0
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def __lowerCAmelCase (__lowerCAmelCase ): '''...
711
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): # noqa: E741 _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) _UpperCAmelCase : str = 0 _UpperCAmelCase : List[str] = [0] * n _UpperCAmelCase : int = ...
40
0
'''simple docstring''' import math lowerCamelCase__ = 10 lowerCamelCase__ = 7 lowerCamelCase__ = BALLS_PER_COLOUR * NUM_COLOURS def __lowerCAmelCase (__lowerCAmelCase = 20 ): _UpperCAmelCase : int = math.comb(lowerCamelCase_ , lowerCamel...
712
'''simple docstring''' def __lowerCAmelCase (): _UpperCAmelCase : str = 0 for i in range(1 , 1_001 ): total += i**i return str(__lowerCAmelCase )[-10:] if __name__ == "__main__": print(solution())
40
0
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): return "".join(chr(ord(A__ ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
713
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__lowerCAmelCase , __lowerCAmelCa...
40
0
'''simple docstring''' 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 ...
714
'''simple docstring''' 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 ...
40
0