
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, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_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


lowerCamelCase__    :		List[str]          =   logging.get_logger(__name__)



class       _snake_case   (	UpperCAmelCase_							):
 __lowerCAmelCase  :     int        =			['pixel_values']


 def __init__(					self					,  SCREAMING_SNAKE_CASE_ = True					,  SCREAMING_SNAKE_CASE_ = None					,  SCREAMING_SNAKE_CASE_ = PIL.Image.BICUBIC					,  SCREAMING_SNAKE_CASE_ = True					,  SCREAMING_SNAKE_CASE_ = None					,  SCREAMING_SNAKE_CASE_ = 1 / 2_55					,  SCREAMING_SNAKE_CASE_ = True					,  SCREAMING_SNAKE_CASE_ = True					,  SCREAMING_SNAKE_CASE_ = None					,  SCREAMING_SNAKE_CASE_ = None					,  **SCREAMING_SNAKE_CASE_					,  ):


   '''simple docstring'''




   super().__init__(**SCREAMING_SNAKE_CASE_)
   lowercase__  :   Union[str, Any]    		=      size if size is not None else {"""height""": 2_56, """width""": 2_56}
   lowercase__  :   int    		=      get_size_dict(SCREAMING_SNAKE_CASE_)
   lowercase__  :   Any    		=      crop_size if crop_size is not None else {"""height""": 2_24, """width""": 2_24}
   lowercase__  :   Optional[int]    		=      get_size_dict(SCREAMING_SNAKE_CASE_					,  param_name="""crop_size""")

   lowercase__  :   Union[str, Any]    		=      do_resize
   lowercase__  :   List[Any]    		=      size
   lowercase__  :   Any    		=      resample
   lowercase__  :   Any    		=      do_center_crop
   lowercase__  :   List[str]    		=      crop_size
   lowercase__  :   str    		=      do_rescale
   lowercase__  :   str    		=      rescale_factor
   lowercase__  :   Tuple    		=      do_normalize
   lowercase__  :   Union[str, Any]    		=      image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
   lowercase__  :   Optional[Any]    		=      image_std if image_std is not None else IMAGENET_STANDARD_STD


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_ = PIL.Image.BICUBIC					,  SCREAMING_SNAKE_CASE_ = None					,  **SCREAMING_SNAKE_CASE_					,  ):


   '''simple docstring'''




   lowercase__  :   Dict    		=      get_size_dict(SCREAMING_SNAKE_CASE_)
   if "height" not in size or "width" not in size:
     raise ValueError(f'The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}')
   return resize(
       SCREAMING_SNAKE_CASE_					,  size=(size["""height"""], size["""width"""])					,  resample=SCREAMING_SNAKE_CASE_					,  data_format=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					self					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_ = None					,  **SCREAMING_SNAKE_CASE_					,  ):


   '''simple docstring'''




   lowercase__  :   Union[str, Any]    		=      get_size_dict(SCREAMING_SNAKE_CASE_)
   if "height" not in size or "width" not in size:
     raise ValueError(f'The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}')
   return center_crop(SCREAMING_SNAKE_CASE_					,  size=(size["""height"""], size["""width"""])					,  data_format=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_)


 def      lowercase__     (					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      lowercase__     (					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      lowercase__     (					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_ = None					,  SCREAMING_SNAKE_CASE_ = ChannelDimension.FIRST					,  **SCREAMING_SNAKE_CASE_					,  ):


   '''simple docstring'''




   lowercase__  :   int    		=      do_resize if do_resize is not None else self.do_resize
   lowercase__  :   Dict    		=      resample if resample is not None else self.resample
   lowercase__  :   Tuple    		=      do_center_crop if do_center_crop is not None else self.do_center_crop
   lowercase__  :   Optional[Any]    		=      do_rescale if do_rescale is not None else self.do_rescale
   lowercase__  :   Optional[int]    		=      rescale_factor if rescale_factor is not None else self.rescale_factor
   lowercase__  :   int    		=      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__  :   Optional[int]    		=      image_std if image_std is not None else self.image_std

   lowercase__  :   Optional[int]    		=      size if size is not None else self.size
   lowercase__  :   Optional[int]    		=      get_size_dict(SCREAMING_SNAKE_CASE_)
   lowercase__  :   int    		=      crop_size if crop_size is not None else self.crop_size
   lowercase__  :   Tuple    		=      get_size_dict(SCREAMING_SNAKE_CASE_					,  param_name="""crop_size""")

   lowercase__  :   int    		=      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_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.""")

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

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

   if do_center_crop:
     lowercase__  :   Dict    		=      [self.center_crop(image=SCREAMING_SNAKE_CASE_					,  size=SCREAMING_SNAKE_CASE_) for image in images]

   if do_rescale:
     lowercase__  :   Optional[int]    		=      [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__  :   Any    		=      [to_channel_dimension_format(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_) for image in images]

   lowercase__  :   Tuple    		=      {"""pixel_values""": images}
   return BatchFeature(data=SCREAMING_SNAKE_CASE_					,  tensor_type=SCREAMING_SNAKE_CASE_)








from ..utils import DummyObject, requires_backends



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Any        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Any        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Union[str, Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     int        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Optional[Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Tuple        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     List[str]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Union[str, Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Optional[Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Dict        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Optional[Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     Optional[Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



class       _snake_case   (	metaclass=UpperCAmelCase_							):
 __lowerCAmelCase  :     List[Any]        =			['flax']


 def __init__(					self					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(self					,  ["""flax"""])


 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])



 @classmethod
 def      lowercase__     (					cls					,  *SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   requires_backends(cls					,  ["""flax"""])






