code: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  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
  
  
  A_			  =    logging.get_logger(__name__)
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    Dict     	=			["pixel_values"]
    def __init__(      self:		int				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		Dict[str, int] = None				,			UpperCamelCase_:		PILImageResampling = PIL.Image.NEAREST				,			UpperCamelCase_:		bool = False				,			UpperCamelCase_:		Dict[str, int] = None				,			UpperCamelCase_:		Union[int, float] = 1 / 255				,			UpperCamelCase_:		bool = False				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		Optional[Union[float, List[float]]] = None				,			UpperCamelCase_:		Optional[Union[float, List[float]]] = None				,			UpperCamelCase_:		bool = True				,			**UpperCamelCase_:		List[str]				,			):
       super().__init__(**UpperCamelCase_					)
       UpperCamelCase_     =size if size is not None else {"height": 346, "width": 346}
       UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
       UpperCamelCase_     =crop_size if crop_size is not None else {"height": 289, "width": 289}
       UpperCamelCase_     =get_size_dict(UpperCamelCase_				,			param_name="crop_size"					)
  
       UpperCamelCase_     =do_resize
       UpperCamelCase_     =size
       UpperCamelCase_     =resample
       UpperCamelCase_     =do_center_crop
       UpperCamelCase_     =crop_size
       UpperCamelCase_     =do_rescale
       UpperCamelCase_     =rescale_factor
       UpperCamelCase_     =rescale_offset
       UpperCamelCase_     =do_normalize
       UpperCamelCase_     =image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
       UpperCamelCase_     =image_std if image_std is not None else IMAGENET_STANDARD_STD
       UpperCamelCase_     =include_top
    def 					UpperCamelCase__   (      self:		List[Any]				,			UpperCamelCase_:		np.ndarray				,			UpperCamelCase_:		Dict[str, int]				,			UpperCamelCase_:		PILImageResampling = PIL.Image.NEAREST				,			UpperCamelCase_:		Optional[Union[str, ChannelDimension]] = None				,			**UpperCamelCase_:		Optional[int]				,			):
       UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
       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(
           UpperCamelCase_				,			size=(size["height"], size["width"])				,			resample=UpperCamelCase_				,			data_format=UpperCamelCase_				,			**UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Tuple				,			UpperCamelCase_:		np.ndarray				,			UpperCamelCase_:		Dict[str, int]				,			UpperCamelCase_:		Optional[Union[str, ChannelDimension]] = None				,			**UpperCamelCase_:		List[str]				,			):
       UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
       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(UpperCamelCase_				,			size=(size["height"], size["width"])				,			data_format=UpperCamelCase_				,			**UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		List[str]				,			UpperCamelCase_:		np.ndarray				,			UpperCamelCase_:		Union[int, float]				,			UpperCamelCase_:		bool = True				,			UpperCamelCase_:		Optional[Union[str, ChannelDimension]] = None				,			**UpperCamelCase_:		Optional[Any]				,			):
       if offset:
          UpperCamelCase_     =(image - 127.5) * scale
          if data_format is not None:
             UpperCamelCase_     =to_channel_dimension_format(UpperCamelCase_				,			UpperCamelCase_					)
          UpperCamelCase_     =rescaled_image.astype(np.floataa					)
       else:
          UpperCamelCase_     =rescale(UpperCamelCase_				,			scale=UpperCamelCase_				,			data_format=UpperCamelCase_				,			**UpperCamelCase_					)
       return rescaled_image
    def 					UpperCamelCase__   (      self:		int				,			UpperCamelCase_:		np.ndarray				,			UpperCamelCase_:		Union[float, List[float]]				,			UpperCamelCase_:		Union[float, List[float]]				,			UpperCamelCase_:		Optional[Union[str, ChannelDimension]] = None				,			**UpperCamelCase_:		Optional[Any]				,			):
       return normalize(UpperCamelCase_				,			mean=UpperCamelCase_				,			std=UpperCamelCase_				,			data_format=UpperCamelCase_				,			**UpperCamelCase_					)
  
  
  
  
  
    def 					UpperCamelCase__   (      self:		Optional[int]				,			UpperCamelCase_:		ImageInput				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		Dict[str, int] = None				,			UpperCamelCase_:		str=None				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		Dict[str, int] = None				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		float = None				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		Optional[Union[float, List[float]]] = None				,			UpperCamelCase_:		Optional[Union[float, List[float]]] = None				,			UpperCamelCase_:		bool = None				,			UpperCamelCase_:		Optional[Union[str, TensorType]] = None				,			UpperCamelCase_:		ChannelDimension = ChannelDimension.FIRST				,			**UpperCamelCase_:		Any				,			):
       UpperCamelCase_     =do_resize if do_resize is not None else self.do_resize
       UpperCamelCase_     =resample if resample is not None else self.resample
       UpperCamelCase_     =do_center_crop if do_center_crop is not None else self.do_center_crop
       UpperCamelCase_     =do_rescale if do_rescale is not None else self.do_rescale
       UpperCamelCase_     =rescale_factor if rescale_factor is not None else self.rescale_factor
       UpperCamelCase_     =rescale_offset if rescale_offset is not None else self.rescale_offset
       UpperCamelCase_     =do_normalize if do_normalize is not None else self.do_normalize
       UpperCamelCase_     =image_mean if image_mean is not None else self.image_mean
       UpperCamelCase_     =image_std if image_std is not None else self.image_std
       UpperCamelCase_     =include_top if include_top is not None else self.include_top
  
       UpperCamelCase_     =size if size is not None else self.size
       UpperCamelCase_     =get_size_dict(UpperCamelCase_					)
       UpperCamelCase_     =crop_size if crop_size is not None else self.crop_size
       UpperCamelCase_     =get_size_dict(UpperCamelCase_				,			param_name="crop_size"					)
  
       UpperCamelCase_     =make_list_of_images(UpperCamelCase_					)
  
       if not valid_images(UpperCamelCase_					):
          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.
       UpperCamelCase_     =[to_numpy_array(UpperCamelCase_					) for image in images]
  
       if do_resize:
          UpperCamelCase_     =[self.resize(image=UpperCamelCase_				,			size=UpperCamelCase_				,			resample=UpperCamelCase_					) for image in images]
  
       if do_center_crop:
          UpperCamelCase_     =[self.center_crop(image=UpperCamelCase_				,			size=UpperCamelCase_					) for image in images]
  
       if do_rescale:
          UpperCamelCase_     =[self.rescale(image=UpperCamelCase_				,			scale=UpperCamelCase_				,			offset=UpperCamelCase_					) for image in images]
  
       if do_normalize:
          UpperCamelCase_     =[self.normalize(image=UpperCamelCase_				,			mean=UpperCamelCase_				,			std=UpperCamelCase_					) for image in images]
  
       if include_top:
          UpperCamelCase_     =[self.normalize(image=UpperCamelCase_				,			mean=[0, 0, 0]				,			std=UpperCamelCase_					) for image in images]
  
       UpperCamelCase_     =[to_channel_dimension_format(UpperCamelCase_				,			UpperCamelCase_					) for image in images]
  
       UpperCamelCase_     ={"pixel_values": images}
       return BatchFeature(data=UpperCamelCase_				,			tensor_type=UpperCamelCase_					)
  
