import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding

class 						_SCREAMING_SNAKE_CASE				(  _lowercase				):






		"""simple docstring"""







		A_    			=   ['''image_processor''', '''tokenizer''']
		A_    			=   '''VideoMAEImageProcessor'''
		A_    			=   ('''CLIPTokenizer''', '''CLIPTokenizerFast''')



		def __init__(      self     :					int	,       __SCREAMING_SNAKE_CASE     :					Any=None	,       __SCREAMING_SNAKE_CASE     :					Dict=None	,       **__SCREAMING_SNAKE_CASE     :					int ):






					"""simple docstring"""
					_snake_case														=   None
					if "feature_extractor" in kwargs:
								warnings.warn(
								    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
								    " instead."	,       __SCREAMING_SNAKE_CASE	,       )
								_snake_case														=   kwargs.pop("feature_extractor" )

					_snake_case														=   image_processor if image_processor is not None else feature_extractor
					if image_processor is None:
								raise ValueError("You need to specify an `image_processor`." )
					if tokenizer is None:
								raise ValueError("You need to specify a `tokenizer`." )

					super().__init__(__SCREAMING_SNAKE_CASE	,       __SCREAMING_SNAKE_CASE )
					_snake_case														=   self.image_processor



		def __call__(      self     :					Dict	,       __SCREAMING_SNAKE_CASE     :					Tuple=None	,       __SCREAMING_SNAKE_CASE     :					Tuple=None	,       __SCREAMING_SNAKE_CASE     :					Dict=None	,       **__SCREAMING_SNAKE_CASE     :					Optional[int] ):






					"""simple docstring"""

					if text is None and videos is None:
								raise ValueError("You have to specify either text or videos. Both cannot be none." )

					if text is not None:
								_snake_case														=   self.tokenizer(__SCREAMING_SNAKE_CASE	,       return_tensors=__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )

					if videos is not None:
								_snake_case														=   self.image_processor(__SCREAMING_SNAKE_CASE	,       return_tensors=__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )

					if text is not None and videos is not None:
								_snake_case														=   image_features.pixel_values
								return encoding
					elif text is not None:
								return encoding
					else:
								return BatchEncoding(data=dict(**__SCREAMING_SNAKE_CASE )	,       tensor_type=__SCREAMING_SNAKE_CASE )



		def 					_a					(      self     :					Any	,       *__SCREAMING_SNAKE_CASE     :					Any	,       **__SCREAMING_SNAKE_CASE     :					Dict ):






					"""simple docstring"""
					return self.tokenizer.batch_decode(*__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )



		def 					_a					(      self     :					Dict	,       *__SCREAMING_SNAKE_CASE     :					List[str]	,       **__SCREAMING_SNAKE_CASE     :					Dict ):






					"""simple docstring"""
					return self.tokenizer.decode(*__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )



		@property
		def 					_a					(      self     :					Optional[Any] ):






					"""simple docstring"""
					return ["input_ids", "attention_mask", "position_ids", "pixel_values"]



		@property
		def 					_a					(      self     :					List[str] ):






					"""simple docstring"""
					warnings.warn(
					    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."	,       __SCREAMING_SNAKE_CASE	,       )
					return self.image_processor_class







		@property
		def 					_a					(      self     :					Tuple ):






					"""simple docstring"""
					warnings.warn(
					    "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."	,       __SCREAMING_SNAKE_CASE	,       )
					return self.image_processor


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 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, logging


_SCREAMING_SNAKE_CASE:    List[Any]     						=							logging.get_logger(__name__)

class 						_SCREAMING_SNAKE_CASE				(  _lowercase				):






		"""simple docstring"""







		A_    			=   ['''pixel_values''']



		def __init__(      self     :					Tuple	,       __SCREAMING_SNAKE_CASE     :					bool = True	,       __SCREAMING_SNAKE_CASE     :					Optional[Dict[str, int]] = None	,       __SCREAMING_SNAKE_CASE     :					PILImageResampling = PILImageResampling.BILINEAR	,       __SCREAMING_SNAKE_CASE     :					bool = True	,       __SCREAMING_SNAKE_CASE     :					Union[int, float] = 1 / 255	,       __SCREAMING_SNAKE_CASE     :					bool = True	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[float, List[float]]] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[float, List[float]]] = None	,       **__SCREAMING_SNAKE_CASE     :					str	,       ):






					"""simple docstring"""
					super().__init__(**__SCREAMING_SNAKE_CASE )
					_snake_case														=   size if size is not None else {"height": 224, "width": 224}
					_snake_case														=   get_size_dict(__SCREAMING_SNAKE_CASE )
					_snake_case														=   do_resize
					_snake_case														=   do_rescale
					_snake_case														=   do_normalize
					_snake_case														=   size
					_snake_case														=   resample
					_snake_case														=   rescale_factor
					_snake_case														=   image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
					_snake_case														=   image_std if image_std is not None else IMAGENET_STANDARD_STD



		def 					_a					(      self     :					int	,       __SCREAMING_SNAKE_CASE     :					np.ndarray	,       __SCREAMING_SNAKE_CASE     :					Dict[str, int]	,       __SCREAMING_SNAKE_CASE     :					PILImageResampling = PILImageResampling.BILINEAR	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[str, ChannelDimension]] = None	,       **__SCREAMING_SNAKE_CASE     :					Tuple	,       ):






					"""simple docstring"""
					_snake_case														=   get_size_dict(__SCREAMING_SNAKE_CASE )
					if "height" not in size or "width" not in size:
								raise ValueError(F'The `size` dictionary must contain the 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 					_a					(      self     :					Tuple	,       __SCREAMING_SNAKE_CASE     :					np.ndarray	,       __SCREAMING_SNAKE_CASE     :					float	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[str, ChannelDimension]] = None	,       **__SCREAMING_SNAKE_CASE     :					List[str] ):






					"""simple docstring"""
					return rescale(__SCREAMING_SNAKE_CASE	,       scale=__SCREAMING_SNAKE_CASE	,       data_format=__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )



		def 					_a					(      self     :					Optional[Any]	,       __SCREAMING_SNAKE_CASE     :					np.ndarray	,       __SCREAMING_SNAKE_CASE     :					Union[float, List[float]]	,       __SCREAMING_SNAKE_CASE     :					Union[float, List[float]]	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[str, ChannelDimension]] = None	,       **__SCREAMING_SNAKE_CASE     :					Optional[Any]	,       ):






					"""simple docstring"""
					return normalize(__SCREAMING_SNAKE_CASE	,       mean=__SCREAMING_SNAKE_CASE	,       std=__SCREAMING_SNAKE_CASE	,       data_format=__SCREAMING_SNAKE_CASE	,       **__SCREAMING_SNAKE_CASE )







		def 					_a					(      self     :					int	,       __SCREAMING_SNAKE_CASE     :					ImageInput	,       __SCREAMING_SNAKE_CASE     :					Optional[bool] = None	,       __SCREAMING_SNAKE_CASE     :					Dict[str, int] = None	,       __SCREAMING_SNAKE_CASE     :					PILImageResampling = None	,       __SCREAMING_SNAKE_CASE     :					Optional[bool] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[float] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[bool] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[float, List[float]]] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[float, List[float]]] = None	,       __SCREAMING_SNAKE_CASE     :					Optional[Union[str, TensorType]] = None	,       __SCREAMING_SNAKE_CASE     :					Union[str, ChannelDimension] = ChannelDimension.FIRST	,       **__SCREAMING_SNAKE_CASE     :					List[Any]	,       ):






					"""simple docstring"""
					_snake_case														=   do_resize if do_resize is not None else self.do_resize
					_snake_case														=   do_rescale if do_rescale is not None else self.do_rescale
					_snake_case														=   do_normalize if do_normalize is not None else self.do_normalize
					_snake_case														=   resample if resample is not None else self.resample
					_snake_case														=   rescale_factor if rescale_factor is not None else self.rescale_factor
					_snake_case														=   image_mean if image_mean is not None else self.image_mean
					_snake_case														=   image_std if image_std is not None else self.image_std

					_snake_case														=   size if size is not None else self.size
					_snake_case														=   get_size_dict(__SCREAMING_SNAKE_CASE )

					_snake_case														=   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:
								raise ValueError("Size must be specified if do_resize is True." )

					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(__SCREAMING_SNAKE_CASE ) for image in images]

					if do_resize:
								_snake_case														=   [self.resize(image=__SCREAMING_SNAKE_CASE	,       size=__SCREAMING_SNAKE_CASE	,       resample=__SCREAMING_SNAKE_CASE ) for image in images]

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

					if do_normalize:
								_snake_case														=   [self.normalize(image=__SCREAMING_SNAKE_CASE	,       mean=__SCREAMING_SNAKE_CASE	,       std=__SCREAMING_SNAKE_CASE ) for image in images]

					_snake_case														=   [to_channel_dimension_format(__SCREAMING_SNAKE_CASE	,       __SCREAMING_SNAKE_CASE ) for image in images]

					_snake_case														=   {"pixel_values": images}
					return BatchFeature(data=__SCREAMING_SNAKE_CASE	,       tensor_type=__SCREAMING_SNAKE_CASE )

