



"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


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

__snake_case				:  Optional[Any] =       {
    'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json',
    # See all PEGASUS models at https://huggingface.co/models?filter=pegasus
}



class      A__  (    __snake_case				):




	'''simple docstring'''





	SCREAMING_SNAKE_CASE        =      "pegasus"
	SCREAMING_SNAKE_CASE        =      ["past_key_values"]
	SCREAMING_SNAKE_CASE        =      {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}

	def __init__(	self:						int			,     _SCREAMING_SNAKE_CASE:						Optional[int]=5_0265			,     _SCREAMING_SNAKE_CASE:						List[Any]=1024			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=12			,     _SCREAMING_SNAKE_CASE:						List[str]=4096			,     _SCREAMING_SNAKE_CASE:						List[Any]=16			,     _SCREAMING_SNAKE_CASE:						Tuple=12			,     _SCREAMING_SNAKE_CASE:						Tuple=4096			,     _SCREAMING_SNAKE_CASE:						int=16			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=0.0			,     _SCREAMING_SNAKE_CASE:						Tuple=0.0			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=True			,     _SCREAMING_SNAKE_CASE:						List[str]=True			,     _SCREAMING_SNAKE_CASE:						Tuple="gelu"			,     _SCREAMING_SNAKE_CASE:						Tuple=1024			,     _SCREAMING_SNAKE_CASE:						Any=0.1			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=0.0			,     _SCREAMING_SNAKE_CASE:						str=0.0			,     _SCREAMING_SNAKE_CASE:						Dict=0.02			,     _SCREAMING_SNAKE_CASE:						List[Any]=0			,     _SCREAMING_SNAKE_CASE:						int=False			,     _SCREAMING_SNAKE_CASE:						Optional[int]=0			,     _SCREAMING_SNAKE_CASE:						Optional[Any]=1			,     _SCREAMING_SNAKE_CASE:						int=1			,     **_SCREAMING_SNAKE_CASE:						Optional[Any]			,     )							->			Any:

				"""simple docstring"""

				__lowerCAmelCase :    List[str]				=			vocab_size
				__lowerCAmelCase :    List[Any]				=			max_position_embeddings
				__lowerCAmelCase :    Union[str, Any]				=			d_model
				__lowerCAmelCase :    Union[str, Any]				=			encoder_ffn_dim
				__lowerCAmelCase :    Union[str, Any]				=			encoder_layers
				__lowerCAmelCase :    int				=			encoder_attention_heads
				__lowerCAmelCase :    List[Any]				=			decoder_ffn_dim
				__lowerCAmelCase :    Optional[int]				=			decoder_layers
				__lowerCAmelCase :    Tuple				=			decoder_attention_heads
				__lowerCAmelCase :    List[str]				=			dropout
				__lowerCAmelCase :    Tuple				=			attention_dropout
				__lowerCAmelCase :    Union[str, Any]				=			activation_dropout
				__lowerCAmelCase :    int				=			activation_function
				__lowerCAmelCase :    Union[str, Any]				=			init_std
				__lowerCAmelCase :    Any				=			encoder_layerdrop
				__lowerCAmelCase :    int				=			decoder_layerdrop
				__lowerCAmelCase :    Tuple				=			use_cache
				__lowerCAmelCase :    Dict				=			encoder_layers
				__lowerCAmelCase :    List[str]				=			scale_embedding  # scale factor will be sqrt(d_model) if True
				super().__init__(
				    pad_token_id=A__			,     eos_token_id=A__			,     is_encoder_decoder=A__			,     decoder_start_token_id=A__			,     forced_eos_token_id=A__			,     **A__			,     )

	@property
	def 				_SCREAMING_SNAKE_CASE  (	self:						Optional[Any])							->			str:

				"""simple docstring"""

				return self.encoder_attention_heads







	@property
	def 				_SCREAMING_SNAKE_CASE  (	self:						Any)							->			str:

				"""simple docstring"""

				return self.d_model







