





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,
    convert_to_rgb,
    get_resize_output_image_size,
    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


A   : List[Any]			=				logging.get_logger(__name__)


if is_vision_available():
					import PIL


class   A      (SCREAMING_SNAKE_CASE   ):
			'''simple docstring'''




			__lowerCamelCase     :	Any          =   ['''pixel_values''']






			def __init__(      self       :   Union[str, Any]							,     __lowerCAmelCase       :   bool = True							,     __lowerCAmelCase       :   Dict[str, int] = None							,     __lowerCAmelCase       :   PILImageResampling = PILImageResampling.BICUBIC							,     __lowerCAmelCase       :   bool = True							,     __lowerCAmelCase       :   Dict[str, int] = None							,     __lowerCAmelCase       :   bool = True							,     __lowerCAmelCase       :   Union[int, float] = 1 / 2_55							,     __lowerCAmelCase       :   bool = True							,     __lowerCAmelCase       :   Optional[Union[float, List[float]]] = None							,     __lowerCAmelCase       :   Optional[Union[float, List[float]]] = None							,     __lowerCAmelCase       :   bool = True							,     **__lowerCAmelCase       :   str							,     )     ->     None:







					"""simple docstring"""






					super().__init__(**__lowerCAmelCase       )
					A__  				=       size if size is not None else {"""shortest_edge""": 2_24}
					A__  				=       get_size_dict(__lowerCAmelCase							,     default_to_square=__lowerCAmelCase       )
					A__  				=       crop_size if crop_size is not None else {"""height""": 2_24, """width""": 2_24}
					A__  				=       get_size_dict(__lowerCAmelCase							,     default_to_square=__lowerCAmelCase							,     param_name="""crop_size"""       )

					A__  				=       do_resize
					A__  				=       size
					A__  				=       resample
					A__  				=       do_center_crop
					A__  				=       crop_size
					A__  				=       do_rescale
					A__  				=       rescale_factor
					A__  				=       do_normalize
					A__  				=       image_mean if image_mean is not None else OPENAI_CLIP_MEAN
					A__  				=       image_std if image_std is not None else OPENAI_CLIP_STD
					A__  				=       do_convert_rgb






			def        a_	(      self       :   Optional[int]							,     __lowerCAmelCase       :   np.ndarray							,     __lowerCAmelCase       :   Dict[str, int]							,     __lowerCAmelCase       :   PILImageResampling = PILImageResampling.BICUBIC							,     __lowerCAmelCase       :   Optional[Union[str, ChannelDimension]] = None							,     **__lowerCAmelCase       :   Union[str, Any]							,     )     ->     np.ndarray:







					"""simple docstring"""






					A__  				=       get_size_dict(__lowerCAmelCase							,     default_to_square=__lowerCAmelCase       )
					if "shortest_edge" not in size:
							raise ValueError(f'The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}'       )
					A__  				=       get_resize_output_image_size(__lowerCAmelCase							,     size=size["""shortest_edge"""]							,     default_to_square=__lowerCAmelCase       )
					return resize(__lowerCAmelCase							,     size=__lowerCAmelCase							,     resample=__lowerCAmelCase							,     data_format=__lowerCAmelCase							,     **__lowerCAmelCase       )






			def        a_	(      self       :   str							,     __lowerCAmelCase       :   np.ndarray							,     __lowerCAmelCase       :   Dict[str, int]							,     __lowerCAmelCase       :   Optional[Union[str, ChannelDimension]] = None							,     **__lowerCAmelCase       :   List[Any]							,     )     ->     np.ndarray:







					"""simple docstring"""






					A__  				=       get_size_dict(__lowerCAmelCase       )
					if "height" not in size or "width" not in size:
							raise ValueError(f'The `size` parameter must contain the keys (height, width). Got {size.keys()}'       )
					return center_crop(__lowerCAmelCase							,     size=(size["""height"""], size["""width"""])							,     data_format=__lowerCAmelCase							,     **__lowerCAmelCase       )






			def        a_	(      self       :   Tuple							,     __lowerCAmelCase       :   np.ndarray							,     __lowerCAmelCase       :   Union[int, float]							,     __lowerCAmelCase       :   Optional[Union[str, ChannelDimension]] = None							,     **__lowerCAmelCase       :   Union[str, Any]							,     )     ->     Union[str, Any]:







					"""simple docstring"""






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






			def        a_	(      self       :   int							,     __lowerCAmelCase       :   np.ndarray							,     __lowerCAmelCase       :   Union[float, List[float]]							,     __lowerCAmelCase       :   Union[float, List[float]]							,     __lowerCAmelCase       :   Optional[Union[str, ChannelDimension]] = None							,     **__lowerCAmelCase       :   List[Any]							,     )     ->     np.ndarray:







					"""simple docstring"""






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







			def        a_	(      self       :   Tuple							,     __lowerCAmelCase       :   ImageInput							,     __lowerCAmelCase       :   bool = None							,     __lowerCAmelCase       :   Dict[str, int] = None							,     __lowerCAmelCase       :   PILImageResampling = None							,     __lowerCAmelCase       :   bool = None							,     __lowerCAmelCase       :   int = None							,     __lowerCAmelCase       :   bool = None							,     __lowerCAmelCase       :   float = None							,     __lowerCAmelCase       :   bool = None							,     __lowerCAmelCase       :   Optional[Union[float, List[float]]] = None							,     __lowerCAmelCase       :   Optional[Union[float, List[float]]] = None							,     __lowerCAmelCase       :   bool = None							,     __lowerCAmelCase       :   Optional[Union[str, TensorType]] = None							,     __lowerCAmelCase       :   Optional[ChannelDimension] = ChannelDimension.FIRST							,     **__lowerCAmelCase       :   Optional[Any]							,     )     ->     PIL.Image.Image:







					"""simple docstring"""






					A__  				=       do_resize if do_resize is not None else self.do_resize
					A__  				=       size if size is not None else self.size
					A__  				=       get_size_dict(__lowerCAmelCase							,     param_name="""size"""							,     default_to_square=__lowerCAmelCase       )
					A__  				=       resample if resample is not None else self.resample
					A__  				=       do_center_crop if do_center_crop is not None else self.do_center_crop
					A__  				=       crop_size if crop_size is not None else self.crop_size
					A__  				=       get_size_dict(__lowerCAmelCase							,     param_name="""crop_size"""							,     default_to_square=__lowerCAmelCase       )
					A__  				=       do_rescale if do_rescale is not None else self.do_rescale
					A__  				=       rescale_factor if rescale_factor is not None else self.rescale_factor
					A__  				=       do_normalize if do_normalize is not None else self.do_normalize
					A__  				=       image_mean if image_mean is not None else self.image_mean
					A__  				=       image_std if image_std is not None else self.image_std
					A__  				=       do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

					A__  				=       make_list_of_images(__lowerCAmelCase       )

					if not valid_images(__lowerCAmelCase       ):
							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:
							raise ValueError("""Size must be specified if do_resize is True."""       )

					if do_center_crop and crop_size is None:
							raise ValueError("""Crop size must be specified if do_center_crop 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:
							A__  				=       [convert_to_rgb(__lowerCAmelCase       ) for image in images]

					# All transformations expect numpy arrays.
					A__  				=       [to_numpy_array(__lowerCAmelCase       ) for image in images]

					if do_resize:
							A__  				=       [self.resize(image=__lowerCAmelCase							,     size=__lowerCAmelCase							,     resample=__lowerCAmelCase       ) for image in images]

					if do_center_crop:
							A__  				=       [self.center_crop(image=__lowerCAmelCase							,     size=__lowerCAmelCase       ) for image in images]

					if do_rescale:
							A__  				=       [self.rescale(image=__lowerCAmelCase							,     scale=__lowerCAmelCase       ) for image in images]

					if do_normalize:
							A__  				=       [self.normalize(image=__lowerCAmelCase							,     mean=__lowerCAmelCase							,     std=__lowerCAmelCase       ) for image in images]

					A__  				=       [to_channel_dimension_format(__lowerCAmelCase							,     __lowerCAmelCase       ) for image in images]

					A__  				=       {"""pixel_values""": images}
					return BatchFeature(data=__lowerCAmelCase							,     tensor_type=__lowerCAmelCase       )













from string import ascii_uppercase

A   : List[str]			=				{str(ord(c) - 5_5): c for c in ascii_uppercase}







def        __lowerCamelCase (							__a       :int   ,					__a       :int   )		->    str:






		"""simple docstring"""

		if isinstance(__a   ,					__a   ):
				raise TypeError("""int() can't convert non-string with explicit base"""   )
		if num < 0:
				raise ValueError("""parameter must be positive int"""   )
		if isinstance(__a   ,					__a   ):
				raise TypeError("""'str' object cannot be interpreted as an integer"""   )
		if isinstance(__a   ,					__a   ):
				raise TypeError("""'float' object cannot be interpreted as an integer"""   )
		if base in (0, 1):
				raise ValueError("""base must be >= 2"""   )
		if base > 3_6:
				raise ValueError("""base must be <= 36"""   )
		A__  				=       """"""
		A__  				=       0
		A__  				=       0
		while div != 1:
				A__				,      A__  				=       divmod(__a   ,					__a   )
				if base >= 1_1 and 9 < mod < 3_6:
						A__  				=       ALPHABET_VALUES[str(__a   )]
				else:
						A__  				=       str(__a   )
				new_value += actual_value
				A__  				=       num // base
				A__  				=       div
				if div == 0:
						return str(new_value[::-1]   )
				elif div == 1:
						new_value += str(__a   )
						return str(new_value[::-1]   )

		return new_value[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for base in range(2, 3_7):
										for num in range(1_0_0_0):
															assert int(decimal_to_any(num, base), base) == num, (
															    num,
															    base,
															    decimal_to_any(num, base),
															    int(decimal_to_any(num, base), base),
															)



