
'''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 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			:  Any   							=	logging.get_logger(__name__)






class 			lowerCAmelCase__       (  _UpperCAmelCase					):
					lowerCAmelCase_					       =					['pixel_values']






					def __init__(       self    ,							__SCREAMING_SNAKE_CASE = True    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC    ,							__SCREAMING_SNAKE_CASE = True    ,							__SCREAMING_SNAKE_CASE = 1 / 2_55    ,							__SCREAMING_SNAKE_CASE = True    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = True    ,							**__SCREAMING_SNAKE_CASE    ,							):


											"""simple docstring"""





											super().__init__(**SCREAMING_SNAKE_CASE_		)
											lowercase_     :					Any													=	size if size is not None else {"""height""": 3_84, """width""": 3_84}
											lowercase_     :					Any													=	get_size_dict(SCREAMING_SNAKE_CASE_    ,							default_to_square=SCREAMING_SNAKE_CASE_		)

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






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC    ,							__SCREAMING_SNAKE_CASE = None    ,							**__SCREAMING_SNAKE_CASE    ,							):


											"""simple docstring"""





											lowercase_     :					Union[str, Any]													=	get_size_dict(SCREAMING_SNAKE_CASE_    ,							default_to_square=SCREAMING_SNAKE_CASE_		)
											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()}'''		)
											lowercase_     :					Any													=	(size["""height"""], size["""width"""])
											return resize(SCREAMING_SNAKE_CASE_    ,							size=SCREAMING_SNAKE_CASE_    ,							resample=SCREAMING_SNAKE_CASE_    ,							data_format=SCREAMING_SNAKE_CASE_    ,							**SCREAMING_SNAKE_CASE_		)






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = None    ,							**__SCREAMING_SNAKE_CASE    ,							):


											"""simple docstring"""





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






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = None    ,							**__SCREAMING_SNAKE_CASE    ,							):


											"""simple docstring"""





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






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = None    ,							__SCREAMING_SNAKE_CASE = ChannelDimension.FIRST    ,							**__SCREAMING_SNAKE_CASE    ,							):


											"""simple docstring"""





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

											lowercase_     :					Optional[int]													=	size if size is not None else self.size
											lowercase_     :					Any													=	get_size_dict(SCREAMING_SNAKE_CASE_    ,							default_to_square=SCREAMING_SNAKE_CASE_		)

											lowercase_     :					List[str]													=	make_list_of_images(SCREAMING_SNAKE_CASE_		)

											if not valid_images(SCREAMING_SNAKE_CASE_		):
																	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:
																	lowercase_     :					Optional[Any]													=	[convert_to_rgb(SCREAMING_SNAKE_CASE_		) for image in images]

											# All transformations expect numpy arrays.
											lowercase_     :					Any													=	[to_numpy_array(SCREAMING_SNAKE_CASE_		) for image in images]

											if do_resize:
																	lowercase_     :					Optional[int]													=	[self.resize(image=SCREAMING_SNAKE_CASE_    ,							size=SCREAMING_SNAKE_CASE_    ,							resample=SCREAMING_SNAKE_CASE_		) for image in images]

											if do_rescale:
																	lowercase_     :					str													=	[self.rescale(image=SCREAMING_SNAKE_CASE_    ,							scale=SCREAMING_SNAKE_CASE_		) for image in images]

											if do_normalize:
																	lowercase_     :					int													=	[self.normalize(image=SCREAMING_SNAKE_CASE_    ,							mean=SCREAMING_SNAKE_CASE_    ,							std=SCREAMING_SNAKE_CASE_		) for image in images]

											lowercase_     :					Optional[Any]													=	[to_channel_dimension_format(SCREAMING_SNAKE_CASE_    ,							SCREAMING_SNAKE_CASE_		) for image in images]

											lowercase_     :					List[str]													=	BatchFeature(data={'''pixel_values''': images}    ,							tensor_type=SCREAMING_SNAKE_CASE_		)

											return encoded_outputs






'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase			:  Tuple   							=	{"configuration_vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"]}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_lowercase			:  str   							=	[
							    "VIT_MSN_PRETRAINED_MODEL_ARCHIVE_LIST",
							    "ViTMSNModel",
							    "ViTMSNForImageClassification",
							    "ViTMSNPreTrainedModel",
							]

if TYPE_CHECKING:
							from .configuration_vit_msn import VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTMSNConfig

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_vit_msn import (
														    VIT_MSN_PRETRAINED_MODEL_ARCHIVE_LIST,
														    ViTMSNForImageClassification,
														    ViTMSNModel,
														    ViTMSNPreTrainedModel,
														)

else:
							import sys

							_lowercase			:  int   							=	_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



