

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_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
	import PIL


A_			:					Optional[Any]    			=     logging.get_logger(__name__)

def 		UpperCamelCase   (lowercase_:					Dict   )	-> List[List[ImageInput]]:
	if isinstance(lowercase_       , (list, tuple)   ) and isinstance(videos[0]       , (list, tuple)   ) and is_valid_image(videos[0][0]   ):
		return videos

	elif isinstance(lowercase_       , (list, tuple)   ) and is_valid_image(videos[0]   ):
		return [videos]

	elif is_valid_image(lowercase_   ):
		return [[videos]]

	raise ValueError(f"""Could not make batched video from {videos}"""   )



class        _a		(__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Tuple    				=			['''pixel_values''']






					def __init__(					self       ,			A__ = True       ,			A__ = None       ,			A__ = PILImageResampling.BILINEAR       ,			A__ = True       ,			A__ = None       ,			A__ = True       ,			A__ = 1 / 255       ,			A__ = True       ,			A__ = None       ,			A__ = None       ,			**A__       ,			):
						super().__init__(**A__     )
						A__				:       Dict	  =						size if size is not None else {"""shortest_edge""": 224}
						A__				:       str	  =						get_size_dict(A__       ,			default_to_square=A__     )
						A__				:       Union[str, Any]	  =						crop_size if crop_size is not None else {"""height""": 224, """width""": 224}
						A__				:       Union[str, Any]	  =						get_size_dict(A__       ,			param_name="""crop_size"""     )

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






					def     __A     (					self       ,			A__       ,			A__       ,			A__ = PILImageResampling.BILINEAR       ,			A__ = None       ,			**A__       ,			):
						A__				:       List[str]	  =						get_size_dict(A__       ,			default_to_square=A__     )
						if "shortest_edge" in size:
							A__				:       str	  =						get_resize_output_image_size(A__       ,			size["""shortest_edge"""]       ,			default_to_square=A__     )
						elif "height" in size and "width" in size:
							A__				:       Union[str, Any]	  =						(size["""height"""], size["""width"""])
						else:
							raise ValueError(F"""Size must have 'height' and 'width' or 'shortest_edge' as keys. Got {size.keys()}"""     )
						return resize(A__       ,			size=A__       ,			resample=A__       ,			data_format=A__       ,			**A__     )






					def     __A     (					self       ,			A__       ,			A__       ,			A__ = None       ,			**A__       ,			):
						A__				:       str	  =						get_size_dict(A__     )
						if "height" not in size or "width" not in size:
							raise ValueError(F"""Size must have 'height' and 'width' as keys. Got {size.keys()}"""     )
						return center_crop(A__       ,			size=(size["""height"""], size["""width"""])       ,			data_format=A__       ,			**A__     )






					def     __A     (					self       ,			A__       ,			A__       ,			A__ = None       ,			**A__       ,			):
						return rescale(A__       ,			scale=A__       ,			data_format=A__       ,			**A__     )






					def     __A     (					self       ,			A__       ,			A__       ,			A__       ,			A__ = None       ,			**A__       ,			):
						return normalize(A__       ,			mean=A__       ,			std=A__       ,			data_format=A__       ,			**A__     )






					def     __A     (					self       ,			A__       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = None       ,			A__ = ChannelDimension.FIRST       ,			):
						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.
						A__				:       Any	  =						to_numpy_array(A__     )

						if do_resize:
							A__				:       str	  =						self.resize(image=A__       ,			size=A__       ,			resample=A__     )

						if do_center_crop:
							A__				:       List[str]	  =						self.center_crop(A__       ,			size=A__     )

						if do_rescale:
							A__				:       List[str]	  =						self.rescale(image=A__       ,			scale=A__     )

						if do_normalize:
							A__				:       List[str]	  =						self.normalize(image=A__       ,			mean=A__       ,			std=A__     )

						A__				:       List[Any]	  =						to_channel_dimension_format(A__       ,			A__     )
						return image






					def     __A     (					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__       ,			):
						A__				:       Any	  =						do_resize if do_resize is not None else self.do_resize
						A__				:       List[str]	  =						resample if resample is not None else self.resample
						A__				:       str	  =						do_center_crop if do_center_crop is not None else self.do_center_crop
						A__				:       List[str]	  =						do_rescale if do_rescale is not None else self.do_rescale
						A__				:       List[Any]	  =						rescale_factor if rescale_factor is not None else self.rescale_factor
						A__				:       Tuple	  =						do_normalize if do_normalize is not None else self.do_normalize
						A__				:       Optional[int]	  =						image_mean if image_mean is not None else self.image_mean
						A__				:       List[Any]	  =						image_std if image_std is not None else self.image_std

						A__				:       Dict	  =						size if size is not None else self.size
						A__				:       Dict	  =						get_size_dict(A__       ,			default_to_square=A__     )
						A__				:       Any	  =						crop_size if crop_size is not None else self.crop_size
						A__				:       str	  =						get_size_dict(A__       ,			param_name="""crop_size"""     )

						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."""     )

						A__				:       Optional[Any]	  =						make_batched(A__     )

						A__				:       Any	  =						[
						    [
						        self._preprocess_image(
						            image=A__       ,			do_resize=A__       ,			size=A__       ,			resample=A__       ,			do_center_crop=A__       ,			crop_size=A__       ,			do_rescale=A__       ,			rescale_factor=A__       ,			do_normalize=A__       ,			image_mean=A__       ,			image_std=A__       ,			data_format=A__       ,			)
						        for img in video
						    ]
						    for video in videos
						]

						A__				:       Tuple	  =						{"""pixel_values""": videos}
						return BatchFeature(data=A__       ,			tensor_type=A__     )






from ..utils import DummyObject, requires_backends



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[int]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  int    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  int    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[str]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[int]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Tuple    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  List[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Dict    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  str    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Any    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Union[str, Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Optional[Any]    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



class        _a		(metaclass=__magic_name__							):


					'''simple docstring'''






					UpperCAmelCase__:  Tuple    				=			['''sentencepiece''']






					def __init__(					self       ,			*A__       ,			**A__     ):
						requires_backends(self       ,			["""sentencepiece"""]     )



