
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


UpperCamelCase_     			=       logging.get_logger(__name__)


class   a_  (A__    ):
       __lowerCAmelCase    :				str    =      ['''pixel_values''']




       def __init__(     self   ,   snake_case_ = True   ,   snake_case_ = None   ,   snake_case_ = PIL.Image.NEAREST   ,   snake_case_ = False   ,   snake_case_ = None   ,   snake_case_ = 1 / 2_5_5   ,   snake_case_ = False   ,   snake_case_ = True   ,   snake_case_ = True   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = True   ,   **snake_case_   ,   ):
         super().__init__(**snake_case_  )
         _lowerCAmelCase       :  List[str]   				=					size if size is not None else {"height": 3_4_6, "width": 3_4_6}
         _lowerCAmelCase       :  Dict   				=					get_size_dict(snake_case_  )
         _lowerCAmelCase       :  Optional[int]   				=					crop_size if crop_size is not None else {"height": 2_8_9, "width": 2_8_9}
         _lowerCAmelCase       :  Union[str, Any]   				=					get_size_dict(snake_case_   ,   param_name="""crop_size"""  )

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




       def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_   ,   snake_case_ = PIL.Image.NEAREST   ,   snake_case_ = None   ,   **snake_case_   ,   ):
         _lowerCAmelCase       :  Optional[int]   				=					get_size_dict(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(
             snake_case_   ,   size=(size["""height"""], size["""width"""])   ,   resample=snake_case_   ,   data_format=snake_case_   ,   **snake_case_  )




       def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_   ,   snake_case_ = None   ,   **snake_case_   ,   ):
         _lowerCAmelCase       :  List[str]   				=					get_size_dict(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(snake_case_   ,   size=(size["""height"""], size["""width"""])   ,   data_format=snake_case_   ,   **snake_case_  )




       def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_   ,   snake_case_ = True   ,   snake_case_ = None   ,   **snake_case_   ,   ):






         if offset:
           _lowerCAmelCase       :  Optional[Any]   				=					(image - 1_2_7.5) * scale
           if data_format is not None:
             _lowerCAmelCase       :  int   				=					to_channel_dimension_format(snake_case_   ,   snake_case_  )
           _lowerCAmelCase       :  Any   				=					rescaled_image.astype(np.floataa  )
         else:
           _lowerCAmelCase       :  str   				=					rescale(snake_case_   ,   scale=snake_case_   ,   data_format=snake_case_   ,   **snake_case_  )
         return rescaled_image




       def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_   ,   snake_case_   ,   snake_case_ = None   ,   **snake_case_   ,   ):
         return normalize(snake_case_   ,   mean=snake_case_   ,   std=snake_case_   ,   data_format=snake_case_   ,   **snake_case_  )







       def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_=None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = None   ,   snake_case_ = ChannelDimension.FIRST   ,   **snake_case_   ,   ):
         _lowerCAmelCase       :  Optional[Any]   				=					do_resize if do_resize is not None else self.do_resize
         _lowerCAmelCase       :  List[str]   				=					resample if resample is not None else self.resample
         _lowerCAmelCase       :  str   				=					do_center_crop if do_center_crop is not None else self.do_center_crop
         _lowerCAmelCase       :  Any   				=					do_rescale if do_rescale is not None else self.do_rescale
         _lowerCAmelCase       :  int   				=					rescale_factor if rescale_factor is not None else self.rescale_factor
         _lowerCAmelCase       :  Tuple   				=					rescale_offset if rescale_offset is not None else self.rescale_offset
         _lowerCAmelCase       :  Any   				=					do_normalize if do_normalize is not None else self.do_normalize
         _lowerCAmelCase       :  Any   				=					image_mean if image_mean is not None else self.image_mean
         _lowerCAmelCase       :  List[Any]   				=					image_std if image_std is not None else self.image_std
         _lowerCAmelCase       :  int   				=					include_top if include_top is not None else self.include_top

         _lowerCAmelCase       :  Optional[int]   				=					size if size is not None else self.size
         _lowerCAmelCase       :  int   				=					get_size_dict(snake_case_  )
         _lowerCAmelCase       :  Optional[int]   				=					crop_size if crop_size is not None else self.crop_size
         _lowerCAmelCase       :  Dict   				=					get_size_dict(snake_case_   ,   param_name="""crop_size"""  )

         _lowerCAmelCase       :  int   				=					make_list_of_images(snake_case_  )

         if not valid_images(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.
         _lowerCAmelCase       :  List[str]   				=					[to_numpy_array(snake_case_  ) for image in images]

         if do_resize:
           _lowerCAmelCase       :  int   				=					[self.resize(image=snake_case_   ,   size=snake_case_   ,   resample=snake_case_  ) for image in images]

         if do_center_crop:
           _lowerCAmelCase       :  List[Any]   				=					[self.center_crop(image=snake_case_   ,   size=snake_case_  ) for image in images]

         if do_rescale:
           _lowerCAmelCase       :  str   				=					[self.rescale(image=snake_case_   ,   scale=snake_case_   ,   offset=snake_case_  ) for image in images]

         if do_normalize:
           _lowerCAmelCase       :  Any   				=					[self.normalize(image=snake_case_   ,   mean=snake_case_   ,   std=snake_case_  ) for image in images]

         if include_top:
           _lowerCAmelCase       :  str   				=					[self.normalize(image=snake_case_   ,   mean=[0, 0, 0]   ,   std=snake_case_  ) for image in images]

         _lowerCAmelCase       :  List[Any]   				=					[to_channel_dimension_format(snake_case_   ,   snake_case_  ) for image in images]

         _lowerCAmelCase       :  List[Any]   				=					{"pixel_values": images}
         return BatchFeature(data=snake_case_   ,   tensor_type=snake_case_  )




'''simple docstring'''

from ..utils import DummyObject, requires_backends


class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				int    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[str]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Any    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Dict    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Tuple    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[int]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[int]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Dict    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[str]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Dict    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[str]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Any    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Any    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[str]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Dict    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Dict    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				int    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[int]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				int    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Any    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				str    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				int    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[int]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				List[str]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Union[str, Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Any    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )



class   a_  (metaclass=_a    ):
       __lowerCAmelCase    :				Optional[Any]    =      ["""tokenizers"""]




       def __init__(     self   ,   *snake_case_   ,   **snake_case_  ):
         requires_backends(self   ,   ["""tokenizers"""]  )


