code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
class lowercase_ : def __init__( self , lowercase_ , lowercase_=None , lowercase_=None) -> Tuple: a__ =data a__ =previous a__ =next_node def __str__( self) -> str: return F"""{self.data}""" de...
20
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
def lowerCAmelCase_ ( lowerCamelCase = 1000 ): __magic_name__ : Optional[int] =-1 __magic_name__ : Tuple =0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c __magic_name__ ...
21
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCamelCase ( ): lowerCAmelCase_ : Dict = HfArgumentParser(snake_case__) lowerCAmelCase_ : Dict = parser.parse_args_into_dataclasses()[0] lowerCAmelCase_ : Lis...
659
0
'''simple docstring''' import copy import re class A : lowercase_ = 'hp' lowercase_ = {} lowercase_ = None @classmethod def __lowerCAmelCase ( cls : List[Any] , low...
22
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' ''' ...
659
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smar...
23
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
659
0
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup UpperCAmelCase_ : Any = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deformab...
24
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } class __...
659
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_big_bird import ...
25
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transform...
26
import argparse import json from tqdm import tqdm def UpperCamelCase ( ): lowerCAmelCase_ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=snake_case__ , default="biencoder-nq-dev.json" , help="Path...
659
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met clas...
27
from collections.abc import Sequence def UpperCamelCase ( snake_case__ = None): if nums is None or not nums: raise ValueError("Input sequence should not be empty") lowerCAmelCase_ : Dict = nums[0] for i in range(1 , len(snake_case__)): lowerCAme...
659
0
'''simple docstring''' UpperCamelCase_ = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .f...
28
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
0
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import requi...
29
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase = '''src/diffuse...
659
0
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_uti...
30
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json''' ...
659
0
import math import qiskit def UpperCAmelCase_ ( __UpperCAmelCase : int = 1 , __UpperCAmelCase : int = 1 , __UpperCAmelCase : int = 1 ) -> qiskit.result.counts.Counts: if ( isinstance(__UpperCAmelCase , __UpperCAmelCase ) or isi...
31
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Paddi...
659
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "microsoft/focalnet-tiny": "https://hug...
32
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. _lowercase = 10 def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__): ...
659
0
from math import isqrt def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(__lowerCAmelCase ) + 1 ) ) def SCREAMING_SNAKE_CASE ( __lowerCAmelCase = 10**6 ) -> int: snake_ca...
33
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer _lowercase = logging.get_logger(__name__) _lowercase = { ...
659
0
"""simple docstring""" 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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( ...
34
from collections.abc import Generator from math import sin def UpperCamelCase ( snake_case__): if len(snake_case__) != 32: raise ValueError("Input must be of length 32") lowerCAmelCase_ : Tuple = b"" for i in [3, 2, 1, 0]: little_endian += string_aa[8...
659
0
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 GenerationTes...
35
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
659
0
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __lowercase : Dict = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str, required=True,...
36
from __future__ import annotations from collections.abc import Callable def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = 1_00 , ): lowerCAmelCase_ : Any = x_start lowerCAmelCase_ : Optional[Any] = fnc(snake_case_...
659
0
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.te...
37
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, t...
659
0
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging...
38
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) _lowercase = { '''iou_prediction_head.lay...
659
0
# 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 requ...
39
class __snake_case : """simple docstring""" def __init__( self : Union[str, Any] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {...
659
0
from typing import TYPE_CHECKING from ....utils import _LazyModule __UpperCAmelCase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys __UpperCAmelCase = _LazyModule(__name__, globals()['''__file__'''...
40
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModel...
659
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''google/bit-...
41
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 _lowerc...
659
0
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
42
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_...
43
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCamelCase ( ): lowerCAmelCase_ : Dict = HfArgumentParser(snake_case__) lowerCAmelCase_ : Dict = parser.parse_args_into_dataclasses()[0] lowerCAmelCase_ : Lis...
659
0
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def A_ ( _lowerCAmelCase : List[str] ): """simple docstring""" _lowerCamelCase : List[Any] = [ "encoder...
44
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' ''' ...
659
0
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def A ( lowercase__ : ...
45
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
659
0
"""simple docstring""" import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common imp...
46
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } class __...
659
0
from collections.abc import Sequence from queue import Queue class _UpperCamelCase: def __init__( self : Tuple , SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMIN...
47
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests fr...
48
import argparse import json from tqdm import tqdm def UpperCamelCase ( ): lowerCAmelCase_ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=snake_case__ , default="biencoder-nq-dev.json" , help="Path...
659
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : Dict = logging.get_logger(__name__) _lowercase : List[Any] ...
49
from collections.abc import Sequence def UpperCamelCase ( snake_case__ = None): if nums is None or not nums: raise ValueError("Input sequence should not be empty") lowerCAmelCase_ : Dict = nums[0] for i in range(1 , len(snake_case__)): lowerCAme...
659
0
'''simple docstring''' def A__ ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : int ): if index == number_of_items: return 0 lowerCamelCase__ ...
50
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
0
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common im...
51
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase = '''src/diffuse...
659
0
"""simple docstring""" import os def __A ( ) -> Tuple: with open(os.path.dirname(a_) + '''/grid.txt''') as f: __a : Dict = [] # noqa: E741 for _ in range(20): l.append([int(a_) for x in f.readline().split()]) __a ...
52
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json''' ...
659
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _UpperCAmelCase ...
53
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Paddi...
659
0
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql impo...
54
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. _lowercase = 10 def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__): ...
659
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake...
55
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer _lowercase = logging.get_logger(__name__) _lowercase = { ...
659
0
'''simple docstring''' def _a (lowercase__ : str , lowercase__ : str ) -> Dict: """simple docstring""" assert x is not None assert y is not None __snake_case = len(lowercase__ ) __snake_case = len(lowercase__ ) ...
56
from collections.abc import Generator from math import sin def UpperCamelCase ( snake_case__): if len(snake_case__) != 32: raise ValueError("Input must be of length 32") lowerCAmelCase_ : Tuple = b"" for i in [3, 2, 1, 0]: little_endian += string_aa[8...
659
0
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, sl...
57
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
659
0
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : int ): '''simple docstring''' if not isinstance(__UpperCamelCase , __UpperCamelCase ): raise ValueError("""iterations mu...
58
from __future__ import annotations from collections.abc import Callable def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = 1_00 , ): lowerCAmelCase_ : Any = x_start lowerCAmelCase_ : Optional[Any] = fnc(snake_case_...
659
0
import numpy as np from transformers import Pipeline def lowerCAmelCase_ ( __a ) -> List[str]: """simple docstring""" lowerCamelCase__: Optional[Any] =np.max(__a , axis=-1 , keepdims=__a ) lowerCamelCase__: int =np.exp(outputs - m...
59
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, t...
659
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { '''configuration_upernet''': ['''UperNetConfig'''], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependency...
60
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) _lowercase = { '''iou_prediction_head.lay...
659
0
from __future__ import annotations def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : int , lowerCAmelCase_ : int , lowerCAmelCase_ : int ): """simple docstring""" lowerCAmelCase__ = [] lowerCAmelCase__ , lowerCAmelCas...
61
class __snake_case : """simple docstring""" def __init__( self : Union[str, Any] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {...
659
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import...
62
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModel...
659
0
def lowerCamelCase__ ( __lowerCamelCase : int ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): __UpperCAmelCase : Tuple = f"""Input value of [number={number}] must be an integer""" raise TypeError(__lowerCamelCase ) if numb...
63
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 _lowerc...
659
0
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vis...
64
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simp...
65
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCamelCase ( ): lowerCAmelCase_ : Dict = HfArgumentParser(snake_case__) lowerCAmelCase_ : Dict = parser.parse_args_into_dataclasses()[0] lowerCAmelCase_ : Lis...
659
0
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers...
66
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' ''' ...
659
0
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 tra...
67
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
659
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __A = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "LlamaConfig"], } try: if not i...
68
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } class __...
659
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable a : Union[str, Any] = { '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHI...
69
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, D...
70
import argparse import json from tqdm import tqdm def UpperCamelCase ( ): lowerCAmelCase_ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=snake_case__ , default="biencoder-nq-dev.json" , help="Path...
659
0
'''simple docstring''' from maths.prime_check import is_prime def a__ ( _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): UpperCAmelCase_ : Any = F'''Input value...
71
from collections.abc import Sequence def UpperCamelCase ( snake_case__ = None): if nums is None or not nums: raise ValueError("Input sequence should not be empty") lowerCAmelCase_ : Dict = nums[0] for i in range(1 , len(snake_case__)): lowerCAme...
659
0
'''simple docstring''' from __future__ import annotations import bisect def UpperCamelCase ( lowercase_ : list[int] , lowercase_ : int , lowercase_ : int = 0 , lowercase_ : int = -1 ) -> int: '''simple docstring''' if hi < 0: lowerc...
72
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
0
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowerCamelCase__ (_UpperCAmelCase): SCREAMING_SNAKE_CASE = int(number**0.5) return number == sq * sq def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , ...
73
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase = '''src/diffuse...
659
0
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __UpperCamelCa...
74
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json''' ...
659
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class lowerCamelCase_ ( __a ): def __init__( self : Union[str, Any] ,...
75
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Paddi...
659
0
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
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. _lowercase = 10 def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__): ...
659
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transf...
77
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer _lowercase = logging.get_logger(__name__) _lowercase = { ...
659
0
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowerCAmelCase_ ( snake_case_ : Optional[int] , snake_case_ : List[Any] ) -...
78
from collections.abc import Generator from math import sin def UpperCamelCase ( snake_case__): if len(snake_case__) != 32: raise ValueError("Input must be of length 32") lowerCAmelCase_ : Tuple = b"" for i in [3, 2, 1, 0]: little_endian += string_aa[8...
659
0
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.t...
79
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
659
0
__UpperCamelCase : List[str] = """Alexander Joslin""" import operator as op from .stack import Stack def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = {"""*""": op.mul, """/""": op.truediv, """+""": op.add, """-""": op.sub} __lowercase ...
80
from __future__ import annotations from collections.abc import Callable def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = 1_00 , ): lowerCAmelCase_ : Any = x_start lowerCAmelCase_ : Optional[Any] = fnc(snake_case_...
659
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _snake_case : Dict = logging.get_logger(__name__) _snake_case : Dict = { "facebook/xmod-base": "...
81
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, t...
659
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class lowercase__ ( SCREAMING_SNAKE_CASE ): ...
82
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) _lowercase = { '''iou_prediction_head.lay...
659
0
"""simple docstring""" 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__ = { ...
83
class __snake_case : """simple docstring""" def __init__( self : Union[str, Any] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {...
659
0
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to have...
84
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModel...
659
0
def _a ( lowercase__ : int = 10_00 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Tuple = 2**power SCREAMING_SNAKE_CASE__ : Optional[int] = str(lowercase__ ) SCREAMING_SNAKE_CASE__ : int = list(lowercase__ ) SCREAMING_...
85
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 _lowerc...
659
0
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __a :Dict = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_pytorch': 'https://huggingfa...
86
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowerCamelCase : Any = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3...
87
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCamelCase ( ): lowerCAmelCase_ : Dict = HfArgumentParser(snake_case__) lowerCAmelCase_ : Dict = parser.parse_args_into_dataclasses()[0] lowerCAmelCase_ : Lis...
659
0
"""simple docstring""" # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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-...
88
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' ''' ...
659
0
import importlib import inspect import os import re # 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 SCREAMING_SNAKE_CASE : Optional[Any] = "src/transformers" # This is to make sure the transformers mod...
89
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
659
0
'''simple docstring''' from bisect import bisect from itertools import accumulate def _snake_case ( A , A , A , A ) -> Dict: lowerCAmelCase__ = sorted(zip(A , A ) , key=lambda A : x[0] / x[1] , reverse...
90
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } class __...
659
0
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_token...
91
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wava...
92
import argparse import json from tqdm import tqdm def UpperCamelCase ( ): lowerCAmelCase_ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=snake_case__ , default="biencoder-nq-dev.json" , help="Path...
659
0
"""simple docstring""" from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, req...
93
from collections.abc import Sequence def UpperCamelCase ( snake_case__ = None): if nums is None or not nums: raise ValueError("Input sequence should not be empty") lowerCAmelCase_ : Dict = nums[0] for i in range(1 , len(snake_case__)): lowerCAme...
659
0
'''simple docstring''' import os from collections.abc import Iterator def lowercase_ ( __A : str = "." ) -> Iterator[str]: """simple docstring""" for dir_path, dir_names, filenames in os.walk(__A ): lowercase : List[Any] =[d for d in dir_names if d...
94
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils im...
95
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase = '''src/diffuse...
659
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __lowerCamelCase = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxCo...
96
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json''' ...
659
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Paddi...
659
0
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" _snake_case : Any = ['image_processor', 'tokenizer'...
98
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. _lowercase = 10 def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__): ...
659
0
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudi...
99
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer _lowercase = logging.get_logger(__name__) _lowercase = { ...
659
0
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, Stabl...
100
from collections.abc import Generator from math import sin def UpperCamelCase ( snake_case__): if len(snake_case__) != 32: raise ValueError("Input must be of length 32") lowerCAmelCase_ : Tuple = b"" for i in [3, 2, 1, 0]: little_endian += string_aa[8...
659
0
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_...
101
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
659
0
"""simple docstring""" from __future__ import annotations __magic_name__ : Any = """Muhammad Umer Farooq""" __magic_name__ : int = """MIT""" __magic_name__ : List[Any] = """1.0.0""" __magic_name__ : Optional[Any] = """Muhammad Um...
102
from __future__ import annotations from collections.abc import Callable def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = 1_00 , ): lowerCAmelCase_ : Any = x_start lowerCAmelCase_ : Optional[Any] = fnc(snake_case_...
659
0
"""simple docstring""" import datasets from .evaluate import evaluate snake_case = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, jo...
103
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, t...
659
0
"""simple docstring""" def _lowerCamelCase ( UpperCAmelCase_ : int ) -> int: """simple docstring""" if not isinstance(UpperCAmelCase_, UpperCAmelCase_ ): raise TypeError("only integers accepted as input" ) else: A__ = ...
104
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) _lowercase = { '''iou_prediction_head.lay...
659
0
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...
105
class __snake_case : """simple docstring""" def __init__( self : Union[str, Any] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {...
659
0
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __snake_case :Tuple =True ...
106
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModel...
659
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( __snake_case : list ): if len(__snake_case ) <= 1: return [tuple(__snake_case )] _A = [] def generate(__snake_case : int , __snake_case : list ): if k == 1: r...
107
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 _lowerc...
659
0
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import loggi...
108
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
109
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def UpperCamelCase ( ): lowerCAmelCase_ : Dict = HfArgumentParser(snake_case__) lowerCAmelCase_ : Dict = parser.parse_args_into_dataclasses()[0] lowerCAmelCase_ : Lis...
659
0
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __UpperCamelCase ( _A = "" ): lowerCAmelCase_ = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" lowerCAmelCase_ = BeautifulSoup(requests.get(snake_case__ ).text ...
431
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _lowercase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' ''' ...
659
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable UpperCamelCase_ = list[list[float | int]] def _lowerCAmelCase ( __magic_name__ : Any , __magic_name__ : List[Any] ) -> int: lowercase : int =...
92
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
659
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json', } ...
200
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json''' ), } class __...
659
0
"""simple docstring""" import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging A_ = logging.get_logger(__name__) de...
391
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
'''simple docstring''' import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient UpperCAmelCase = WebClient(token=os.environ['CI_SLACK_BOT_TOKEN']) ...
433
import argparse import json from tqdm import tqdm def UpperCamelCase ( ): lowerCAmelCase_ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=snake_case__ , default="biencoder-nq-dev.json" , help="Path...
659
0
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCAmelCase ( _lowercase : Any , _lowercase : List[str] , _lowercase : Any ) -> List[str]: """simple docstring"...
552
from collections.abc import Sequence def UpperCamelCase ( snake_case__ = None): if nums is None or not nums: raise ValueError("Input sequence should not be empty") lowerCAmelCase_ : Dict = nums[0] for i in range(1 , len(snake_case__)): lowerCAme...
659
0
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union __A = TypeVar("""T""") __A = Union[List[T], Tuple[T, ...]] __A = Union[T, List[T], Dict[str, T]] __A = Union[str, bytes, os.PathLike]
93
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
0
"""simple docstring""" import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class UpperCamelCase__ ( snake_c...
545
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase = '''src/diffuse...
659
0
'''simple docstring''' from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _A = [ """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone vide...
158
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/resolve/main/config.json''' ...
659
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) UpperCAmelCase_ : Union[str, Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/co...
570
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Paddi...
659
0