





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,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_batched,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


_lowerCamelCase			       =      logging.get_logger(__name__)







class 			__A       (      lowerCamelCase__  ):




      """simple docstring"""







      UpperCAmelCase__						=      ["""pixel_values"""]


      def __init__(		self      ,							a__ = True      ,							a__ = None      ,							a__ = PILImageResampling.BICUBIC      ,							a__ = True      ,							a__ = True      ,							a__ = 1 / 255      ,							a__ = None      ,							a__ = True      ,							a__ = None      ,							a__ = None      ,							**a__      ,							):



             """simple docstring"""





             super().__init__(**a__)
             _lowerCamelCase							:     Dict	=		size if size is not None else {'''height''': 224, '''width''': 224}
             _lowerCamelCase							:     Union[str, Any]	=		get_size_dict(a__)
             _lowerCamelCase							:     str	=		crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
             _lowerCamelCase							:     str	=		get_size_dict(a__      ,							default_to_square=a__      ,							param_name='''crop_size''')

             _lowerCamelCase							:     List[str]	=		do_resize
             _lowerCamelCase							:     List[str]	=		do_rescale
             _lowerCamelCase							:     Tuple	=		do_normalize
             _lowerCamelCase							:     Union[str, Any]	=		do_center_crop
             _lowerCamelCase							:     Optional[Any]	=		crop_size
             _lowerCamelCase							:     str	=		size
             _lowerCamelCase							:     Dict	=		resample
             _lowerCamelCase							:     List[Any]	=		rescale_factor
             _lowerCamelCase							:     Optional[Any]	=		image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
             _lowerCamelCase							:     List[str]	=		image_std if image_std is not None else IMAGENET_DEFAULT_STD


      def 				__snake_case			(		self      ,							a__      ,							a__      ,							a__ = PILImageResampling.BILINEAR      ,							a__ = None      ,							**a__      ,							):



             """simple docstring"""





             _lowerCamelCase							:     int	=		get_size_dict(a__)

             if "shortest_edge" in size:
                    _lowerCamelCase							:     int	=		get_resize_output_image_size(a__      ,							size=size['''shortest_edge''']      ,							default_to_square=a__)
                    # size = get_resize_output_image_size(image, size["shortest_edge"], size["longest_edge"])
             elif "height" in size and "width" in size:
                    _lowerCamelCase							:     int	=		(size['''height'''], size['''width'''])
             else:
                    raise ValueError(F"""Size must contain 'height' and 'width' keys or 'shortest_edge' key. Got {size.keys()}""")
             return resize(a__      ,							size=a__      ,							resample=a__      ,							data_format=a__      ,							**a__)


      def 				__snake_case			(		self      ,							a__      ,							a__      ,							a__ = None      ,							**a__      ,							):



             """simple docstring"""





             _lowerCamelCase							:     str	=		get_size_dict(a__)
             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(a__      ,							size=(size['''height'''], size['''width'''])      ,							data_format=a__      ,							**a__)


      def 				__snake_case			(		self      ,							a__      ,							a__      ,							a__ = None      ,							**a__):



             """simple docstring"""





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


      def 				__snake_case			(		self      ,							a__      ,							a__      ,							a__      ,							a__ = None      ,							**a__      ,							):



             """simple docstring"""





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



      def 				__snake_case			(		self      ,							a__      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = None      ,							a__ = ChannelDimension.FIRST      ,							**a__      ,							):



             """simple docstring"""





             _lowerCamelCase							:     Union[str, Any]	=		do_resize if do_resize is not None else self.do_resize
             _lowerCamelCase							:     Optional[int]	=		do_rescale if do_rescale is not None else self.do_rescale
             _lowerCamelCase							:     List[str]	=		do_normalize if do_normalize is not None else self.do_normalize
             _lowerCamelCase							:     str	=		do_center_crop if do_center_crop is not None else self.do_center_crop
             _lowerCamelCase							:     str	=		crop_size if crop_size is not None else self.crop_size
             _lowerCamelCase							:     str	=		get_size_dict(a__      ,							param_name='''crop_size'''      ,							default_to_square=a__)
             _lowerCamelCase							:     Any	=		resample if resample is not None else self.resample
             _lowerCamelCase							:     List[str]	=		rescale_factor if rescale_factor is not None else self.rescale_factor
             _lowerCamelCase							:     Dict	=		image_mean if image_mean is not None else self.image_mean
             _lowerCamelCase							:     Optional[int]	=		image_std if image_std is not None else self.image_std

             _lowerCamelCase							:     List[str]	=		size if size is not None else self.size
             _lowerCamelCase							:     Tuple	=		get_size_dict(a__)

             if not is_batched(a__):
                    _lowerCamelCase							:     int	=		[images]

             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:
                    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.''')

             # All transformations expect numpy arrays.
             _lowerCamelCase							:     Optional[int]	=		[to_numpy_array(a__) for image in images]

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

             if do_center_crop:
                    _lowerCamelCase							:     Optional[int]	=		[self.center_crop(image=a__      ,							size=a__) for image in images]

             if do_rescale:
                    _lowerCamelCase							:     Any	=		[self.rescale(image=a__      ,							scale=a__) for image in images]

             if do_normalize:
                    _lowerCamelCase							:     Optional[int]	=		[self.normalize(image=a__      ,							mean=a__      ,							std=a__) for image in images]

             _lowerCamelCase							:     List[Any]	=		[to_channel_dimension_format(a__      ,							a__) for image in images]

             _lowerCamelCase							:     List[str]	=		{'''pixel_values''': images}
             return BatchFeature(data=a__      ,							tensor_type=a__)








_lowerCamelCase			       =      [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
_lowerCamelCase			       =      [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
_lowerCamelCase			       =      {
    0: 'Sunday',
    1: 'Monday',
    2: 'Tuesday',
    3: 'Wednesday',
    4: 'Thursday',
    5: 'Friday',
    6: 'Saturday',
}




def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       assert len(str(lowercase_      )      ) > 2, "year should be in YYYY format"
       assert 1 <= month <= 12, "month should be between 1 to 12"
       assert 1 <= day <= 31, "day should be between 1 to 31"

       # Doomsday algorithm:
       _lowerCamelCase							:     List[Any]	=		year // 1_00
       _lowerCamelCase							:     Dict	=		(5 * (century % 4) + 2) % 7
       _lowerCamelCase							:     Tuple	=		year % 1_00
       _lowerCamelCase							:     int	=		centurian % 12
       _lowerCamelCase							:     List[Any]	=		(
           (centurian // 12) + centurian_m + (centurian_m // 4) + century_anchor
       ) % 7
       _lowerCamelCase							:     List[Any]	=		(
           DOOMSDAY_NOT_LEAP[month - 1]
           if (year % 4 != 0) or (centurian == 0 and (year % 4_00) == 0)
           else DOOMSDAY_LEAP[month - 1]
       )
       _lowerCamelCase							:     Any	=		(dooms_day + day - day_anchor) % 7
       return WEEK_DAY_NAMES[week_day]


if __name__ == "__main__":
       import doctest

       doctest.testmod()

