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
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def snake_case_ ( __lowercase ...
720
import fire from utils import calculate_rouge, save_json def snake_case_ ( __lowercase , __lowercase , __lowercase=None , **__lowercase ): UpperCAmelCase_ : Tuple = [x.strip() for x in open(__lowercase ).readlines()] UpperCAmelCase_ ...
641
0
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNet...
721
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
641
0
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case_ ( ): UpperCAmelCase_ : str = HfArgumentParser(__lowercase ) UpperCAmelCase_ : Optional[Any] = parser.parse_args_into_dataclasses()[0] UpperC...
700
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __UpperCamelCase : Dict = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control t...
641
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class lowerCAmelCase__( unittest.TestCase , snake_case__ ): '''simple docstring''' def _lowerCamelCase ( self : List[str] ): ...
701
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case_ ( ): UpperCAmelCase_ : str = HfArgumentParser(__lowercase ) UpperCAmelCase_ : Optional[Any] = parser.parse_args_into_dataclasses()[0] UpperC...
641
0
from math import pi def snake_case_ ( __lowercase , __lowercase ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
702
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelCase : str = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( ...
641
0
from math import factorial, pi def snake_case_ ( __lowercase , __lowercase = 3_0 ): if not isinstance(__lowercase , (int, float) ): raise ValueError('''maclaurin_sin() requires either an int or float for theta''' ) if not isinstance(__lowercase , __lo...
703
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def snake_case_ ( __lowercase , __lowercase ): # Lo...
641
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseMo...
704
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaToke...
641
0
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class lowerCAmelCase__( snake_case__...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : str = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', '...
641
0
'''simple docstring''' from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class lowerCAmelCa...
706
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCAmelCase__( snake_case__ ...
641
0
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __UpperCamelCase : List[Any] = { 'sample_size': 32, 'in_channels': 3, 'out_channels': 3, 'layers_per_block': 2...
707
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase__: '''simple docstring''' A_ : torch.Tensor # [batch_size x 3] A_ : torch.Tensor # [batch_size x 3] A_ : torch.Ten...
641
0
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Tuple = {name: getattr...
708
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, reca...
641
0
def snake_case_ ( __lowercase , __lowercase , __lowercase=False ): if isinstance(__lowercase , __lowercase ) and isinstance(__lowercase , __lowercase ): UpperCAmelCase_ : Tuple = len(set_a.intersection(__lowercase ) ...
709
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) class lowerCAmelCase__( snake_case__ ): '''simple docstring''' A_ : Union[str, ...
641
0
def snake_case_ ( __lowercase = 1 , __lowercase = 1_0_0_0 ): UpperCAmelCase_ : Any = 1 UpperCAmelCase_ : str = 0 for divide_by_number in range(__lowercase , digit + 1 ): UpperCAmelCase_ : list[int] = [...
710
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( ...
641
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Union[str, Any] = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHI...
711
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def snake_case_ ( __lowercase , __low...
641
0
def snake_case_ ( __lowercase , __lowercase ) -> Tuple: return int((input_a, input_a).count(0 ) == 0 ) def snake_case_ ( ) -> Optional[int]: assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_g...
712
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'ti...
641
0
'''simple docstring''' import string def snake_case_ ( __lowercase ): UpperCAmelCase_ : Optional[int] = '''''' for i in sequence: UpperCAmelCase_ : Optional[Any] = ord(__lowercase ) if 6_5 <= extract <= 9_0: outp...
713
def snake_case_ ( __lowercase ): return " ".join( ''''''.join(word[::-1] ) if len(__lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('Hey wollef...
641
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Dict = { 'configuration_resnet': ['RESNET_P...
714
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator fr...
641
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
715
# 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/LICENSE-2.0 # # Unless require...
641
0
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_co...
716
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCAmelCase__: '''simple docstring''' def __init__( self : List[str] , __snake_case : Union[str, Any] ): '''simple docstring''' ...
641
0
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCAmelCase__( snake_case__ ): '''simple docstring''' A_ : Any = 'EncodecFeatureExtractor' A_ : Dic...
717
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/conf...
641
0
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def snake_case_ ( __lowercase : Optional[Any] ): return ...
718
import math import qiskit def snake_case_ ( __lowercase = 1 , __lowercase = 1 , __lowercase = 1 ): if ( isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , _...
641
0
def snake_case_ ( __lowercase ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], }, { ...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Dict = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/...
641
0
def snake_case_ ( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase ): if index == number_of_items: return 0 UpperCAmelCase_ : Union[str, Any] = 0 UpperCAmelCase_ : Optional[int] = 0 UpperC...
720
import fire from utils import calculate_rouge, save_json def snake_case_ ( __lowercase , __lowercase , __lowercase=None , **__lowercase ): UpperCAmelCase_ : Tuple = [x.strip() for x in open(__lowercase ).readlines()] UpperCAmelCase_ ...
641
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPip...
721
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
641
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available __UpperCamelCase : Optional[Any] = { 'configuration_ernie': ['ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ErnieConfig', 'ErnieOnnxConfig']...
700
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __UpperCamelCase : Dict = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control t...
641
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Tuple = { 'RWKV/rwkv-4-169m-pile': 'https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.jso...
701
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case_ ( ): UpperCAmelCase_ : str = HfArgumentParser(__lowercase ) UpperCAmelCase_ : Optional[Any] = parser.parse_args_into_dataclasses()[0] UpperC...
641
0
def snake_case_ ( __lowercase ): UpperCAmelCase_ : Union[str, Any] = 1 UpperCAmelCase_ : List[Any] = 2 while i * i <= n: UpperCAmelCase_ : int = 0 while n % i == 0: n //= i multiplicity += 1 ...
702
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelCase : str = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( ...
641
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def snake_case_ ( __lowercase ): UpperCAmelCase_ : ...
703
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def snake_case_ ( __lowercase , __lowercase ): # Lo...
641
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __UpperCamelCase : List[str] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAv...
704
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaToke...
641
0
import string from math import logaa def snake_case_ ( __lowercase , __lowercase ): UpperCAmelCase_ : List[Any] = document.translate( str.maketrans('''''' , '''''' , string.punctuation ) ).replace('''\n''' , '''''' )...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : str = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', '...
641
0
'''simple docstring''' __UpperCamelCase : Optional[Any] = { 'Pillow': 'Pillow', 'accelerate': 'accelerate>=0.11.0', 'compel': 'compel==0.1.8', 'black': 'black~=23.1', 'datasets': 'datasets', 'filelock': 'filelock', 'flax': 'flax>=0.4.1', 'hf-d...
706
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCAmelCase__( snake_case__ ...
641
0
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def snake_case_ ( __lowercase , __low...
707
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase__: '''simple docstring''' A_ : torch.Tensor # [batch_size x 3] A_ : torch.Tensor # [batch_size x 3] A_ : torch.Ten...
641
0
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py __UpperCamelCase : Tuple = '.' if __name__ == "__main__": __UpperCamelCase : List[Any] = os.path.join(REPO_...
708
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, reca...
641
0
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCAmelCase__: '''simple docstring''' def __init__( self : str , __snake_case : str=2 , __snake_case ...
709
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) class lowerCAmelCase__( snake_case__ ): '''simple docstring''' A_ : Union[str, ...
641
0
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_di...
710
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( ...
641
0
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig...
711
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def snake_case_ ( __lowercase , __low...
641
0
import math from collections.abc import Iterator from itertools import takewhile def snake_case_ ( __lowercase ) -> str: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even nu...
712
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'ti...
641
0
'''simple docstring''' from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_...
713
def snake_case_ ( __lowercase ): return " ".join( ''''''.join(word[::-1] ) if len(__lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('Hey wollef...
641
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( __lowercase , __lowercase ): print(F'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(__lowercase ): print(F'''{i}\t\t{d}''' ) def snake_ca...
714
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator fr...
641
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Any = { 'configuration_whisper': ['WHISPER_PRET...
715
# 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/LICENSE-2.0 # # Unless require...
641
0
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def snake_case_ ( __lowercase ): UpperCAmelCase_ : Optional[Any] = int(__lowercas...
716
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCAmelCase__: '''simple docstring''' def __init__( self : List[str] , __snake_case : Union[str, Any] ): '''simple docstring''' ...
641
0
import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class lower...
717
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/conf...
641
0
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def snake_case_ ( __lowercase : Optional[Any] ): UpperCAmelCase_ : str = {} UpperCAm...
718
import math import qiskit def snake_case_ ( __lowercase = 1 , __lowercase = 1 , __lowercase = 1 ): if ( isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , _...
641
0
def snake_case_ ( __lowercase ): UpperCAmelCase_ : Tuple = len(__lowercase ) while cur > 1: # Find the maximum number in arr UpperCAmelCase_ : Union[str, Any] = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi ...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Dict = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/...
641
0
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor...
720
import fire from utils import calculate_rouge, save_json def snake_case_ ( __lowercase , __lowercase , __lowercase=None , **__lowercase ): UpperCAmelCase_ : Tuple = [x.strip() for x in open(__lowercase ).readlines()] UpperCAmelCase_ ...
641
0
def snake_case_ ( __lowercase = 5_0 ): UpperCAmelCase_ : Optional[int] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - til...
721
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
641
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Union[str, Any] = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
700
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __UpperCamelCase : Dict = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control t...
641
0
def snake_case_ ( __lowercase ): if num <= 0: raise ValueError('''Input must be a positive integer''' ) UpperCAmelCase_ : Any = [True] * (num + 1) UpperCAmelCase_ : Any = 2 while p * p <= num: if primes[p]: for...
701
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case_ ( ): UpperCAmelCase_ : str = HfArgumentParser(__lowercase ) UpperCAmelCase_ : Optional[Any] = parser.parse_args_into_dataclasses()[0] UpperC...
641
0
def snake_case_ ( __lowercase ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
702
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelCase : str = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( ...
641
0
import operator def snake_case_ ( __lowercase , __lowercase = False , __lowercase = None ): UpperCAmelCase_ : Any = operator.lt if reverse else operator.gt UpperCAmelCase_ : Optional[int] = solution or [] if not arr: return solution ...
703
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def snake_case_ ( __lowercase , __lowercase ): # Lo...
641
0
import qiskit def snake_case_ ( __lowercase = 2 ): UpperCAmelCase_ : Union[str, Any] = qubits # Using Aer's simulator UpperCAmelCase_ : Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) # Creating a Quantum Circuit acting on the q r...
704
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaToke...
641
0
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTe...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : str = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', '...
641
0
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common imp...
706
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCAmelCase__( snake_case__ ...
641
0
import os import sys __UpperCamelCase : List[Any] = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoM...
707
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase__: '''simple docstring''' A_ : torch.Tensor # [batch_size x 3] A_ : torch.Tensor # [batch_size x 3] A_ : torch.Ten...
641
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.jso...
708
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, reca...
641
0
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def snake_case_ ( __lowercase ): UpperCAmelCase_ : Any = [ '''encoder.version''', '''decoder.version''', '''model....
709
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) class lowerCAmelCase__( snake_case__ ): '''simple docstring''' A_ : Union[str, ...
641
0
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def snake_case_ ( __lowercase , __lowercase , __lowercase = 1_0**-1_0 ): UpperCAmelCase_ : Optional[Any] = a while True: ...
710
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( ...
641
0
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FIL...
711
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def snake_case_ ( __lowercase , __low...
641
0
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__( unittest.Tes...
712
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'ti...
641
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Union[str, Any] = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: i...
713
def snake_case_ ( __lowercase ): return " ".join( ''''''.join(word[::-1] ) if len(__lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('Hey wollef...
641
0
'''simple docstring''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_mode...
714
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator fr...
641
0
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__ ): '''simple docstring''' ...
715
# 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/LICENSE-2.0 # # Unless require...
641
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def snake_case_ ( __lowercase , __lowercase , __lowercase ): # Initia...
716
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCAmelCase__: '''simple docstring''' def __init__( self : List[str] , __snake_case : Union[str, Any] ): '''simple docstring''' ...
641
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
717
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/conf...
641
0
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def snake_case_ ( __lowercase : List[Any]...
718
import math import qiskit def snake_case_ ( __lowercase = 1 , __lowercase = 1 , __lowercase = 1 ): if ( isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , __lowercase ) or isinstance(__lowercase , _...
641
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_availabl...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Dict = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/...
641
0
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor __UpperCamelCase : int = logging.get_logger(__name__) class lowerCAmelCase__( snake_case__ ): '''simple docstring''' def __i...
720
import fire from utils import calculate_rouge, save_json def snake_case_ ( __lowercase , __lowercase , __lowercase=None , **__lowercase ): UpperCAmelCase_ : Tuple = [x.strip() for x in open(__lowercase ).readlines()] UpperCAmelCase_ ...
641
0
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: {act_f...
721
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
641
0
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_torchaudio @require_...
642
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a__ : Any = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"]} tr...
642
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipel...
642
# Imports import numpy as np class UpperCAmelCase__: '''simple docstring''' def __init__( self : Any , lowerCAmelCase : Dict=None , lowerCAmelCase : List[Any]=None , lowerCAmelCase : List[Any]=None , lowerCAmelCase : List[str]=None , lowerCAmelCase :...
642
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
642
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCAmelCase__( unittest.TestCase , lowerCamelCase ): '''simple docstring''' def UpperCAmelCase ( self : List[str]) -> Any: """simple docstring"...
642
1
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : Tuple = (KDPMaDiscreteScheduler,) A : str ...
642
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : List[Any] ...
642
1
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 from ...test_pipeline_mixi...
642
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCAmelCase ( A__ ): lowercase__ = prime_factors(A__ ) if is_square_free(A__ ): return -1 if len(A__ ) % 2 else 1 return 0 if __name__ == "__main__": import doc...
642
1
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() a__ : str = logging.get_logger(__name__) def...
642
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : List[str] = logging.get_logger(__name__) a__ : List[Any] = { "microsoft/focalnet-tiny": "https:/...
642
1
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda fro...
642
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ : Optional[int] = logging.get_logger(__name__) a__ : Dict = { "vocab_file": "vocab.json", "merges_fil...
642
1
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class UpperCAmelCase__( unittest.TestCase ): '''simple docstring''' ...
642
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : Optional[int] = { "configuration_blenderbot": [ "BLENDERBOT_PRETRAINED_CON...
642
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Any = logging.get_logger(__name__) a__ : List[Any] = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "https://huggingface.co/goog...
642
import heapq import sys import numpy as np a__ : Dict = tuple[int, int] class UpperCAmelCase__: '''simple docstring''' def __init__( self : List[str]) -> Any: """simple docstring""" lowercase__ = [] lowercase__ = set() def ...
642
1
import math def _lowerCAmelCase ( A__ ): return math.sqrt(A__ ) * math.sqrt(A__ ) == num def _lowerCAmelCase ( A__ ): lowercase__ = 0 lowercase__ = n while left <= right: lowercase__ = (left + right) // 2 if mid**2 == n: ...
642
import math import sys def _lowerCAmelCase ( A__ ): lowercase__ = '' try: with open(A__ , 'rb' ) as binary_file: lowercase__ = binary_file.read() for dat in data: lowercase__ = F'''{dat:08b}''' r...
642
1
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : List[Any] ...
642
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging a__ : int = logging.get_logger(__name__) a__ : Tuple = {"vocab_file": "vocab.txt"} a__ : int ...
642
1
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) a__ : Dict = pytest.mark.integration @pytest.mark.parametrize('path' , ['paws', 'csv'] ) de...
642
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo a__ : int = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and M...
642
1
from math import factorial def _lowerCAmelCase ( A__ , A__ ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError('Please enter positive integers ...
642
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...te...
642
1
import csv import tweepy # Twitter API credentials a__ : Optional[int] = "" a__ : Union[str, Any] = "" a__ : str = "" a__ : Optional[Any] = "" def _lowerCAmelCase ( A__ ): # authorize twitter, initialize tweepy lowercase__ = tweepy.OAu...
642
def _lowerCAmelCase ( A__ , A__ , A__ ): if principal <= 0: raise Exception('Principal borrowed must be > 0' ) if rate_per_annum < 0: raise Exception('Rate of interest must be >= 0' ) if years_to_repay <= 0 or not isinstance(A__ , A__ ): ...
642
1
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/nie...
642
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ ): if b == 0: return (1, 0) ((lowercase__), (lowercase__)) = extended_euclid(A__ , a % b ) lowercase__ = a // b return (y, x - k * y) def _lowerCAmelCase ( A__ , A__...
642
1
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( ...
642
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : Optional[Any] = { "google/umt5-small": "https://huggingface.co/google...
642
1
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, ren...
642
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokenization_com...
642
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.utils ...
642
import argparse import hashlib # hashlib is only used inside the Test class import struct class UpperCAmelCase__: '''simple docstring''' def __init__( self : Optional[Any] , lowerCAmelCase : str) -> Optional[int]: """simple docstring""" lowercase__ ...
642
1
from __future__ import annotations import os from collections.abc import Mapping a__ : Union[str, Any] = tuple[int, int] class UpperCAmelCase__: '''simple docstring''' def __init__( self : Optional[int] , lowerCAmelCase : set[int] , lowerCAmelCase : Mapping...
642
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 import BartTokenizer a__ ...
642
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a__ : Dict = logging.get_logger(__name__) a__ : List[str] =...
642
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : str = (DDIMParallelScheduler,) A : Any = (("eta", 0.0), ("num_inference_step...
642
1
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : int = logging.get_logger(__name__) a__ : Optional[Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research/efficientformer-l1-300/r...
642
import cva import numpy as np class UpperCAmelCase__: '''simple docstring''' def __init__( self : Union[str, Any] , lowerCAmelCase : float , lowerCAmelCase : int) -> Dict: """simple docstring""" if k in (0.04, 0.06): lowercase__ ...
642
1
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 ANY if is_vision_avai...
642
from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Dict = logging.get_logger(__name__) a__ : List[Any] = { "facebook/s2t-small-librispeech-asr": ( "https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json" ), ...
642
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class UpperCAmelCase__( unittest.Te...
642
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a__ : Any = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"]} tr...
642
1
def _lowerCAmelCase ( A__ = 1_000 ): lowercase__ = 2**power lowercase__ = str(A__ ) lowercase__ = list(A__ ) lowercase__ = 0 for i in list_num: sum_of_num += int(A__ ) return sum_of_num if __name__ == "__main__": a__ : A...
642
# Imports import numpy as np class UpperCAmelCase__: '''simple docstring''' def __init__( self : Any , lowerCAmelCase : Dict=None , lowerCAmelCase : List[Any]=None , lowerCAmelCase : List[Any]=None , lowerCAmelCase : List[str]=None , lowerCAmelCase :...
642
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
642
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCAmelCase__( unittest.TestCase , lowerCamelCase ): '''simple docstring''' def UpperCAmelCase ( self : List[str]) -> Any: """simple docstring"...
642
1
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
642
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : List[Any] ...
642
1
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCAmelCase ( A__ ): lowercase__ = prime_factors(A__ ) if is_square_free(A__ ): return -1 if len(A__ ) % 2 else 1 return 0 if __name__ == "__main__": import doc...
642
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCAmelCase ( A__ ): lowercase__ = prime_factors(A__ ) if is_square_free(A__ ): return -1 if len(A__ ) % 2 else 1 return 0 if __name__ == "__main__": import doc...
642
1
from __future__ import annotations import math def _lowerCAmelCase ( A__ ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ...
642
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a__ : List[str] = logging.get_logger(__name__) a__ : List[Any] = { "microsoft/focalnet-tiny": "https:/...
642
1
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def _lowerCAmelCase ( A__ , A__ ): lowercase__ = F'''{sampling_rate}''' lowercase__ = '1' lowercase__ = 'f32le' lowercase__ = [ 'ffmpe...
642
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ : Optional[int] = logging.get_logger(__name__) a__ : Dict = { "vocab_file": "vocab.json", "merges_fil...
642
1
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging a__ : str = logging.get_logger(__name__) def _lowerCAmelCase ( A__ , A__ ): ...
642
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : Optional[int] = { "configuration_blenderbot": [ "BLENDERBOT_PRETRAINED_CON...
642
1
def _lowerCAmelCase ( A__ = 1_000 ): lowercase__, lowercase__ = 1, 1 lowercase__ = 2 while True: lowercase__ = 0 lowercase__ = fa + fa lowercase__, lowercase__ = fa, f index += 1 for _ in str(A__ ): ...
642
import heapq import sys import numpy as np a__ : Dict = tuple[int, int] class UpperCAmelCase__: '''simple docstring''' def __init__( self : List[str]) -> Any: """simple docstring""" lowercase__ = [] lowercase__ = set() def ...
642
1
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a__ : List[str] = logging.get_logger(__name__) def _lowerCAmelCase ( A__ ): if isinstance(A__ , np.ndarray ): return list(tensor.shape ) lowercase_...
642
import math import sys def _lowerCAmelCase ( A__ ): lowercase__ = '' try: with open(A__ , 'rb' ) as binary_file: lowercase__ = binary_file.read() for dat in data: lowercase__ = F'''{dat:08b}''' r...
642
1