




'''simple docstring'''

from typing import Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format
from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_images
from ...utils import TensorType, logging


a       :						Any								=		logging.get_logger(__name__)



class 		SCREAMING_SNAKE_CASE__  (			_UpperCamelCase	):
			__SCREAMING_SNAKE_CASE    =			["""pixel_values"""]





			def __init__(      self						:    str      ,		a_						:    bool = True      ,		a_						:    Union[int, float] = 1 / 255      ,		a_						:    bool = True      ,		a_						:    int = 8      ,		**a_						:    Any      ,		):



						"""simple docstring"""




						super().__init__(**a_							)

						__snake_case			=		do_rescale
						__snake_case			=		rescale_factor
						__snake_case			=		do_pad
						__snake_case			=		pad_size





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



						"""simple docstring"""




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





			def 							A (      self						:    Optional[int]      ,		a_						:    np.ndarray      ,		a_						:    int      ,		a_						:    Optional[Union[str, ChannelDimension]] = None							):



						"""simple docstring"""




						__snake_case		,     __snake_case			=		get_image_size(a_							)
						__snake_case			=		(old_height // size + 1) * size - old_height
						__snake_case			=		(old_width // size + 1) * size - old_width

						return pad(a_      ,		((0, pad_height), (0, pad_width))      ,		mode="symmetric"      ,		data_format=a_							)






			def 							A (      self						:    int      ,		a_						:    ImageInput      ,		a_						:    Optional[bool] = None      ,		a_						:    Optional[float] = None      ,		a_						:    Optional[bool] = None      ,		a_						:    Optional[int] = None      ,		a_						:    Optional[Union[str, TensorType]] = None      ,		a_						:    Union[str, ChannelDimension] = ChannelDimension.FIRST      ,		**a_						:    str      ,		):



						"""simple docstring"""




						__snake_case			=		do_rescale if do_rescale is not None else self.do_rescale
						__snake_case			=		rescale_factor if rescale_factor is not None else self.rescale_factor
						__snake_case			=		do_pad if do_pad is not None else self.do_pad
						__snake_case			=		pad_size if pad_size is not None else self.pad_size

						__snake_case			=		make_list_of_images(a_							)

						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_rescale and rescale_factor is None:
									raise ValueError("Rescale factor must be specified if do_rescale is True."							)

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

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

						if do_pad:
									__snake_case			=		[self.pad(a_      ,		size=a_							) for image in images]

						__snake_case			=		[to_channel_dimension_format(a_      ,		a_							) for image in images]

						__snake_case			=		{"pixel_values": images}
						return BatchFeature(data=a_      ,		tensor_type=a_							)













"""simple docstring"""
from ..utils import DummyObject, requires_backends



class        UpperCamelCase__ (				metaclass=a_):







    """simple docstring"""
    __UpperCAmelCase           = ["""flax""", """transformers"""]







    def __init__(		self :	List[Any]				,    *UpperCamelCase_ :	str				,    **UpperCamelCase_ :	Any ):





           '''simple docstring'''

           requires_backends(self				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	Optional[int]				,    *UpperCamelCase_ :	Tuple				,    **UpperCamelCase_ :	List[Any] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	str				,    *UpperCamelCase_ :	Optional[Any]				,    **UpperCamelCase_ :	Dict ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )



class        UpperCamelCase__ (				metaclass=a_):







    """simple docstring"""
    __UpperCAmelCase           = ["""flax""", """transformers"""]







    def __init__(		self :	List[Any]				,    *UpperCamelCase_ :	str				,    **UpperCamelCase_ :	str ):





           '''simple docstring'''

           requires_backends(self				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	Optional[int]				,    *UpperCamelCase_ :	Optional[int]				,    **UpperCamelCase_ :	List[str] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	Tuple				,    *UpperCamelCase_ :	List[str]				,    **UpperCamelCase_ :	Optional[Any] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )



class        UpperCamelCase__ (				metaclass=a_):







    """simple docstring"""
    __UpperCAmelCase           = ["""flax""", """transformers"""]







    def __init__(		self :	Optional[int]				,    *UpperCamelCase_ :	List[Any]				,    **UpperCamelCase_ :	List[str] ):





           '''simple docstring'''

           requires_backends(self				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	str				,    *UpperCamelCase_ :	List[str]				,    **UpperCamelCase_ :	Tuple ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	Tuple				,    *UpperCamelCase_ :	Any				,    **UpperCamelCase_ :	List[str] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )



class        UpperCamelCase__ (				metaclass=a_):







    """simple docstring"""
    __UpperCAmelCase           = ["""flax""", """transformers"""]







    def __init__(		self :	Optional[Any]				,    *UpperCamelCase_ :	Optional[Any]				,    **UpperCamelCase_ :	Dict ):





           '''simple docstring'''

           requires_backends(self				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	str				,    *UpperCamelCase_ :	Dict				,    **UpperCamelCase_ :	List[str] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )







    @classmethod
    def 				a__			(		cls :	str				,    *UpperCamelCase_ :	Optional[Any]				,    **UpperCamelCase_ :	Union[str, Any] ):





           '''simple docstring'''

           requires_backends(cls				,    ['flax', 'transformers'] )