


"""simple docstring"""







from typing import List, Optional, Union

import numpy as np
import PIL.Image

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


__lowercase    =				logging.get_logger(__name__)






class 						_A  (  _a  ):







    """simple docstring"""




    UpperCAmelCase	:							Optional[Any]     =	["""pixel_values"""]






    def __init__( self    :   List[str]    ,			__UpperCAmelCase    :   bool = True    ,			__UpperCAmelCase    :   int = 32    ,			__UpperCAmelCase    :   List[str]=PILImageResampling.BILINEAR    ,			__UpperCAmelCase    :   bool = True    ,			**__UpperCAmelCase    :   Tuple    ,			):
      a						:		List[Any]											=      do_resize
      a						:		str											=      do_rescale
      a						:		Optional[Any]											=      size_divisor
      a						:		Any											=      resample
      super().__init__(**__UpperCAmelCase)






    def      __snake_case							( self    :   List[str]    ,			__UpperCAmelCase    :   np.ndarray    ,			__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Optional[ChannelDimension] = None    ,			**__UpperCAmelCase    :   List[str]):
      a							,		a						:		Optional[int]											=      get_image_size(__UpperCAmelCase)
      # Rounds the height and width down to the closest multiple of size_divisor
      a						:		str											=      height // size_divisor * size_divisor
      a						:		int											=      width // size_divisor * size_divisor
      a						:		str											=      resize(__UpperCAmelCase    ,			(new_h, new_w)    ,			resample=__UpperCAmelCase    ,			data_format=__UpperCAmelCase    ,			**__UpperCAmelCase)
      return image






    def      __snake_case							( self    :   str    ,			__UpperCAmelCase    :   np.ndarray    ,			__UpperCAmelCase    :   float    ,			__UpperCAmelCase    :   Optional[ChannelDimension] = None    ,			**__UpperCAmelCase    :   str):
      return rescale(image=__UpperCAmelCase    ,			scale=__UpperCAmelCase    ,			data_format=__UpperCAmelCase    ,			**__UpperCAmelCase)






    def      __snake_case							( self    :   Optional[Any]    ,			__UpperCAmelCase    :   Union["PIL.Image.Image", TensorType, List["PIL.Image.Image"], List[TensorType]]    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			__UpperCAmelCase    :   Optional[int] = None    ,			__UpperCAmelCase    :   Optional[int]=None    ,			__UpperCAmelCase    :   Optional[bool] = None    ,			__UpperCAmelCase    :   Optional[Union[TensorType, str]] = None    ,			__UpperCAmelCase    :   ChannelDimension = ChannelDimension.FIRST    ,			**__UpperCAmelCase    :   List[str]    ,			):
      a						:		Dict											=      do_resize if do_resize is not None else self.do_resize
      a						:		List[Any]											=      do_rescale if do_rescale is not None else self.do_rescale
      a						:		List[str]											=      size_divisor if size_divisor is not None else self.size_divisor
      a						:		Tuple											=      resample if resample is not None else self.resample

      if do_resize and size_divisor is None:
        raise ValueError("size_divisor is required for resizing")

      a						:		Tuple											=      make_list_of_images(__UpperCAmelCase)

      if not valid_images(__UpperCAmelCase):
        raise ValueError("Invalid image(s)")

      # All transformations expect numpy arrays.
      a						:		Union[str, Any]											=      [to_numpy_array(__UpperCAmelCase) for img in images]

      if do_resize:
        a						:		List[Any]											=      [self.resize(__UpperCAmelCase    ,			size_divisor=__UpperCAmelCase    ,			resample=__UpperCAmelCase) for image in images]

      if do_rescale:
        a						:		Dict											=      [self.rescale(__UpperCAmelCase    ,			scale=1 / 255) for image in images]

      a						:		List[str]											=      [to_channel_dimension_format(__UpperCAmelCase    ,			__UpperCAmelCase) for image in images]

      a						:		Dict											=      {"pixel_values": images}
      return BatchFeature(data=__UpperCAmelCase    ,			tensor_type=__UpperCAmelCase)










"""simple docstring"""







__lowercase    =				frozenset(
    [
        """prompt""",
        """height""",
        """width""",
        """guidance_scale""",
        """negative_prompt""",
        """prompt_embeds""",
        """negative_prompt_embeds""",
        """cross_attention_kwargs""",
    ]
)

__lowercase    =				frozenset(["""prompt""", """negative_prompt"""])

__lowercase    =				frozenset([])

__lowercase    =				frozenset(["""image"""])

__lowercase    =				frozenset(
    [
        """image""",
        """height""",
        """width""",
        """guidance_scale""",
    ]
)

__lowercase    =				frozenset(["""image"""])

__lowercase    =				frozenset(
    [
        """prompt""",
        """image""",
        """height""",
        """width""",
        """guidance_scale""",
        """negative_prompt""",
        """prompt_embeds""",
        """negative_prompt_embeds""",
    ]
)

__lowercase    =				frozenset(["""prompt""", """image""", """negative_prompt"""])

__lowercase    =				frozenset(
    [
        # Text guided image variation with an image mask
        """prompt""",
        """image""",
        """mask_image""",
        """height""",
        """width""",
        """guidance_scale""",
        """negative_prompt""",
        """prompt_embeds""",
        """negative_prompt_embeds""",
    ]
)

__lowercase    =				frozenset(["""prompt""", """image""", """mask_image""", """negative_prompt"""])

__lowercase    =				frozenset(
    [
        # image variation with an image mask
        """image""",
        """mask_image""",
        """height""",
        """width""",
        """guidance_scale""",
    ]
)

__lowercase    =				frozenset(["""image""", """mask_image"""])

__lowercase    =				frozenset(
    [
        """example_image""",
        """image""",
        """mask_image""",
        """height""",
        """width""",
        """guidance_scale""",
    ]
)

__lowercase    =				frozenset(["""example_image""", """image""", """mask_image"""])

__lowercase    =				frozenset(["""class_labels"""])

__lowercase    =				frozenset(["""class_labels"""])

__lowercase    =				frozenset(["""batch_size"""])

__lowercase    =				frozenset([])

__lowercase    =				frozenset(["""batch_size"""])

__lowercase    =				frozenset([])

__lowercase    =				frozenset(
    [
        """prompt""",
        """audio_length_in_s""",
        """guidance_scale""",
        """negative_prompt""",
        """prompt_embeds""",
        """negative_prompt_embeds""",
        """cross_attention_kwargs""",
    ]
)

__lowercase    =				frozenset(["""prompt""", """negative_prompt"""])
__lowercase    =				frozenset(["""input_tokens"""])

__lowercase    =				frozenset(["""input_tokens"""])






