
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
   import PIL


lowercase_ 				=			logging.get_logger(__name__)





class     __UpperCamelCase (							lowerCAmelCase__       ):






     """simple docstring"""







     lowerCAmelCase_							   =			['''pixel_values''']



     def __init__(				self							:							str     ,						_A							:							bool = True     ,						_A							:							Dict[str, int] = None     ,						_A							:							PILImageResampling = PILImageResampling.BICUBIC     ,						_A							:							bool = True     ,						_A							:							Union[int, float] = 1 / 255     ,						_A							:							bool = True     ,						_A							:							Optional[Union[float, List[float]]] = None     ,						_A							:							Optional[Union[float, List[float]]] = None     ,						_A							:							bool = True     ,						**_A							:							Dict     ,						):







       """simple docstring"""




       super().__init__(**_A )
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		size if size is not None else {'''height''': 384, '''width''': 384}
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		get_size_dict(_A     ,						default_to_square=_A )

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		do_resize
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		size
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		resample
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		do_rescale
       __SCREAMING_SNAKE_CASE      :	str					=		rescale_factor
       __SCREAMING_SNAKE_CASE      :	List[str]					=		do_normalize
       __SCREAMING_SNAKE_CASE      :	Dict					=		image_mean if image_mean is not None else OPENAI_CLIP_MEAN
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		image_std if image_std is not None else OPENAI_CLIP_STD
       __SCREAMING_SNAKE_CASE      :	Dict					=		do_convert_rgb



     def  UpperCAmelCase__							(				self							:							int     ,						_A							:							np.ndarray     ,						_A							:							Dict[str, int]     ,						_A							:							PILImageResampling = PILImageResampling.BICUBIC     ,						_A							:							Optional[Union[str, ChannelDimension]] = None     ,						**_A							:							Optional[Any]     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		get_size_dict(_A     ,						default_to_square=_A )
       if "height" not in size or "width" not in size:
         raise ValueError(F'''The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}''' )
       __SCREAMING_SNAKE_CASE      :	int					=		(size['''height'''], size['''width'''])
       return resize(_A     ,						size=_A     ,						resample=_A     ,						data_format=_A     ,						**_A )



     def  UpperCAmelCase__							(				self							:							Dict     ,						_A							:							np.ndarray     ,						_A							:							Union[int, float]     ,						_A							:							Optional[Union[str, ChannelDimension]] = None     ,						**_A							:							Any     ,						):







       """simple docstring"""




       return rescale(_A     ,						scale=_A     ,						data_format=_A     ,						**_A )



     def  UpperCAmelCase__							(				self							:							Union[str, Any]     ,						_A							:							np.ndarray     ,						_A							:							Union[float, List[float]]     ,						_A							:							Union[float, List[float]]     ,						_A							:							Optional[Union[str, ChannelDimension]] = None     ,						**_A							:							int     ,						):







       """simple docstring"""




       return normalize(_A     ,						mean=_A     ,						std=_A     ,						data_format=_A     ,						**_A )




     def  UpperCAmelCase__							(				self							:							int     ,						_A							:							ImageInput     ,						_A							:							Optional[bool] = None     ,						_A							:							Optional[Dict[str, int]] = None     ,						_A							:							PILImageResampling = None     ,						_A							:							Optional[bool] = None     ,						_A							:							Optional[float] = None     ,						_A							:							Optional[bool] = None     ,						_A							:							Optional[Union[float, List[float]]] = None     ,						_A							:							Optional[Union[float, List[float]]] = None     ,						_A							:							Optional[Union[str, TensorType]] = None     ,						_A							:							bool = None     ,						_A							:							ChannelDimension = ChannelDimension.FIRST     ,						**_A							:							int     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	int					=		do_resize if do_resize is not None else self.do_resize
       __SCREAMING_SNAKE_CASE      :	List[str]					=		resample if resample is not None else self.resample
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		do_rescale if do_rescale is not None else self.do_rescale
       __SCREAMING_SNAKE_CASE      :	Dict					=		rescale_factor if rescale_factor is not None else self.rescale_factor
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		do_normalize if do_normalize is not None else self.do_normalize
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		image_mean if image_mean is not None else self.image_mean
       __SCREAMING_SNAKE_CASE      :	str					=		image_std if image_std is not None else self.image_std
       __SCREAMING_SNAKE_CASE      :	str					=		do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

       __SCREAMING_SNAKE_CASE      :	Any					=		size if size is not None else self.size
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		get_size_dict(_A     ,						default_to_square=_A )

       __SCREAMING_SNAKE_CASE      :	Any					=		make_list_of_images(_A )

       if not valid_images(_A ):
         raise ValueError(
             '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
             '''torch.Tensor, tf.Tensor or jax.ndarray.''' )

       if do_resize and size is None or resample is None:
         raise ValueError('''Size and resample must be specified if do_resize is True.''' )

       if do_rescale and rescale_factor is None:
         raise ValueError('''Rescale factor must be specified if do_rescale is True.''' )

       if do_normalize and (image_mean is None or image_std is None):
         raise ValueError('''Image mean and std must be specified if do_normalize is True.''' )

       # PIL RGBA images are converted to RGB
       if do_convert_rgb:
         __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		[convert_to_rgb(_A ) for image in images]

       # All transformations expect numpy arrays.
       __SCREAMING_SNAKE_CASE      :	Dict					=		[to_numpy_array(_A ) for image in images]

       if do_resize:
         __SCREAMING_SNAKE_CASE      :	List[Any]					=		[self.resize(image=_A     ,						size=_A     ,						resample=_A ) for image in images]

       if do_rescale:
         __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		[self.rescale(image=_A     ,						scale=_A ) for image in images]

       if do_normalize:
         __SCREAMING_SNAKE_CASE      :	Tuple					=		[self.normalize(image=_A     ,						mean=_A     ,						std=_A ) for image in images]

       __SCREAMING_SNAKE_CASE      :	int					=		[to_channel_dimension_format(_A     ,						_A ) for image in images]

       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		BatchFeature(data={'''pixel_values''': images}     ,						tensor_type=_A )

       return encoded_outputs





# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

_lowercase    	=		"2.13.1"

import platform

import pyarrow
from packaging import version


if version.parse(platform.python_version()) < version.parse("3.7"):
   raise ImportWarning(
       "To use `datasets`, Python>=3.7 is required, and the current version of Python doesn't match this condition."
   )

if version.parse(pyarrow.__version__).major < 8:
   raise ImportWarning(
       "To use `datasets`, the module `pyarrow>=8.0.0` is required, and the current version of `pyarrow` doesn't match this condition.\n"
       "If you are running this in a Google Colab, you should probably just restart the runtime to use the right version of `pyarrow`."
   )

del platform
del pyarrow
del version

from .arrow_dataset import Dataset
from .arrow_reader import ReadInstruction
from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
from .combine import concatenate_datasets, interleave_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .download import *
from .features import *
from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
from .info import DatasetInfo, MetricInfo
from .inspect import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
    list_datasets,
    list_metrics,
)
from .iterable_dataset import IterableDataset
from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric
from .metric import Metric
from .splits import (
    NamedSplit,
    NamedSplitAll,
    Split,
    SplitBase,
    SplitDict,
    SplitGenerator,
    SplitInfo,
    SubSplitInfo,
    percent,
)
from .tasks import *
from .utils import *
from .utils import logging


# deprecated modules
from datasets import arrow_dataset as _arrow_dataset  # isort:skip
from datasets import utils as _utils  # isort:skip
from datasets.utils import download_manager as _deprecated_download_manager  # isort:skip

_lowercase    	=		concatenate_datasets
_lowercase    	=		DownloadConfig
_lowercase    	=		DownloadManager
_lowercase    	=		DownloadMode
_lowercase    	=		DownloadConfig
_lowercase    	=		DownloadMode
_lowercase    	=		DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager
