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
'''simple docstring''' from math import sqrt def lowerCAmelCase_ ( snake_case_ : int ) -> int: '''simple docstring''' UpperCAmelCase_ = 0 for i in range(1 , int(sqrt(snake_case_ ) + 1 ) ): if n % i == 0 and i != sqrt(snake_case_ ...
1
_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
0
'''simple docstring''' import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available lowerCamelCase : str = logging.getLogger...
2
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
0
'''simple docstring''' from typing import Any def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ , ): '''simple docstring''' _validation( snake_case__ , snake_case__ , snake_case__ ...
3
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
0
'''simple docstring''' import numpy as np def a_ ( lowerCamelCase : np.ndarray , lowerCamelCase : float ): return np.where(vector > 0 , lowerCamelCase , (alpha * (np.exp(lowerCamelCase ) - 1)) ) if __name__ == "__main__": import doctest doctest....
4
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
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPo...
5
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
0
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def __lowerCAmelCase ( a__ ) -> Tuple: __a ...
6
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
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
7
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
0
import math from collections.abc import Callable def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): snake_case_ = xa snake_case_ = xa while True: if x_n == x_na or function(SCREAMING_SNAKE_CASE__ )...
8
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
0
from __future__ import annotations import os from collections.abc import Mapping __lowerCAmelCase : Optional[int] =tuple[int, int] class _lowercase : '''simple docstring''' def __init__( self :Optional[Any] , lowerCAmelCase__ :set[int] , lowerCAmelCase__ :Mappi...
9
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
0
from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=__SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = ["torch", "transformers", "onnx"] def __init__(self : Union[str, Any] , *UpperCAmelCase_ : Optional[Any] , **Up...
10
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
0
def _UpperCAmelCase (UpperCamelCase__ : int ): if num < 0: return False _A : int = num _A : int = 0 while num > 0: _A : Optional[Any] = rev_num * 10 + (num % 10) num //= 10...
11
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
0
def lowerCamelCase__ ( A__ : int = 10 , A__ : int = 22 ): '''simple docstring''' __lowerCamelCase = range(1 , A__ ) __lowerCamelCase = range(1 , A__ ) return sum( 1 for power in powers for base in bases if len...
12
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
0
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCAmelCase : Optional[int] = 10 def A_ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ...
13
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
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor _lowerCamelCase : List[Any] = logging.get_logger(__name__) class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' def __init__( self : Opt...
14
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
0
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = "EncodecFeatureExtractor" snake_case_ = ("T5To...
15
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ =...
16
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
0
"""simple docstring""" def _A ( UpperCamelCase_ : Optional[int]) -> int: '''simple docstring''' return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7...
17
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
0
import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ran...
18
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
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer __A =logging.get_logger(__name__) __A ={'''vocab_file''': '''vocab.txt'...
19
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
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Dict = { """vocab_file""": """vocab.json""", """...
20
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
0
import argparse from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> Any: _lowercase : int = F'''{file}_{class_name}_{test_name}''' done_test[_id] +...
21
# 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
0
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MO...
22
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
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils imp...
23
_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
0
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Liter...
24
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
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig UpperCAmelCase__ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase__ : Optional[Any] = { 'Intel/dpt...
25
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
0
def lowerCAmelCase_ ( snake_case_ ): if not isinstance(snake_case_,snake_case_ ): raise TypeError("""only integers accepted as input""" ) else: _A : int = str(abs(snake_case_ ) ) _A : Dict = [list(snake_c...
26
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
0
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def __UpperCAmelCase ( ...
27
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
0
'''simple docstring''' _lowerCamelCase : str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def __lowerCamelCase ( A__ ) -> bytes: """simple docstring""" # Make sure the supplied data is a bytes-like object if not is...
28
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json', 'uclanlp/visu...
29
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
0
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def a ( snake_case__: ...
30
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
0
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_...
31
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
0
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transfo...
32
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
0
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowercase ( __snake_case : List[Any] , __snake_case : Tuple=1 ): if n_shave_prefix_segments >= 0: return ".".join(p...
33
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
0
'''simple docstring''' def snake_case_ (_a : int , _a : int ): return "\n".join( F"{number} * {i} = {number * i}" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10)) ...
34
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __a = {"configuration_plbart": ["PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "PLBart...
35
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _snake_case = { "configuration_longt5": ["LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "LongT5Config", "LongT5OnnxConfig"], } try: if not is_torch_available(): ...
36
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
0
'''simple docstring''' import json import os from typing import 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...
37
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
0
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate UpperCAmelCase_ : List[Any] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('''''', '''|'...
38
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
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = '''▁''' _a = ...
39
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
0
"""simple docstring""" import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import requ...
40
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
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging...
41
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
0
'''simple docstring''' import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, ...
42
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
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowercase = { '''configuration_perceiver''': ['''PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PerceiverConfig...
43
# 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
0
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ,_l...
44
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
"""simple docstring""" import math import unittest def lowercase ( lowerCAmelCase__ : int ) -> bool: assert isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 an...
45
_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
0
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ = TypeVar("T") class lowercase ( Generic[T] ): def __init__( self , lowercase ) -> None: lowerCAmelCase = data ...
46
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
0
'''simple docstring''' from typing import List import numpy as np def _lowerCAmelCase ( _UpperCamelCase : dict ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE ={key: len(_UpperCamelCase ) for key, value in gen_kwargs.items() if isinstance(_UpperC...
47
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
0
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: impor...
48
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case :List[str] = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xlm'...
49
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
0
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class lowerCAmelCase ( __UpperCamelCase ): UpperCAmelCase__ = Dist...
50
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
0
from pathlib import Path import fire def A (__A : str , __A : str , __A : int ) -> Tuple: """simple docstring""" UpperCAmelCase_ = Path(__A ) UpperCAmelCase_ = Path(__A ) d...
51
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
0
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_atten...
52
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
0
'''simple docstring''' def lowercase__ ( __lowercase : int ) -> int: """simple docstring""" if n == 1 or not isinstance(__lowercase , __lowercase ): return 0 elif n == 2: return 1 else: __UpperCamelCase ...
53
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
0
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
54
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
0
'''simple docstring''' import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch a_ : List[str] = """ss...
55
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
0
'''simple docstring''' # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_tab...
56
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
0
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from...
57
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
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
58
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
0
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __lowerCamelCase = logging.get_logger("""transformers.models.speecht5""") def UpperCamelCase ( __lowerCamelCase : Union[str,...
59
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
0
"""simple docstring""" from manim import * class snake_case_( a__ ): def lowerCamelCase__ ( self : Tuple ): lowerCAmelCase : List[str] = Rectangle(height=0.5 , width=0.5 ) lowerCAmelCase : Union[str, Any] = Rectangle(height=0.4...
60
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
0
"""simple docstring""" 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 TokenizerTeste...
61
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
0
import string def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str ): for key in range(len(string.ascii_uppercase ) ): __UpperCamelCase ='' for symbol in message: if symbol in string.ascii_uppercase: __UpperCamelCase ...
62
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
0
'''simple docstring''' import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passe...
63
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
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json''', '''microsoft/ma...
64
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
0
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP UpperCamelCase__ = False try: UpperCamelCase__ ...
65
# 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
0
"""simple docstring""" __a = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __a = [{"type": ...
66
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
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDi...
67
_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
0
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMix...
68
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
0
"""simple docstring""" import math import sys def UpperCAmelCase ( UpperCAmelCase ) -> int: if number != int(UpperCAmelCase ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the value of input must not...
69
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
0
'''simple docstring''' # 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.apach...
70
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
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered...
71
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
0
"""simple docstring""" import numpy as np from transformers import Pipeline def snake_case_ ( A_ : List[str] ): '''simple docstring''' _lowerCamelCase : Any = np.max(A_, axis=-1, keepdims=A_ ) _lowerCamelCase : List[str...
72
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
0
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) a =pytest.mark.integration @pytest.mark.parametrize('path' , ['paws', 'csv'] ) d...
73
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
0
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = {'''vocab_file''': '''vocab.json'''} _lowercase = { ''...
74
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
0
'''simple docstring''' from collections.abc import Callable class __UpperCamelCase : def __init__( self, lowerCAmelCase = None ): """simple docstring""" lowerCamelCase_ =[] # Stores indexes of each item for supporting upda...
75
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
0
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCamelCase ( self : Optional[int] ) ...
76
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
0
"""simple docstring""" import torch def a_ ( ): '''simple docstring''' if torch.cuda.is_available(): lowercase__ : Tuple = torch.cuda.device_count() else: lowercase__ : Optional[int] = 0 print(f"""Successfully ran on ...
77
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
0
"""simple docstring""" import os from datetime import datetime as dt from github import Github snake_case_ = [ """good first issue""", """feature request""", """wip""", ] def _lowerCAmelCase ( ): UpperCAmelCase = Github(os.environ['GITHUB...
78
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCamelCase_ = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwiftF...
79
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
0
'''simple docstring''' from string import ascii_uppercase a__ : List[str] = {char: i for i, char in enumerate(ascii_uppercase)} a__ : str = dict(enumerate(ascii_uppercase)) def _UpperCamelCase ( __A , __A ) -> str: '''simple docstr...
80
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase_ : List[str] = { """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_...
81
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
0
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( """split_dict""" , [ SplitDict(), SplitDict({"""train""": SplitInfo(name="""train""" , num_bytes=13_37 , num_examples=42 , dataset_name="""my...
82
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) snake_case_ : Any = { 'configuration_trocr': ['TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
83
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
0
"""simple docstring""" from statistics import mean import numpy as np def _snake_case ( lowercase__ : list , lowercase__ : list , lowercase__ : list , lowercase__ : int ) -> list: '''simple docstring''' lowerCAmelCa...
84
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
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() _SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) def UpperCamelCase_( sn...
85
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase__ = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], ...
86
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
0
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common i...
87
# 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
0
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester ...
88
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
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils imp...
89
_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
0
from itertools import permutations def lowerCamelCase_ ( UpperCamelCase__ : tuple ) -> bool: """simple docstring""" if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if n...
90
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ : Dict = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_vis...
91
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = {"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""} class a__ ( snake_case__ ): _a : ...
92
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
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : str = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT...
93
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
0
import numpy as np snake_case : List[str] = [ ['''a''', '''b''', '''c''', '''d''', '''e'''], ['''f''', '''g''', '''h''', '''i''', '''k'''], ['''l''', '''m''', '''n''', '''o''', '''p'''], ['''q''', '''r''', '''s''', '''t''', '''u'''], ['''v''', '''w''', '''x''', '''y''', '''z'...
94
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
0
def _A ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" a__ : int =(num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formu...
95
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
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel fr...
96
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
0
'''simple docstring''' import numpy as np import datasets __snake_case = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was...
97
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
0
"""simple docstring""" def a_ ( lowerCamelCase = 1_0**1_2 ): UpperCAmelCase__ = 1 UpperCAmelCase__ = 0 UpperCAmelCase__ = 1 UpperCAmelCase__ = 1 while numerator <= 2 * min_total - 1: prev_numerat...
98
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
0
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common...
99
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
0
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is...
100
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
0