from typing import Dict, List, Optional, Union

import numpy as np

from transformers.utils import is_vision_available
from transformers.utils.generic import TensorType

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 logging


if is_vision_available():
	import PIL

_UpperCamelCase			:	Union[str, Any]								=logging.get_logger(__name__)



def  a__ (__lowercase							:str   )		-> 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 						UpperCAmelCase__ (							__snake_case							):
		__snake_case      :       Optional[int]     =   ["pixel_values"]







		def __init__(					self       ,A__ = True       ,A__ = None       ,A__ = PILImageResampling.BILINEAR       ,A__ = True       ,A__ = None       ,A__ = True       ,A__ = 1 / 255       ,A__ = True       ,A__ = True       ,A__ = None       ,A__ = None       ,**A__       ,):
						super().__init__(**A__		)
						_A	:				Tuple   =      size if size is not None else {'''shortest_edge''': 256}
						_A	:				str   =      get_size_dict(A__       ,default_to_square=A__		)
						_A	:				str   =      crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
						_A	:				str   =      get_size_dict(A__       ,param_name='''crop_size'''		)

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







		def  A__      (					self       ,A__       ,A__       ,A__ = PILImageResampling.BILINEAR       ,A__ = None       ,**A__       ,):
						_A	:				str   =      get_size_dict(A__       ,default_to_square=A__		)
						if "shortest_edge" in size:
										_A	:				Optional[Any]   =      get_resize_output_image_size(A__       ,size['''shortest_edge''']       ,default_to_square=A__		)
						elif "height" in size and "width" in size:
										_A	:				str   =      (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	:				Optional[int]   =      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__ = True       ,A__ = None       ,**A__       ,):
						_A	:				Any   =      image.astype(np.floataa		)
						if offset:
										_A	:				List[str]   =      image - (scale / 2)
						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__ = 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.'''		)

						if offset and not do_rescale:
										raise ValueError('''For offset, do_rescale must also be set to True.'''		)

						# All transformations expect numpy arrays.
						_A	:				Dict   =      to_numpy_array(A__		)

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

						if do_center_crop:
										_A	:				str   =      self.center_crop(A__       ,size=A__		)

						if do_rescale:
										_A	:				Optional[int]   =      self.rescale(image=A__       ,scale=A__       ,offset=A__		)

						if do_normalize:
										_A	:				Dict   =      self.normalize(image=A__       ,mean=A__       ,std=A__		)

						_A	:				Union[str, 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__ = None       ,A__ = ChannelDimension.FIRST       ,**A__       ,):
						_A	:				Optional[int]   =      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	:				Union[str, Any]   =      do_center_crop if do_center_crop is not None else self.do_center_crop
						_A	:				Tuple   =      do_rescale if do_rescale is not None else self.do_rescale
						_A	:				List[str]   =      rescale_factor if rescale_factor is not None else self.rescale_factor
						_A	:				List[str]   =      offset if offset is not None else self.offset
						_A	:				Optional[int]   =      do_normalize if do_normalize is not None else self.do_normalize
						_A	:				Optional[Any]   =      image_mean if image_mean is not None else self.image_mean
						_A	:				Dict   =      image_std if image_std is not None else self.image_std

						_A	:				str   =      size if size is not None else self.size
						_A	:				int   =      get_size_dict(A__       ,default_to_square=A__		)
						_A	:				Any   =      crop_size if crop_size is not None else self.crop_size
						_A	:				Optional[int]   =      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	:				List[str]   =      make_batched(A__		)

						_A	:				Tuple   =      [
						    [
						        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__       ,offset=A__       ,do_normalize=A__       ,image_mean=A__       ,image_std=A__       ,data_format=A__       ,)
						        for img in video
						    ]
						    for video in videos
						]

						_A	:				Optional[int]   =      {'''pixel_values''': videos}
						return BatchFeature(data=A__       ,tensor_type=A__		)



