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 argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import DataLoa...
717
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Tuple: if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) UpperCAmelCase_ = sum(_lowerCamelCase ) / len(_lowerCamelCase ) # Calculate the average return sum(abs(x - average ) for x in nums ) / len(_low...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case__ ( ) -> Any: UpperCAmelCase_ = HfArgumentParser(lowercase_ ) UpperCAmelCase_ = parser.parse_args_into_dataclasses()[0] UpperCAmelCase_ ...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging SCREAMING_SNAKE_CASE = "\\n\n" SCREAMING_SNAKE_CASE = "\nPerplexity (PPL) is one of the most common metrics fo...
720
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 0 while number > 0: UpperCAmelCase_ = number % ...
23
0
import math SCREAMING_SNAKE_CASE = 10 SCREAMING_SNAKE_CASE = 7 SCREAMING_SNAKE_CASE = BALLS_PER_COLOUR * NUM_COLOURS def snake_case__ ( __SCREAMING_SNAKE_CASE = 20 ) -> List[str]: UpperCAmelCase_ = math.comb(_lowerCamelCase , _lowerCamelCase ...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
23
0
import heapq import sys import numpy as np SCREAMING_SNAKE_CASE = tuple[int, int] class lowerCamelCase : '''simple docstring''' def __init__( self ): UpperCAmelCase_ = [] UpperCAmelCase_ = set() def A__ ( self ): ...
700
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__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
701
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase ): UpperCAmelCase_ = str(id_ ) UpperCAmelCase_ = None UpperCAmelCase_ = Non...
23
0
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase ( lowercase__ ): '''simple docstring''' lowerCAmelCase_ : str = (DDPMParallelScheduler,) def A__ ( self , **lowerCAm...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try...
23
0
import qiskit def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> List[Any]: UpperCAmelCase_ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register UpperCAmelCase_ = qiskit.QuantumCircuit(__lowercase , __...
703
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline SCREAMING_SNAKE_CASE = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argument("--dpm", action="s...
704
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nic...
705
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> np.array: UpperCAmelCase_ = f'''{sampling_rate}''' UpperCAmelCase_ = "1" UpperCAmelCase...
23
0
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa...
706
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( lowercase__, lowercase__ ): '''simple docstring''' @register_to_...
23
0
'''simple docstring''' def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Optional[Any]: if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) UpperCAmelCase_ = str(bin(_snake_case ) )[2:] # remove the leading "0b" Upper...
707
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
23
0
class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase , lowerCAmelCase ): UpperCAmelCase_ = name UpperCAmelCase_ = val def __str__( self ): return f'''{self.__class__.__name__}({self.name}, {self...
708
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availa...
23
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) ...
709
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 0, 0, 0 UpperCAmelCase_ = ugly_nums[ia] * 2 UpperCAmelCase_ = ugly_nums[ia] * 3 UpperCAmelCase_ = ugly_nums[i...
23
0
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as comput...
710
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test...
23
0
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 snake_case__ ( __SCREAMING_SNAKE_CASE ) -> List[Tuple[int, ...]]: UpperCAmelCase...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available SCREAMING_SNAKE_CASE = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDepe...
23
0
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class lowerCamelCase : def A__ ( self , lowerCAmelCase ): raise NotImplementedError() def A__ ( self ): raise NotImplemented...
712
import math def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list[int]: UpperCAmelCase_ = [] UpperCAmelCase_ = 2 UpperCAmelCase_ = int(math.sqrt(__SCREAMING_SNAKE_CASE ) ) # Size of every segment UpperCAmelCase_ = [True] * (end + 1) UpperCAmelCase_ = ...
23
0
from collections.abc import Sequence from queue import Queue class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase=None , lowerCAmelCase=None ): UpperCAmelCase_ = start...
713
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
23
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_toke...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
23
0
import unittest from knapsack import knapsack as k class lowerCamelCase ( unittest.TestCase ): '''simple docstring''' def A__ ( self ): UpperCAmelCase_ = 0 UpperCAmelCase_ = [0] UpperCAmelCase_ = [0] UpperCAmelCase_ ...
715
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "xlm-roberta-base": "https://h...
23
0
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils impor...
716
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ , UpperCAmelCase_ = divmod(__SCREAMING_SNAKE_CASE , 2 ) re...
23
0
from __future__ import annotations import unittest from transformers import DistilBertConfig, 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 fr...
717
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
0
SCREAMING_SNAKE_CASE = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] SCREAMING_SNAKE_CASE = [ ...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwr...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CONTEXT_ENCO...
720
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 0 while number > 0: UpperCAmelCase_ = number % ...
23
0
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
23
0
from __future__ import annotations import typing from collections import Counter def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(_lowerCAmelCase , max_perim...
700
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__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } t...
701
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase ): UpperCAmelCase_ = str(id_ ) UpperCAmelCase_ = None UpperCAmelCase_ = Non...
23
0
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterMixin ...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try...
23
0
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require...
703
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE = 1000 ) -> str: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
704
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> None: UpperCAmelCase_ = analyze_text(_lowerCamelCase ) UpperCAmelCase_ = list(" " + ascii_lowercase ) # what is our...
705
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> np.array: UpperCAmelCase_ = f'''{sampling_rate}''' UpperCAmelCase_ = "1" UpperCAmelCase...
23
0
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArguments
706
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( lowercase__, lowercase__ ): '''simple docstring''' @register_to_...
23
0
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def snake_case__ ( ...
707
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
23
0
from __future__ import annotations import collections import pprint from pathlib import Path def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Optional[int]: return "".join(sorted(lowerCAmelCase__ ) ) def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: return word_by_...
708
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availa...
23
0
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.tes...
709
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 0, 0, 0 UpperCAmelCase_ = ugly_nums[ia] * 2 UpperCAmelCase_ = ugly_nums[ia] * 3 UpperCAmelCase_ = ugly_nums[i...
23
0
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since ...
710
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test...
23
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available SCREAMING_SNAKE_CASE = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDepe...
23
0
from __future__ import annotations import typing from collections import Counter def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> typing.Counter[int]: UpperCAmelCase_ = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(a_ , max_perimeter + 1 ...
712
import math def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list[int]: UpperCAmelCase_ = [] UpperCAmelCase_ = 2 UpperCAmelCase_ = int(math.sqrt(__SCREAMING_SNAKE_CASE ) ) # Size of every segment UpperCAmelCase_ = [True] * (end + 1) UpperCAmelCase_ = ...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Dict: 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 no...
713
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
23
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node SCREAMING_SNAKE_CASE = 4 SCREAMING_SNAKE_CASE = 3 class lowerCamelCase ( lowe...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
23
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase ( lowercase__, unittest.TestCase ): ...
715
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "xlm-roberta-base": "https://h...
23
0
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
716
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ , UpperCAmelCase_ = divmod(__SCREAMING_SNAKE_CASE , 2 ) re...
23
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See all CANINE models at https://hu...
717
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = '▁' SCREAMING_SNAKE_CASE = {'vocab_file': 'spiece.model'} SC...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_ava...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
from __future__ import annotations def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> bool: if len(lowerCamelCase__ ) == 0: return False UpperCAmelCase_ = len(lowerCamelCase__ ) // 2 if a_list[midpoint] == item: return True if item < a_list...
720
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 0 while number > 0: UpperCAmelCase_ = number % ...
23
0
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph clas...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
23
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available SCREAMING_SNAKE_CASE = { "configuration_audio_spectrogram_transformer": [ "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "AST...
700
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__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
0
'''simple docstring''' def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [0] * len(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ = [] UpperCAmelCase_ = [1] * len(__SCREAMING_SNAKE_CASE ) for values in graph.values(): for i in values: indegree[...
701
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase ): UpperCAmelCase_ = str(id_ ) UpperCAmelCase_ = None UpperCAmelCase_ = Non...
23
0
from __future__ import annotations class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase , lowerCAmelCase ): UpperCAmelCase_ , UpperCAmelCase_ = text, pattern UpperCAmelCase_ , UpperCAmelCase_ = ...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try...
23
0
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np SCREAMING_SNAKE_CASE = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 SCREAMING_SNAKE_CASE = typing.Union[np.floataa, int, float] # noqa: UP007 def s...
703
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Tuple: UpperCAmelCase_ = FileLock(str(tmpdir / "foo.lock" ) ) UpperCAmelCase_ = FileLock(str(tmpdir / "foo.lock" ) ) UpperCAmelCase_ ...
704
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: # In...
705
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> np.array: UpperCAmelCase_ = f'''{sampling_rate}''' UpperCAmelCase_ = "1" UpperCAmelCase...
23
0
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ) from transformers.test...
706
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( lowercase__, lowercase__ ): '''simple docstring''' @register_to_...
23
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 ): '''simple docstring''' def A__ ( self ): debug_laun...
707
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
23
0
import argparse from collections import defaultdict def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Optional[int]: UpperCAmelCase_ = f'''{file}_{class_name}_{test_nam...
708
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availa...
23
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common...
709
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 0, 0, 0 UpperCAmelCase_ = ugly_nums[ia] * 2 UpperCAmelCase_ = ugly_nums[ia] * 3 UpperCAmelCase_ = ugly_nums[i...
23
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
710
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test...
23
0
SCREAMING_SNAKE_CASE = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" SCREAMING_SNAKE_CASE ...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available SCREAMING_SNAKE_CASE = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDepe...
23
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } try: if not is_torch_available(): ...
712
import math def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list[int]: UpperCAmelCase_ = [] UpperCAmelCase_ = 2 UpperCAmelCase_ = int(math.sqrt(__SCREAMING_SNAKE_CASE ) ) # Size of every segment UpperCAmelCase_ = [True] * (end + 1) UpperCAmelCase_ = ...
23
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = {"vocab_f...
713
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
23
0
import os import time import numpy as np import onnxruntime as ort SCREAMING_SNAKE_CASE = "1" SCREAMING_SNAKE_CASE = "0" SCREAMING_SNAKE_CASE = "1" SCREAMING_SNAKE_CASE = ort.SessionOptions() SCREAMING_SNAKE_CASE = ort.GraphOptimizationLevel.ORT_D...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
23
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = {"vocab_file": "vocab.json"...
715
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "xlm-roberta-base": "https://h...
23
0
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel from...
716
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ , UpperCAmelCase_ = divmod(__SCREAMING_SNAKE_CASE , 2 ) re...
23
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "alibaba-damo/mgp-str-base": "https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json", } class lowerCame...
717
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
0
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 .embeddings_flax import FlaxTimestepEmbedding, Fl...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
'''simple docstring''' from math import factorial, pi def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 30 ) -> float: if not isinstance(__SCREAMING_SNAKE_CASE , (int, float) ): raise ValueError("maclaurin_sin() requires either an int or float for theta" )...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
from __future__ import annotations import math import random from typing import Any class lowerCamelCase : '''simple docstring''' def __init__( self ): UpperCAmelCase_ = [] UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 def ...
720
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 0 while number > 0: UpperCAmelCase_ = number % ...
23
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
23
0
import math from datetime import datetime, timedelta def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> datetime: UpperCAmelCase_ = year % 19 UpperCAmelCase_ = year % 4 UpperCAmelCase_ = year % 7 UpperCAmelCase_ = math.floor(year / 100 ) UpperCAmelCase_ = ...
700
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__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get...
701
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase ): UpperCAmelCase_ = str(id_ ) UpperCAmelCase_ = None UpperCAmelCase_ = Non...
23
0
import os def snake_case__ ( ) -> str: UpperCAmelCase_ = os.path.dirname(os.path.realpath(__SCREAMING_SNAKE_CASE ) ) UpperCAmelCase_ = os.path.join(__SCREAMING_SNAKE_CASE , "triangle.txt" ) with open(__SCREAMING_SNAKE_CASE ) as f: UpperCAmelCase_ = f.readlin...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try...
23
0
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = "x" , __SCREAMING_SNAKE_CASE = 10**-10 , __SCREAMING_SNAKE_CASE = 1 , ) -> complex: Upp...
703
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.default_p...
704
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = abs(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ = 0 while n > 0: res += n % 10 n //= 10 return res def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = abs(__SCREA...
705
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> np.array: UpperCAmelCase_ = f'''{sampling_rate}''' UpperCAmelCase_ = "1" UpperCAmelCase...
23
0
import os from typing import Dict, List, Tuple, TypeVar, Union SCREAMING_SNAKE_CASE = TypeVar("T") SCREAMING_SNAKE_CASE = Union[List[T], Tuple[T, ...]] SCREAMING_SNAKE_CASE = Union[T, List[T], Dict[str, T]] SCREAMING_SNAKE_CASE = Union[str, bytes, os.PathLike] ...
706
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( lowercase__, lowercase__ ): '''simple docstring''' @register_to_...
23
0
'''simple docstring''' from __future__ import annotations import math def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list[int]: if num <= 0: UpperCAmelCase_ = f'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(__SCREAMING_SNAKE_CASE ) UpperCAm...
707
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
23
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
708
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availa...
23
0
import torch from torch import nn class lowerCamelCase ( nn.Module ): '''simple docstring''' def __init__( self , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase=1 , lowerCAmelCase=False ): ...
709
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 0, 0, 0 UpperCAmelCase_ = ugly_nums[ia] * 2 UpperCAmelCase_ = ugly_nums[ia] * 3 UpperCAmelCase_ = ugly_nums[i...
23
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.ut...
710
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test...
23
0
import datasets from .evaluate import evaluate SCREAMING_SNAKE_CASE = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint arXiv:21...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available SCREAMING_SNAKE_CASE = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDepe...
23
0
import requests SCREAMING_SNAKE_CASE = "YOUR API KEY" def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = giphy_api_key ) -> list: UpperCAmelCase_ = "+".join(query.split() ) UpperCAmelCase_ = f'''https://api.giphy.com/v1/gifs/search?q={format...
712
import math def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list[int]: UpperCAmelCase_ = [] UpperCAmelCase_ = 2 UpperCAmelCase_ = int(math.sqrt(__SCREAMING_SNAKE_CASE ) ) # Size of every segment UpperCAmelCase_ = [True] * (end + 1) UpperCAmelCase_ = ...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> list: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if n_element < 1: UpperCAmelCase_ = ValueError("a should be a positive number" ) raise my_error UpperCAmelCase_ = [1] UpperCAmelCase_ , UpperCAmelCase_ ...
713
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: return int((input_a, input_a).count(0 ) != 0 ) def snake_case__ ( ) -> None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available(): ...
23
0
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from ...
715
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "xlm-roberta-base": "https://h...
23
0
import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> np.ndarray: return 1 / (1 + np.exp(-vector )) def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> np.ndarray: return vector * sigmoid(__SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest...
716
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ , UpperCAmelCase_ = divmod(__SCREAMING_SNAKE_CASE , 2 ) re...
23
0
import gc import threading import time import psutil import torch class lowerCamelCase : '''simple docstring''' def __init__( self ): UpperCAmelCase_ = psutil.Process() UpperCAmelCase_ = False def A__ ( self ): UpperCAmelCa...
717
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.js...
718
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Union[str, Any]: UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAM...
23
0
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCamelCase ( lowercase__ ): '''simple docstring''' @staticmethod @abstractmethod def A__ ( lowerCAmelCase ): raise NotImplementedError() ...
719
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
23
0
from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=lowercase__ ): '''simple docstring''' lowerCAmelCase_ : Optional[int] = ['flax'] def __init__( self , *lowerCAmelCase , **lowerCAmelCase ): requires_b...
720
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> int: UpperCAmelCase_ = 0 while number > 0: UpperCAmelCase_ = number % ...
23
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "shi-labs/nat-mini-in1k-2...
721
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MA...
23
0
SCREAMING_SNAKE_CASE = "Input must be a string of 8 numbers plus letter" SCREAMING_SNAKE_CASE = "TRWAGMYFPDXBNJZSQVHLCKE" def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> bool: if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): UpperCAmelCase_ ...
700
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__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
0
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Optional[Any]: UpperCAmelCase_ = SwinConfig(image_size=192 ) ...
701
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : '''simple docstring''' def __init__( self , lowerCAmelCase ): UpperCAmelCase_ = str(id_ ) UpperCAmelCase_ = None UpperCAmelCase_ = Non...
23
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.set...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> Optional[int]: UpperCAmelCase_ = [1] for i in range(2 , __SCREAMING_SNAKE_CASE ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds" UpperCAmelCase_ = ...
703
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
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 TaTokenizer else: SC...
704
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING...
23
0
def snake_case__ ( __SCREAMING_SNAKE_CASE = 100_0000 ) -> int: UpperCAmelCase_ = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , __SCREAMING_SNAKE_CASE ): phi[j] -= phi[j] // i ret...
705
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> np.array: UpperCAmelCase_ = f'''{sampling_rate}''' UpperCAmelCase_ = "1" UpperCAmelCase...
23
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "kssteven/ibert-roberta-base":...
706
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( lowercase__, lowercase__ ): '''simple docstring''' @register_to_...
23
0