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
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class _l...
21
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import ...
22
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTe...
23
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def lowerCamelCase__ ( snake_case_ : Optional[int] , snake_case_ : Union[str, Any] , snake_case_ : Optional[int] ) -> Unio...
24
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
"""simple docstring""" import sys import turtle def lowercase_ ( _snake_case ,_snake_case ): return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase_ ( _snake_case ,_snake_case ,_snake_case ,_snake_case ,): my_pen.up() my_pen.goto(vertexa[0] ,vertex...
25
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
class lowercase : def __init__( self ) -> List[str]: _A : List[Any] = {} def a__ ( self ) -> None: print(self.vertex ) for i in self.vertex: print(_a , """ -> """ , """ -> """....
26
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedu...
249
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowercase : Union[str, Any] = logging.get_logger(__name__) __lowercase : Tuple = { ...
27
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
'''simple docstring''' from math import sqrt def __lowerCamelCase ( A__ ) -> int: """simple docstring""" UpperCamelCase = 0 for i in range(1 , int(sqrt(A__ ) + 1 ) ): if n % i == 0 and i != sqrt(A__ ): total ...
28
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from tran...
29
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch if is...
30
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : Any = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
31
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake UpperCAmelCase_ : Tuple = numpy.array([0, 0]) UpperCAmelCase_ : Any = numpy.array([0.5, 0.8_6_6_0_2_5_4]) UpperCAmelCase_ : Tuple ...
32
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
"""simple docstring""" import sys def lowercase ( __snake_case : Dict ): lowercase_ : int = len(__snake_case ) lowercase_ : Tuple = [[0 for x in range(__snake_case )] for x in range(__snake_case )] lowercase_ : int = [[0 fo...
33
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' class _a : def __init__( self : List[str] ): '''simple docstring''' UpperCAmelCase = '''''' UpperCAmelCase = '''''' UpperCAmelCase = [] def A ( self : List[Any] , ...
34
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from...
35
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging _snake_case = logging.get_logger(__name__) def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstr...
36
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer _lowerCAmelCase = logging.get_logger...
37
"""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.apache.org/...
249
0
import numpy as np class _SCREAMING_SNAKE_CASE : def __init__( self : int ): UpperCamelCase :int = (0, 0) UpperCamelCase :List[str] = None UpperCamelCase :Union[str, Any] = 0 UpperCamelCase :Optional[Any] = 0 UpperCamelCase ...
38
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __A ( )-> str: """simple docstring""" with offline(OfflineSimu...
39
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
40
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
'''simple docstring''' import inspect import unittest from transformers import MobileNetVaConfig 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 ......
41
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
'''simple docstring''' from math import isclose, sqrt def SCREAMING_SNAKE_CASE__ ( __A , __A , __A ) -> tuple[float, float, float]: _snake_case = point_y / 4 / point_x _snake_case = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) _snake_case ...
42
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
from string import ascii_lowercase, ascii_uppercase def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if not sentence: return "" __UpperCamelCase :Optional[Any] = dict(zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ) return lower_to_upper.get(sentenc...
43
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
44
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
"""simple docstring""" def lowercase ( lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : List[Any] ) -> Optional[Any]: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase ( lowerCAmelCase__ : int , lowerCAmelC...
45
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""simple docstring""" import warnings from typing import Any, Dict, 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_uti...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
'''simple docstring''' import os import sys import unittest lowerCamelCase : Optional[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 ...
47
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import Gr...
48
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedu...
249
0
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __snake_case :List[Any] = 1.054571817E-34 # unit of ℏ : J * s __snake_case :List[str] = 3E8 # unit of c : m * s^-1 def ...
49
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase ( metaclass=__UpperCamelCase ): UpperCAmelCase__ = ["""torch"""] def __init__( self : List[Any] , *UpperCAmelCase : Optional[Any] , **UpperCAmelCase : List[str] ) -> int: ...
50
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, ...
51
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
def A_ ( _lowerCAmelCase = 50 ) -> int: UpperCamelCase : List[Any] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): different_co...
52
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
'''simple docstring''' import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": a__ : List[str] =argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=st...
53
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
"""simple docstring""" from __future__ import annotations from collections import deque class UpperCamelCase_ : """simple docstring""" def __init__( self : str , UpperCAmelCase__ : list[str] ) -> Any: __SCREAMING_SNAKE_CASE = [] self.adlist.append( ...
54
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Union[str, Any] = logging.get_logger(__name__) a_ : Optional[Any] = { """microsoft/unispeech-sat-base-100h-libri-ft""": ( ""...
55
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a : Any ...
56
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" # Lint as: python3 import itertools import os import re A : Dict = re.compile(R"([A-Z]+)([A-Z][a-z])") A : Union[str, Any] = re.compile(R"([a-z\d])([A-Z])") A : Any = re.compile(R"(?<!_)_(?!_)") A : List[Any] = re.compile(R"(_{2,})")...
57
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
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...
58
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_bar...
59
"""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.apache.org/...
249
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 snake_case_( unittest.TestCase ): def lowerCamelCase__ ( self : ...
60
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
"""simple docstring""" class A_ : '''simple docstring''' def __init__( self ): """simple docstring""" UpperCAmelCase_ : List[Any] = "" UpperCAmelCase_ : Optional[int] = "" UpperCAmelCase_ : Optional[Any] = [] def ...
61
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : int ): return [sentence[i : i + ngram_size] for i in range(len(SCREAMING_SNAKE_CASE__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
62
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowerCAmelCase_ : List[str] = HfApi() lowerCAmelCase_ : str = {} # fmt: off lowerCAmelCase_ : Any = torch.tensor([ -0.7_515, -1.6_883, ...
63
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
64
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCamelCase__ = TypeVar('KEY') UpperCamelCase__ = TypeVar('VAL') @dataclass(frozen=UpperCAmelCase_ , slots=UpperCAmelCase_ ) class A ...
65
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a = { "configuration_data2vec_audio": ["DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP", "Data2VecAudioConfig"], "configuration_data2vec_te...
66
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __UpperCAmelCas...
67
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
import string def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: str ) -> None: '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): A__ = "" for symbol in message: if symbol in string.ascii_uppercase: ...
68
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
"""simple docstring""" import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, A...
69
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
'''simple docstring''' import unittest from transformers import DonutProcessor A__ : Union[str, Any] ='''naver-clova-ix/donut-base''' class UpperCAmelCase ( unittest.TestCase ): def lowercase__ ( self : List[Any] ) -> int: ...
70
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedu...
249
0
import random def A ( a_ ,a_ ,a_ = False ) -> dict: __UpperCamelCase : dict ={i: [] for i in range(a_ )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
71
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
"""simple docstring""" from __future__ import annotations def snake_case_ ( A_ : list[int] ): '''simple docstring''' if len(A_ ) == 0: return array _lowerCamelCase , _lowerCamelCase : List[str] = min(A_ ), max...
72
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
import os import unicodedata 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 ={"""vocab_file""": """spiece.mo...
73
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_se...
74
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
'''simple docstring''' from PIL import Image def a_ ( __snake_case : Image , __snake_case : int ) -> Image: """simple docstring""" lowerCamelCase_ =(259 * (level + 255)) / (255 * (259 - level)) def contrast(__snake_case ...
75
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __vers...
76
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
"""simple docstring""" 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...
77
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
"""simple docstring""" import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink ...
78
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
'''simple docstring''' from __future__ import annotations lowerCamelCase_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __lowercase ( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , ) -> ...
79
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' import numpy as np def _UpperCamelCase ( __A ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def _UpperCamelCase ( __A ) -> np.ndarray: '''simple docstring''' return vect...
80
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def _A ( lowercase , lowercase , lowercase , lowercase = 1_00 , ): """simple docstring""" a =x_start a =fnc(...
81
"""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.apache.org/...
249
0
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging A__ = """\ """ A__ = """ Perplexity (PPL) is one of the most common metrics for evaluating language models. It ...
82
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
'''simple docstring''' def A__ ( UpperCAmelCase_ ): if num < 0: return False _UpperCamelCase : int = num _UpperCamelCase : int = 0 while num > 0: _UpperCamelCase : str = rev_num * 1_0 + (num % 1_0) num //= 1_0...
83
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _SCREAMING_SNAKE_CASE : UpperCAmelCase_ :int UpperCAmelCase_ :TreeNode | None = None UpperCAmelCase_ :TreeNode | Non...
84
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def UpperCamelCase_( snake_case : str ): '''simple docstring''' return "".join(sorted(snake_case ) ) def UpperCamelCase_( snake_case ...
85
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @requ...
86
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
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 snake_case_ (...
87
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
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...
88
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ ) -> Optional[Any]: _a : Optional[Any] = [] _a : List[str] = set({'(', '[', '{'} ) _a : List[str] = set({')', ']', '}'} ) _a : Optional[int] ...
89
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_xlm_roberta_xl": [ "XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMRobertaXLConfig", "XLMRobertaXLOnnxConfig", ...
90
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
"""simple docstring""" from __future__ import annotations class lowerCAmelCase__ : '''simple docstring''' def __init__( self : Any , lowercase_ : int = 0): '''simple docstring''' SCREAMING_SNAKE_CASE_ : List[Any] ...
91
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
from __future__ import annotations UpperCamelCase__ = 1.6021E-19 # units = C def _a ( SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , ): if (conductivity, electron_conc, mobilit...
92
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedu...
249
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE...
93
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
snake_case : List[str] = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '...
94
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester...
95
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configurati...
96
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = ...
97
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict lowerCAmelCase__ : Union[str, Any] = namedtuple( '...
98
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
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 lowercase : Union[str, Any...
99
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
"""simple docstring""" import numpy class SCREAMING_SNAKE_CASE_ : """simple docstring""" def __init__( self , lowerCAmelCase__ , lowerCAmelCase__): __SCREAMING_SNAKE_CASE = input_array # Random initial weights are assigned where first argument is the # ...
100
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
import sys lowercase__ :Union[str, Any] = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098...
101
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
"""simple docstring""" import sys from collections import defaultdict class _UpperCAmelCase : '''simple docstring''' def __init__(self ): '''simple docstring''' __snake_case : Optional[int] = [] def SCREAMING_SNAKE_CASE (self , a_ ): '''sim...
102
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAvai...
103
"""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.apache.org/...
249
0
'''simple docstring''' from __future__ import annotations from random import random class lowercase_ : """simple docstring""" def __init__( self : Union[str, Any] ,lowercase__ : int | None = None ): __lowercase = value __lowercase = random() ...
104
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
"""simple docstring""" import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax ...
105
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" from typing import Any class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Any ,lowercase_ : Any ): lowerCAmelCase__ : List[str] = data lowerCAmelCase__ : Any = None class S...
106
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if i...
107
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetuned-audiose...
108
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, 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(): ...
109
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
def lowerCamelCase_ ( UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : int ) -> Any: """simple docstring""" __lowerCamelCase = '''''' for i in table: res += inp[i - 1] return res def lower...
90
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm lowerCAmelCase: Tuple = 2_0_4_8 lowerCAmelCase: str = 4_0_9_6 lowerCAmelCase: Optional[int] = 4_2 lowerCAmelCase: str = os.environ.p...
297
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' lowerCAmelCase = len(__UpperCamelCase ) // 2 # choose the middle 3 elements lowerCAmelCase ...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( Chann...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
import csv import tweepy # Twitter API credentials lowerCAmelCase__ :int = '''''' lowerCAmelCase__ :Tuple = '''''' lowerCAmelCase__ :Union[str, Any] = '''''' lowerCAmelCase__ :Tuple = '''''' def lowerCAmelCase__ ( a__: List[Any] ) -> Union[str, Any...
329
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedu...
249
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor UpperCAmelCase = logging.get_logger(__name__) class UpperCAmelCase_ ( _lowercase): def __init__( self : Dict , *__U...
256
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", exist_ok=True) def A_ ( A__ ) -> Tuple: ...
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available __a = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except Op...
66
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A__ ( __SCREAMING_SNAKE_CASE): _UpperCAmelCase : Optional[Any] = ["""image_processor""", """tokenizer"""] _UpperCAmelCase : Union[str, Any] ...
287
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
import numpy class __A: """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): UpperCamelCase__ = input_array # Random initial weights are assigned where first argument is the # number of nodes in previous layer and ...
244
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __snake_case = (7_20, 12_80) # Height, Width __snake_case = (0.4, 0.6) # if height or width lower than this scale, drop it. __snake_case = 1 / 1_00 __snake_case = ''...
348
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0