code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
from __future__ import annotations def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase, ): if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("""You cannot supply more or less than 2 values""" ) elif electron_conc < 0: raise ValueError("""Electron con...
287
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : Any = 4 lowerCamelCase : List[str] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[Any] = ((s...
287
1
# Copyright 2022 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 applicab...
287
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase ={ """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimeSeriesTransformerConfig""", ], } ...
287
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """nvidia/...
287
1
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTeste...
287
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name_...
287
1
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
1
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDetection from t...
287
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 Regres...
287
1
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ="""▁""" _lowerCamelCase ={"""vocab_fil...
287
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
1
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from a...
287
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 =logging.get_logger(__name__) _lowerCame...
287
1
import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class A__ ( __SCRE...
287
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
1
# 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 applicab...
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
# Copyright 2022 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 applicab...
287
# Copyright 2021 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 app...
287
1
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCase ...
287
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase ={ """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", """Pix2StructText...
287
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailab...
287
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : str = field(default=...
287
1
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-base/blob/main/con...
287
1
import math def _a ( lowerCamelCase = 100 ): lowerCamelCase : Union[str, Any] = sum(i * i for i in range(1, n + 1 ) ) lowerCamelCase : Union[str, Any] = int(math.pow(sum(range(1, n + 1 ) ), 2 ) ) return square_of_sum - sum_of_square...
287
def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = set(range(3, lowerCamelCase, 2 ) ) primes.add(2 ) for p in range(3, lowerCamelCase, 2 ): if p not in primes: continue primes.difference_update(set(range(p * p, lowerCamelCase, lowerCamelCase ...
287
1
import math def _a ( lowerCamelCase ): lowerCamelCase : Any = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowerCamelCase ) def _a ( lowerCamelCase = 1 / 1_2345 ): lowerCamelCase : List[Any] ...
287
from __future__ import annotations import collections import pprint from pathlib import Path def _a ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def _a ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] _lowerC...
287
1
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from...
287
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, ) from ...
287
1
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging _lowerCamelCase ={ """cola""": 2, ...
287
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configuration_...
287
1
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__) @dat...
287
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertMode...
287
1
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class A__ : _UpperCAmelCase : int _UpperCAmelCase : Node | None = None _UpperCAmelCase : ...
287
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logger ...
287
1
import qiskit def _a ( lowerCamelCase = 2 ): lowerCamelCase : List[Any] = qubits # Using Aer's simulator lowerCamelCase : int = qiskit.Aer.get_backend("""aer_simulator""" ) # Creating a Quantum Circuit acting on the q register lowerCamelCase : str = ...
287
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase =5_0_0_0_0_0 _lowerCamelCase , _lowerCamelCase =os.path.split(__file__) _lowerCamelCase =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_...
287
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_...
287
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : Any = 4 lowerCamelCase : List[str] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[Any] = ((s...
287
1
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def _a ( lowerCamelCase ): lowerCamelCase : Any = args.pruning_method lowerCamelCase : Dict = args.threshold lowerCamelCase : Uni...
287
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
1
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_to...
287
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """nvidia/...
287
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : str = field(default=...
287
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name_...
287
1
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging _lowerCam...
287
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
1
from timeit import timeit _lowerCamelCase ={ """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a plan a canal panama" } # Ensure our test data is valid a...
287
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 Regres...
287
1
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _lowerCamelCase =numpy.array([0, 0]) _lowerCamelCase =numpy.array([0.5, 0.8660254]) _lowerCamelCase =numpy.array([1, 0]) _lowerCamelCase =[VECTOR_1, VECTOR_...
287
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
1
class A__ : def __init__( self , __magic_name__ , __magic_name__ , __magic_name__ ): lowerCamelCase : Dict = name lowerCamelCase : Optional[int] = value lowerCamelCase : str = weight def __repr__( self ): ...
287
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 =logging.get_logger(__name__) _lowerCame...
287
1
from __future__ import annotations import os from typing import Any import requests _lowerCamelCase ="""https://api.github.com""" # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user _lowerCamelCase =BASE_URL + """/user""" # https://github.com/settings/to...
287
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
1
def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): def update_area_of_max_square(lowerCamelCase, lowerCamelCase ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 lowerCamelCase : List[Any] = update_area_of_max_square(lowerCamelCase, col + 1 ) ...
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import logging log...
287
# Copyright 2021 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 app...
287
1
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_timm,...
287
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
1
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
1
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils ...
287
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : str = field(default=...
287
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
287
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-base/blob/main/con...
287
1
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, ) from ...
287
def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = set(range(3, lowerCamelCase, 2 ) ) primes.add(2 ) for p in range(3, lowerCamelCase, 2 ): if p not in primes: continue primes.difference_update(set(range(p * p, lowerCamelCase, lowerCamelCase ...
287
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase ={ """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SqueezeBertConfig""", """Squeeze...
287
from __future__ import annotations import collections import pprint from pathlib import Path def _a ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def _a ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] _lowerC...
287
1
def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): def count_of_possible_combinations(lowerCamelCase ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_poss...
287
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, ) from ...
287
1
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokenizer...
287
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configuration_...
287
1
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A__ ( __SCREAMING_SNA...
287
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertMode...
287
1
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _a ( lowerCamelCase ): lowerCamelCase : Union[str, Any] = {} lowerCamelCase : List[str] = ...
287
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logger ...
287
1
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase =5_0_0_0_0_0 _lowerCamelCase , _lowerCamelCase =os.path.split(__file__) _lowerCamelCase =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_...
287
1
_lowerCamelCase =[sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _a ( lowerCamelCase ): lowerCamelCase : List[Any] = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared += DIGITS_SQUARED[numb...
287
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : Any = 4 lowerCamelCase : List[str] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[Any] = ((s...
287
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import ...
287
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
1
_lowerCamelCase =""" # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.git """ _...
287
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """nvidia/...
287
1
import re import string import numpy as np import datasets _lowerCamelCase =""" Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ _lowerCamelCase =""" Args: predictions: List of predicted te...
287
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name_...
287
1
from collections import deque def _a ( lowerCamelCase ): lowerCamelCase : Dict = len(lowerCamelCase ) lowerCamelCase : Optional[Any] = deque() lowerCamelCase : Optional[Any] = [False for _ in range(lowerCamelCase )] lowerCamelCase : Optional[...
287
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
1
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={"""vocab_file""": """vocab.txt"""} _lowerCamelCase ...
287
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 Regres...
287
1
from __future__ import annotations class A__ : def __init__( self , __magic_name__ ): lowerCamelCase : Any = TypeError( """Matrices must be formed from a list of zero or more lists containing at """ """least one and the same number of values, ea...
287
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
1
from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.robert...
287
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 =logging.get_logger(__name__) _lowerCame...
287
1
def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = set(range(3, lowerCamelCase, 2 ) ) primes.add(2 ) for p in range(3, lowerCamelCase, 2 ): if p not in primes: continue primes.difference_update(set(range(p * p, lowerCamelCase, lowerCamelCase ...
287
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""", # See all BioGPT models at https://huggingface.co/mo...
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
from __future__ import annotations def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # noqa: E741 while r - l > 1: lowerCamelCase : Any = (l + r) // 2 if v[m] >= key: lowerCamelCase : List[str] = m else: lowerCamelCase : Dict ...
287
# Copyright 2021 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 app...
287
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """bert-base-uncased""": """https://huggingface.co/bert-b...
287
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class A__ ( unittest.TestCase): def UpperCamelCase__ ( self ): lowerCamelCase : int = [ """safety_checker/pytorch_model.bin""", """safety_checker/m...
287
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
1
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase=None ): # set para...
287
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : str = field(default=...
287
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, BlipImageProce...
287
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-base/blob/main/con...
287
1
import math from numpy import inf from scipy.integrate import quad def _a ( lowerCamelCase ): if num <= 0: raise ValueError("""math domain error""" ) return quad(lowerCamelCase, 0, lowerCamelCase, args=(lowerCamelCase) )[0] def _a ( lowerCamelCase, lowerCamel...
287
def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = set(range(3, lowerCamelCase, 2 ) ) primes.add(2 ) for p in range(3, lowerCamelCase, 2 ): if p not in primes: continue primes.difference_update(set(range(p * p, lowerCamelCase, lowerCamelCase ...
287
1
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
from __future__ import annotations import collections import pprint from pathlib import Path def _a ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def _a ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] _lowerC...
287
1
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM, ...
287
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, ) from ...
287
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): lowerCamelCase : Union[str, Any] = OmegaConf.load(lowerCamelCase ) lowerCamelCase : Optional[in...
287
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configuration_...
287
1
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
287
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertMode...
287
1
def _a ( lowerCamelCase ): if not isinstance(lowerCamelCase, lowerCamelCase ): raise TypeError("""Input value must be an 'int' type""" ) lowerCamelCase : int = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": import doc...
287
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logger ...
287
1
from __future__ import annotations class A__ : def __init__( self , __magic_name__ = 0 ): lowerCamelCase : List[str] = key def UpperCamelCase__ ( self , __magic_name__ , __magic_name__ ): assert isinstance(__magic_name__ ...
287
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase =5_0_0_0_0_0 _lowerCamelCase , _lowerCamelCase =os.path.split(__file__) _lowerCamelCase =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_...
287
1
import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class A__ : def __init__( self , __magic_name__ ): if isinstance(__magic_name__ , __magic_name__ ): ...
287
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : Any = 4 lowerCamelCase : List[str] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[Any] = ((s...
287
1
from __future__ import annotations from scipy.special import comb # type: ignore class A__ : def __init__( self , __magic_name__ ): lowerCamelCase : str = list_of_points # Degree determines the flexibility of the curve. # Degree = 1 will produce a str...
287
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : Optional[int] = (DDIMParallelScheduler,) _UpperCAmelCase : Any = (("""eta""", 0.0), ("""num_inf...
287
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """nvidia/...
287
1
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tokenization_utils ...
287
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name_...
287
1
import pytest _lowerCamelCase ="""__dummy_dataset1__""" _lowerCamelCase =""" import json import os import datasets REPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\" URLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", \"validation\": REPO_URL + \"wiki...
287
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase ={ """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: if not is_torch_available(): ...
287
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 Regres...
287
1
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
1
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class A__ ( __SCREAMING_SNAKE_CASE , unittest.Te...
287
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 =logging.get_logger(__name__) _lowerCame...
287
1
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) def _a ( lowerCamelCase, lowerCamelCase ): lowerCamelCase : Optional[Any] = nn.functional.no...
287
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
1
import unittest from transformers import 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 ModelTesterMixin, ids_tensor from ....
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
from math import isclose, sqrt def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): lowerCamelCase : List[str] = point_y / 4 / point_x lowerCamelCase : List[Any] = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) lowerCamelCase : Union[str, Any] ...
287
# Copyright 2021 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 app...
287
1
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...
287
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
1
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def _a ( lowerCamelCase = "" ): lowerCamelCase : Any = url or """https://www.imdb.com/chart/top/?ref_=nv_mv_250""" lowerCamelCase : str = BeautifulSoup(requests.get(lowerCamel...
287
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
1
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax...
287
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : str = field(default=...
287
1
from __future__ import annotations import math _lowerCamelCase ="""2020.9.26""" _lowerCamelCase ="""xcodz-dot, cclaus, dhruvmanila""" def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): if not all(isinstance(lowerCamelCase, (float, int) ...
287
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-base/blob/main/con...
287
1
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def _a ( lowerCamelCase, lowerCamelCase=(), lowerCamelCase=None, lowerCamelCase="no", lowerCamelCase="29500" ): lowerC...
287
def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = set(range(3, lowerCamelCase, 2 ) ) primes.add(2 ) for p in range(3, lowerCamelCase, 2 ): if p not in primes: continue primes.difference_update(set(range(p * p, lowerCamelCase, lowerCamelCase ...
287
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegmentation, ...
287
from __future__ import annotations import collections import pprint from pathlib import Path def _a ( lowerCamelCase ): return "".join(sorted(lowerCamelCase ) ) def _a ( lowerCamelCase ): return word_by_signature[signature(lowerCamelCase )] _lowerC...
287
1
import random class A__ : @staticmethod def UpperCamelCase__ ( __magic_name__ ): lowerCamelCase : Any = [ord(__magic_name__ ) for i in text] lowerCamelCase : List[Any] = [] lowerCamelCase : str = [] for ...
287
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, ) from ...
287
1
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _a ( lowerCamelCase ): ...
287
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configuration_...
287
1
_lowerCamelCase =[0, 2, 4, 6, 8] _lowerCamelCase =[1, 3, 5, 7, 9] def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return 0 for i in range(length // 2 - 1, -1, -1 ): remaind...
287
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertMode...
287
1
import os import sys import unittest _lowerCamelCase =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read...
287
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logger ...
287
1
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json""" ), } ...
287
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase =5_0_0_0_0_0 _lowerCamelCase , _lowerCamelCase =os.path.split(__file__) _lowerCamelCase =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_...
287
1
import math def _a ( lowerCamelCase, lowerCamelCase ): if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of initial intensity if angle < 0 or angle > 360: raise ValueError("""In Malus Law, the angle is in th...
287
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : Any = 4 lowerCamelCase : List[str] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[Any] = ((s...
287
1
from string import ascii_uppercase _lowerCamelCase ={char: i for i, char in enumerate(ascii_uppercase)} _lowerCamelCase =dict(enumerate(ascii_uppercase)) def _a ( lowerCamelCase, lowerCamelCase ): lowerCamelCase : Optional[Any] = len(lowerCamelCase ) lowerCame...
287
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE): def __init__( self , *__magic_name__ , **__magic_name__ ): warnings.warn( ...
287
1
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCamelCase =5_0_0_0_0_0 _lowerCamelCase , _lowerCamelCase =os.path.split(__file__) _lowerCamelCase =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_...
287
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """nvidia/...
287
1
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _lowerCamelCa...
287
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name_...
287
1
from math import factorial _lowerCamelCase ={str(d): factorial(d) for d in range(1_0)} def _a ( lowerCamelCase ): return sum(DIGIT_FACTORIAL[d] for d in str(lowerCamelCase ) ) def _a ( ): lowerCamelCase : List[Any] = 7 * factorial(9 ) + ...
287
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATURE_E...
287
1
from __future__ import annotations def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0""" ) if resistance < 0: raise ValueError("""Resistance cannot be negative""" ...
287
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 Regres...
287
1
import unittest from transformers import LiltConfig, 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 ModelTesterMixin, ids_t...
287
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase ={} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvail...
287
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 =logging.get_logger(__name__) _lowerCame...
287
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """roberta-base""": """https://huggingface.co/roberta-bas...
287
import json import sys def _a ( lowerCamelCase, lowerCamelCase ): with open(lowerCamelCase, encoding="""utf-8""" ) as f: lowerCamelCase : List[Any] = json.load(lowerCamelCase ) lowerCamelCase : Optional[Any] = ["""<details>""", """<summary>Show updated b...
287
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase ={ """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AutoformerConfig""", ], } ...
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
287
# Copyright 2021 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 app...
287
1
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class lowercase_ : '''simple docstring''' __snake_case = 42 __snake_case = None __snake_case = Non...
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
0