code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCAmelCase__ ( *a__ ) ->List[Any]: '''simple docstring''' if not isinstance(a__ , a__ ): _UpperCamelCase = list(a__ ) for i in range(len(...
368
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 _UpperCAmelCase ( lowerCAmelCase ): '''simple docst...
63
0
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def lowerCAmelCase__ ( a__ ) ->Union[str, Any]: '''simple docstring''' if not is_accelerate_available(): return method _UpperCamelCase =...
369
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available():...
63
0
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( '''The `image_to_image.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionImg2ImgPipeline` instead.''' )
370
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
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.utils....
371
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
0
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 _UpperCAmelCase ( __SCREAMING_SNAKE_CASE ...
350
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase__ = { 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTConfig', 'GroupViTOnnxConfig', 'GroupV...
351
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
63
0
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available if is_vision_av...
352
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} try: if not is_tok...
63
0
import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension ...
353
import unittest import numpy as np from transformers import RoFormerConfig, 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 transf...
63
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _UpperCAmelCase ( lowerCAmelCase ): '''si...
354
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' _UpperCame...
63
0
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and not ...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lowerCamelCase__ = '''src/diff...
356
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaFo...
63
0
import itertools import string from collections.abc import Generator, Iterable def lowerCAmelCase__ ( a__ , a__ ) ->List[Any]: '''simple docstring''' _UpperCamelCase = iter(A_ ) while True: _UpperCamelCase = tuple(itertools.islice(A_ , A_ ) ) ...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0
from __future__ import annotations def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: raise ValueError("Resistance cann...
358
def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" _UpperCamelCase = str(bin(a__ ) ...
63
0
lowerCamelCase__ = {str(digit): digit**5 for digit in range(10)} def lowerCAmelCase__ ( a__ ) ->Tuple: '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(a__ ) ) def lowerCAmelCase__ ( ) ->Dict: '''simple docstring''' return sum(...
359
# 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 lowerCAmelCase__ ( a__ , a__ , a__ , a_...
63
0
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
360
import inspect import unittest from transformers import DecisionTransformerConfig, 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 i...
63
0
import math import unittest from transformers import BioGptConfig, 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 Mo...
361
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 import TFModelTesterMixin, ids_tensor from ...test_p...
63
0
import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
362
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
63
0
def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' _UpperCamelCase = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def lowerCAmelCase__ ( a__ ) ->dict[str, str]: '''simple d...
363
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( Tenso...
63
0
from collections.abc import Sequence def lowerCAmelCase__ ( a__ , a__ = False ) ->float: if not arr: return 0 _UpperCamelCase = 0 if allow_empty_subarrays else float("-inf" ) _UpperCamelCase = 0.0 for num in arr: _UpperCamelCase = max(0 if all...
364
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {''...
63
0
from __future__ import annotations def lowerCAmelCase__ ( a__ ) ->int: '''simple docstring''' _UpperCamelCase = str(lowerCAmelCase__ ) return n == n[::-1] def lowerCAmelCase__ ( a__ = 1_000_000 ) ->int: '''simple docstring''' _UpperCamelCase ...
365
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> Opti...
63
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import Albe...
366
import re def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if len(re.findall("[ATCG]" , a__ ) ) != len(a__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": import doctes...
63
0
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_available()...
367
import os def lowerCAmelCase__ ( ) ->Any: '''simple docstring''' with open(os.path.dirname(a__ ) + "/grid.txt" ) as f: _UpperCamelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) for x in f.readline().split()] ) _UpperCamelCase ...
63
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert impor...
368
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 _UpperCAmelCase ( lowerCAmelCase ): '''simple docst...
63
0
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCamelCase__ = TypeVar('''T''') class _UpperCAmelCase ( Generic[T] ): '''simple docstring''' def __init__( self : Tuple , lowercase_ : T) ->...
369
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available():...
63
0
def lowerCAmelCase__ ( a__ = 2_000_000 ) ->List[Any]: '''simple docstring''' _UpperCamelCase = [0 for i in range(n + 1 )] _UpperCamelCase = 1 _UpperCamelCase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: fo...
370
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
0
from decimal import Decimal, getcontext from math import ceil, factorial def lowerCAmelCase__ ( a__ ) ->Tuple: '''simple docstring''' if not isinstance(__a , __a ): raise TypeError("Undefined for non-integers" ) elif precision < 1: raise ValueError("Undefined for non-nat...
371
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
0
import string def lowerCAmelCase__ ( a__ ) ->List[Any]: '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): _UpperCamelCase = """""" for symbol in message: if symbol in string.ascii_uppercase: _UpperCamelCase = string.ascii_u...
350
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
0
from __future__ import annotations class _UpperCAmelCase : '''simple docstring''' def __init__( self : Union[str, Any] , lowercase_ : str , lowercase_ : str) -> str: """simple docstring""" _UpperCamelCase = text, pattern _UpperCamelCas...
351
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
63
0
from __future__ import annotations from random import choice def lowerCAmelCase__ ( a__ ) ->Optional[int]: '''simple docstring''' return choice(a__ ) def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' _UpperCamelCase = random_pivot(a__...
352
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} try: if not is_tok...
63
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/ma...
353
import unittest import numpy as np from transformers import RoFormerConfig, 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 transf...
63
0
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=UpperCamelCase__ ): '''simple docstring''' __A = ['''torch''', '''scipy'''] def __init__( self : Union[str, Any] , *lowercase_ : Optional[Any] , **lowercase_ : ...
354
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' _UpperCame...
63
0
from math import pow def lowerCAmelCase__ ( a__ , a__ , a__ , a__ , a__ , ) ->str: '''simple docstring''' if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 return current_sum, s...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from tokenizers import pr...
356
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaFo...
63
0
from __future__ import annotations from collections import Counter from random import random class _UpperCAmelCase : '''simple docstring''' def __init__( self : Tuple) -> List[Any]: """simple docstring""" _UpperCamelCase = {} def __UpperCAmelCase ...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0
class _UpperCAmelCase : '''simple docstring''' def __init__( self : Tuple , lowercase_ : Optional[int]) -> Tuple: """simple docstring""" _UpperCamelCase = set_counts _UpperCamelCase = max(A__) _UpperCamelCase = len(A__) _Up...
358
def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" _UpperCamelCase = str(bin(a__ ) ...
63
0
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger lowerCamelCase__ = '''<<<<<<< This should probably be modified because it mentions: ''' lowerCamelCase__ = '''=======\n>...
359
# 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 lowerCAmelCase__ ( a__ , a__ , a__ , a_...
63
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 applicabl...
360
import inspect import unittest from transformers import DecisionTransformerConfig, 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 i...
63
0
class _UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[Any] , lowercase_ : Dict) -> str: """simple docstring""" _UpperCamelCase = arr.split(",") def __UpperCAmelCase ( self ...
361
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 import TFModelTesterMixin, ids_tensor from ...test_p...
63
0
lowerCamelCase__ = [ '''DownloadConfig''', '''DownloadManager''', '''DownloadMode''', '''StreamingDownloadManager''', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
362
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
63
0
import math lowerCamelCase__ = 10 lowerCamelCase__ = 7 lowerCamelCase__ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCAmelCase__ ( a__ = 20 ) ->Optional[int]: '''simple docstring''' _UpperCamelCase = math.comb(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE...
363
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( Tenso...
63
0
from bisect import bisect from itertools import accumulate def lowerCAmelCase__ ( a__ , a__ , a__ , a__ ) ->Any: _UpperCamelCase = sorted(zip(snake_case__ , snake_case__ ) , key=lambda a__ : x[0] / x[1] , reverse=snake_case__ ) _UpperCamelCas...
364
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {''...
63
0
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
365
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> Opti...
63
0
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC lowerCamelCase__ = parse(importlib.metadata.version('''torch''')) def lowerCAmelCase__ ( a__ , a__ , a__ ) ->Any: '''simple docstri...
366
import re def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if len(re.findall("[ATCG]" , a__ ) ) != len(a__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": import doctes...
63
0
def lowerCAmelCase__ ( a__ ) ->int: '''simple docstring''' _UpperCamelCase = 1 for i in range(1 , num + 1 ): fact *= i return fact def lowerCAmelCase__ ( a__ ) ->int: '''simple docstring''' _UpperCamelCase = 0 while number > 0:...
367
import os def lowerCAmelCase__ ( ) ->Any: '''simple docstring''' with open(os.path.dirname(a__ ) + "/grid.txt" ) as f: _UpperCamelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) for x in f.readline().split()] ) _UpperCamelCase ...
63
0
def lowerCAmelCase__ ( a__ ) ->list: '''simple docstring''' if any(not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(lowerCAmelCase_ ) ): for...
368
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 _UpperCAmelCase ( lowerCAmelCase ): '''simple docst...
63
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase__ = { '''configuration_ctrl''': ['''CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CTRLConfig'''], '''tokenization_ctrl''': ['''CTRLTokenizer'''], } ...
369
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available():...
63
0
from __future__ import annotations import math def lowerCAmelCase__ ( a__ ) ->List[Any]: '''simple docstring''' 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...
370
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
0
import math import tensorflow as tf from packaging import version def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' _UpperCamelCase = tf.convert_to_tensor(a__ ) _UpperCamelCase = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype ) ...
371
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, UNeta...
350
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
0
import argparse import os import torch from transformers.utils import WEIGHTS_NAME lowerCamelCase__ = ['''small''', '''medium''', '''large'''] lowerCamelCase__ = '''lm_head.decoder.weight''' lowerCamelCase__ = '''lm_head.weight''' def lowerCAmelCase__ ( a__ , a__ ) -...
351
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
63
0
from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCamelCase__ = {'''tokenization_byt5''': ['''ByT5Tokenizer''']} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys lowerCamelCase__ = _LazyModule(__name__, globals()['''__file__'''], _import...
352
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} try: if not is_tok...
63
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface impor...
353
import unittest import numpy as np from transformers import RoFormerConfig, 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 transf...
63
0
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.utils import l...
354
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' _UpperCame...
63
0
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _UpperCAmelCase ( pl.LightningModule ): '''simple docstring''' def __init__( self : Any , lowercase_ : Any) ...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_staging_test class _UpperC...
356
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaFo...
63
0
def lowerCAmelCase__ ( a__ = 100 ) ->int: '''simple docstring''' _UpperCamelCase = 0 _UpperCamelCase = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main__": print(...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ : Tuple = logging.get_logger(__name__...
358
def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" _UpperCamelCase = str(bin(a__ ) ...
63
0
def lowerCAmelCase__ ( a__ ) ->bool: '''simple docstring''' if num < 0: return False _UpperCamelCase = num _UpperCamelCase = 0 while num > 0: _UpperCamelCase = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_num if __name__ ==...
359
# 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 lowerCAmelCase__ ( a__ , a__ , a__ , a_...
63
0
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version lowerCamelCase__ ...
360
import inspect import unittest from transformers import DecisionTransformerConfig, 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 i...
63
0
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 _UpperCAmelCase ( lowerCAmelCase ...
361
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 import TFModelTesterMixin, ids_tensor from ...test_p...
63
0
import argparse import copy def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' _UpperCamelCase = {} with open(a__ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: _UpperCamelCase = [] _list.append([line.split()[...
362
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
63
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Accelerat...
363
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( Tenso...
63
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase__ = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_available(): ...
364
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {''...
63
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=False): ...
365
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> Opti...
63
0
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 lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = '''▁...
366
import re def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if len(re.findall("[ATCG]" , a__ ) ) != len(a__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": import doctes...
63
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCamelCase__ = version.parse(importlib_metadata.version('''nltk''')) if NLTK_VERSION >= version.Version('''3.6.4'''): from nltk import word_tokenize lowerCamelCase__ ...
367
import os def lowerCAmelCase__ ( ) ->Any: '''simple docstring''' with open(os.path.dirname(a__ ) + "/grid.txt" ) as f: _UpperCamelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) for x in f.readline().split()] ) _UpperCamelCase ...
63
0
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> ...
368
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 _UpperCAmelCase ( lowerCAmelCase ): '''simple docst...
63
0
def lowerCAmelCase__ ( a__ = 200 ) ->int: '''simple docstring''' _UpperCamelCase = [1, 2, 5, 10, 20, 50, 100, 200] _UpperCamelCase = [0] * (pence + 1) _UpperCamelCase = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(a__...
369
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available():...
63
0
import inspect import unittest class _UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCAmelCase ( self : Tuple) -> str: """simple docstring""" try: import diffusers # noqa: F401 except ImportError: assert False ...
370
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import c...
371
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf lowerCamelCase__ = logging.get_logger(__name__) @datac...
350
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
0
lowerCamelCase__ = ''' # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git ''' lowerCamelCase__ = [{'''type''': '''code''', '''content''': INSTALL_CONTENT}] lowerCamelCase__ ...
351
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
63
0
def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if number > 0: raise ValueError("input must be a negative integer" ) _UpperCamelCase = len(bin(a__ )[3:] ) _UpperCamelCase = bin(abs(a__ ) - (1 << binary_number_length) )[3:] _UpperCamelCas...
352
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} try: if not is_tok...
63
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''Salesforce/blip-vqa-base''': '''https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/con...
353
import unittest import numpy as np from transformers import RoFormerConfig, 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 transf...
63
0
from math import pi, sqrt def lowerCAmelCase__ ( a__ ) ->float: '''simple docstring''' if num <= 0: raise ValueError("math domain error" ) if num > 171.5: raise OverflowError("math range error" ) elif num - int(a__ ) not in (0, 0.5): raise NotImplementedError("num mus...
354
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' _UpperCame...
63
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequenceClas...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' def __lt__( self : Dict , lowercase_ : Optional[int]) -> ...
356
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaFo...
63
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...utils im...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowerCAmelCase__ ( a__ = True , *a__ , **a__ ) ->Dict: '''simple docstring''' if not is_tqdm_available(): raise ImportError("Accelerate...
358
def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" _UpperCamelCase = str(bin(a__ ) ...
63
0
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' __A = (DDPMScheduler,) def __UpperCAmelCase ( self : Tuple , **lowercase_ : D...
359
# 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 lowerCAmelCase__ ( a__ , a__ , a__ , a_...
63
0
# 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 appl...
360
import inspect import unittest from transformers import DecisionTransformerConfig, 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 i...
63
0
import inspect import unittest from transformers import ViTMSNConfig 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_configuration_common import ConfigTester from ...te...
361
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 import TFModelTesterMixin, ids_tensor from ...test_p...
63
0
from math import sqrt def lowerCAmelCase__ ( a__ ) ->int: '''simple docstring''' _UpperCamelCase = 0 for i in range(1 , int(sqrt(a__ ) + 1 ) ): if n % i == 0 and i != sqrt(a__ ): total += i + n // i elif i == sqrt(a__ ): total += i retur...
362
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
63
0
import math def lowerCAmelCase__ ( a__ = 100 ) ->int: '''simple docstring''' _UpperCamelCase = sum(i * i for i in range(1 , n + 1 ) ) _UpperCamelCase = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squa...
363
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( Tenso...
63
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' __A = (EulerDiscreteScheduler,) __A = 10 def __UpperC...
364
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {''...
63
0
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 lowerCamelCase__ = { # 1536-bit 5: { '''prime''': int( '''FFFFFFFF...
365
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> Opti...
63
0
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring'...
366
import re def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if len(re.findall("[ATCG]" , a__ ) ) != len(a__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": import doctes...
63
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch i...
367
import os def lowerCAmelCase__ ( ) ->Any: '''simple docstring''' with open(os.path.dirname(a__ ) + "/grid.txt" ) as f: _UpperCamelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) for x in f.readline().split()] ) _UpperCamelCase ...
63
0
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
368
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 _UpperCAmelCase ( lowerCAmelCase ): '''simple docst...
63
0
import logging import os import threading import time try: import warnings except ImportError: lowerCamelCase__ = None try: import msvcrt except ImportError: lowerCamelCase__ = None try: import fcntl except ImportError: lowerCamelCase__ = None # Backward compatibil...
369
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available():...
63
0
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizer...
370
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
0
from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCamelCase__ = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lowerCamelCase__ = _Laz...
371
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''vocab_file''': '''vocab.json''', '''merges_file...
63
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _UpperCAmelCase : '''simple docstring''' def __init__( self : int , lowercase_ : Collection[float] | None = None) -> None: """simple doc...
350
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
0
import argparse import os import re lowerCamelCase__ = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowerCamelCase__ = re.compile(R'''[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDi...
351
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
63
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase__ = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_canine''': ['''CanineTokeni...
352
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase__ = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfig''']} try: if not is_tok...
63
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNet...
353
import unittest import numpy as np from transformers import RoFormerConfig, 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 transf...
63
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' @require_torch def __UpperCAmelCase ( sel...
354
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( a__ , a__ , a__ ) ->int: '''simple docstring''' _UpperCame...
63
0
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
import argparse import os import re lowerCamelCase__ = '''src/transformers''' # Pattern that looks at the indentation in a line. lowerCamelCase__ = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. lowerCamelCase__ = re.compile(R'''^\s*"([^"]+)":''') # Pat...
356
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaFo...
63
0
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_NAME,...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0