style_context: 
  
  
  
  
  
  
  """simple docstring"""
  
  
  
  
  
  
  import warnings
  
  from ...processing_utils import ProcessorMixin
  from ...tokenization_utils_base import BatchEncoding
  class 						__lowerCAmelCase   (			UpperCAmelCase       ):
  
  
  
  
  
  
  
    '''simple docstring'''
  
  
    __lowerCamelCase       :    Optional[Any]     	=			["image_processor", "tokenizer"]
    __lowerCamelCase       :    List[str]     	=			"VideoMAEImageProcessor"
    __lowerCamelCase       :    Dict     	=			("CLIPTokenizer", "CLIPTokenizerFast")
    def __init__(      self:		str				,			UpperCamelCase_:		Dict=None				,			UpperCamelCase_:		str=None				,			**UpperCamelCase_:		str					):
       UpperCamelCase_     =None
       if "feature_extractor" in kwargs:
          warnings.warn(
              "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
              " instead."				,			UpperCamelCase_				,			)
          UpperCamelCase_     =kwargs.pop("feature_extractor"					)
  
       UpperCamelCase_     =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__(UpperCamelCase_				,			UpperCamelCase_					)
       UpperCamelCase_     =self.image_processor
    def __call__(      self:		Tuple				,			UpperCamelCase_:		str=None				,			UpperCamelCase_:		str=None				,			UpperCamelCase_:		Optional[Any]=None				,			**UpperCamelCase_:		int					):
  
       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:
          UpperCamelCase_     =self.tokenizer(UpperCamelCase_				,			return_tensors=UpperCamelCase_				,			**UpperCamelCase_					)
  
       if videos is not None:
          UpperCamelCase_     =self.image_processor(UpperCamelCase_				,			return_tensors=UpperCamelCase_				,			**UpperCamelCase_					)
  
       if text is not None and videos is not None:
          UpperCamelCase_     =image_features.pixel_values
          return encoding
       elif text is not None:
          return encoding
       else:
          return BatchEncoding(data=dict(**UpperCamelCase_					)				,			tensor_type=UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Any				,			*UpperCamelCase_:		List[str]				,			**UpperCamelCase_:		Optional[int]					):
       return self.tokenizer.batch_decode(*UpperCamelCase_				,			**UpperCamelCase_					)
    def 					UpperCamelCase__   (      self:		Optional[Any]				,			*UpperCamelCase_:		List[str]				,			**UpperCamelCase_:		Tuple					):
       return self.tokenizer.decode(*UpperCamelCase_				,			**UpperCamelCase_					)
    @property
    def 					UpperCamelCase__   (      self:		List[Any]					):
       return ["input_ids", "attention_mask", "position_ids", "pixel_values"]
    @property
    def 					UpperCamelCase__   (      self:		str					):
       warnings.warn(
           "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."				,			UpperCamelCase_				,			)
       return self.image_processor_class
  
  
  
  
  
    @property
    def 					UpperCamelCase__   (      self:		Optional[Any]					):
       warnings.warn(
           "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."				,			UpperCamelCase_				,			)
       return self.image_processor
  