





'''simple docstring'''







from typing import Callable, Optional, Union

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


snake_case_  :							str            =	logging.get_logger(__name__)

snake_case_  :							List[Any]            =	{
    "microsoft/prophetnet-large-uncased": (
        "https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json"
    ),
}


class        __a   (lowerCamelCase  ):
							__a       : List[str]          =							"prophetnet"
							__a       : Any          =							["past_key_values"]
							__a       : Dict          =							{
							    "num_attention_heads": "num_encoder_attention_heads",
							}

							def __init__(				self				:  List[str]							,  __magic_name__				:  Optional[float] = 0.1							,  __magic_name__				:  Optional[Union[str, Callable]] = "gelu"							,  __magic_name__				:  Optional[int] = 3_05_22							,  __magic_name__				:  Optional[int] = 10_24							,  __magic_name__				:  Optional[int] = 40_96							,  __magic_name__				:  Optional[int] = 12							,  __magic_name__				:  Optional[int] = 16							,  __magic_name__				:  Optional[int] = 40_96							,  __magic_name__				:  Optional[int] = 12							,  __magic_name__				:  Optional[int] = 16							,  __magic_name__				:  Optional[float] = 0.1							,  __magic_name__				:  Optional[float] = 0.1							,  __magic_name__				:  Optional[int] = 5_12							,  __magic_name__				:  Optional[float] = 0.0_2							,  __magic_name__				:  Optional[bool] = True							,  __magic_name__				:  Optional[bool] = True							,  __magic_name__				:  Optional[int] = 0							,  __magic_name__				:  Optional[int] = 2							,  __magic_name__				:  Optional[int] = 32							,  __magic_name__				:  Optional[int] = 1_28							,  __magic_name__				:  Optional[bool] = False							,  __magic_name__				:  Optional[float] = 0.0							,  __magic_name__				:  Optional[bool] = True							,  __magic_name__				:  Optional[int] = 0							,  __magic_name__				:  Optional[int] = 1							,  __magic_name__				:  Optional[int] = 2							,  **__magic_name__				:  Any							,  )       ->							List[Any]:







													"""simple docstring"""
													UpperCAmelCase_      :   List[str]      =	vocab_size
													UpperCAmelCase_      :   Optional[Any]      =	hidden_size
													UpperCAmelCase_      :   Any      =	encoder_ffn_dim
													UpperCAmelCase_      :   Dict      =	num_encoder_layers
													UpperCAmelCase_      :   int      =	num_encoder_attention_heads
													UpperCAmelCase_      :   Optional[int]      =	decoder_ffn_dim
													UpperCAmelCase_      :   Any      =	num_decoder_layers
													UpperCAmelCase_      :   Optional[Any]      =	num_decoder_attention_heads
													UpperCAmelCase_      :   Any      =	max_position_embeddings
													UpperCAmelCase_      :   Optional[Any]      =	init_std  # Normal(0, this parameter)
													UpperCAmelCase_      :   Union[str, Any]      =	activation_function

													# parameters for prophetnet
													UpperCAmelCase_      :   Optional[int]      =	ngram
													UpperCAmelCase_      :   Optional[Any]      =	num_buckets
													UpperCAmelCase_      :   List[Any]      =	relative_max_distance
													UpperCAmelCase_      :   Tuple      =	disable_ngram_loss
													UpperCAmelCase_      :   Any      =	eps

													# 3 Types of Dropout
													UpperCAmelCase_      :   Any      =	attention_dropout
													UpperCAmelCase_      :   int      =	activation_dropout
													UpperCAmelCase_      :   Union[str, Any]      =	dropout

													UpperCAmelCase_      :   int      =	use_cache

													super().__init__(
													    pad_token_id=__magic_name__							,  bos_token_id=__magic_name__							,  eos_token_id=__magic_name__							,  is_encoder_decoder=__magic_name__							,  add_cross_attention=__magic_name__							,  decoder_start_token_id=__magic_name__							,  **__magic_name__							,  )

							@property
							def      UpperCAmelCase__						(				self				:  List[Any] )       ->							int:







													"""simple docstring"""
													return self.num_encoder_layers + self.num_decoder_layers



							@num_hidden_layers.setter
							def      UpperCAmelCase__						(				self				:  List[Any]							,  __magic_name__				:  Tuple )       ->							str:







													"""simple docstring"""
													raise NotImplementedError(
													    '''This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and'''
													    ''' `num_decoder_layers`.''' )












'''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,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


snake_case_  :							Any            =	logging.get_logger(__name__)


if is_vision_available():
					import PIL


class        __a   (lowerCamelCase  ):
							__a       : Any          =							["pixel_values"]

							def __init__(				self				:  Optional[int]							,  __magic_name__				:  bool = True							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  PILImageResampling = PILImageResampling.BICUBIC							,  __magic_name__				:  bool = True							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  bool = True							,  __magic_name__				:  Union[int, float] = 1 / 2_55							,  __magic_name__				:  bool = True							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  bool = True							,  **__magic_name__				:  Union[str, Any]							,  )       ->							None:







													"""simple docstring"""
													super().__init__(**__magic_name__ )
													UpperCAmelCase_      :   List[Any]      =	size if size is not None else {'''shortest_edge''': 2_24}
													UpperCAmelCase_      :   List[str]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   int      =	crop_size if crop_size is not None else {'''height''': 2_24, '''width''': 2_24}
													UpperCAmelCase_      :   Union[str, Any]      =	get_size_dict(__magic_name__ )

													UpperCAmelCase_      :   str      =	do_resize
													UpperCAmelCase_      :   Optional[Any]      =	size
													UpperCAmelCase_      :   int      =	resample
													UpperCAmelCase_      :   List[str]      =	do_center_crop
													UpperCAmelCase_      :   Optional[Any]      =	crop_size
													UpperCAmelCase_      :   List[str]      =	do_rescale
													UpperCAmelCase_      :   Union[str, Any]      =	rescale_factor
													UpperCAmelCase_      :   int      =	do_normalize
													UpperCAmelCase_      :   Any      =	image_mean if image_mean is not None else OPENAI_CLIP_MEAN
													UpperCAmelCase_      :   Optional[Any]      =	image_std if image_std is not None else OPENAI_CLIP_STD
													UpperCAmelCase_      :   int      =	do_convert_rgb

							def      UpperCAmelCase__						(				self				:  int							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Dict[str, int]							,  __magic_name__				:  PILImageResampling = PILImageResampling.BICUBIC							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Optional[int]							,  )       ->							np.ndarray:







													"""simple docstring"""
													UpperCAmelCase_      :   Optional[Any]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   Any      =	get_resize_output_image_size(
													    __magic_name__							,  size=(size['''height'''], size['''width'''])							,  default_to_square=__magic_name__ )
													return resize(__magic_name__							,  size=__magic_name__							,  resample=__magic_name__							,  data_format=__magic_name__							,  **__magic_name__ )

							def      UpperCAmelCase__						(				self				:  List[Any]							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Dict[str, int]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Any							,  )       ->							np.ndarray:







													"""simple docstring"""
													UpperCAmelCase_      :   List[Any]      =	get_size_dict(__magic_name__ )
													return center_crop(__magic_name__							,  size=(size['''height'''], size['''width'''])							,  data_format=__magic_name__							,  **__magic_name__ )

							def      UpperCAmelCase__						(				self				:  str							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Union[int, float]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Any							,  )       ->							Union[str, Any]:







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

							def      UpperCAmelCase__						(				self				:  str							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Union[float, List[float]]							,  __magic_name__				:  Union[float, List[float]]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Optional[int]							,  )       ->							np.ndarray:







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



							def      UpperCAmelCase__						(				self				:  Dict							,  __magic_name__				:  ImageInput							,  __magic_name__				:  bool = None							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  PILImageResampling = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  int = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  float = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  Optional[Union[str, TensorType]] = None							,  __magic_name__				:  Optional[ChannelDimension] = ChannelDimension.FIRST							,  **__magic_name__				:  Union[str, Any]							,  )       ->							PIL.Image.Image:







													"""simple docstring"""
													UpperCAmelCase_      :   int      =	do_resize if do_resize is not None else self.do_resize
													UpperCAmelCase_      :   Dict      =	size if size is not None else self.size
													UpperCAmelCase_      :   Union[str, Any]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   str      =	resample if resample is not None else self.resample
													UpperCAmelCase_      :   Tuple      =	do_center_crop if do_center_crop is not None else self.do_center_crop
													UpperCAmelCase_      :   List[str]      =	crop_size if crop_size is not None else self.crop_size
													UpperCAmelCase_      :   Optional[Any]      =	get_size_dict(__magic_name__ )
													UpperCAmelCase_      :   str      =	do_rescale if do_rescale is not None else self.do_rescale
													UpperCAmelCase_      :   Tuple      =	rescale_factor if rescale_factor is not None else self.rescale_factor
													UpperCAmelCase_      :   List[Any]      =	do_normalize if do_normalize is not None else self.do_normalize
													UpperCAmelCase_      :   Tuple      =	image_mean if image_mean is not None else self.image_mean
													UpperCAmelCase_      :   int      =	image_std if image_std is not None else self.image_std
													UpperCAmelCase_      :   Optional[Any]      =	do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

													UpperCAmelCase_      :   Any      =	make_list_of_images(__magic_name__ )

													if not valid_images(__magic_name__ ):
																			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_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.''' )

													# PIL RGBA images are converted to RGB
													if do_convert_rgb:
																			UpperCAmelCase_      :   Optional[int]      =	[convert_to_rgb(__magic_name__ ) for image in images]

													# All transformations expect numpy arrays.
													UpperCAmelCase_      :   Optional[Any]      =	[to_numpy_array(__magic_name__ ) for image in images]

													if do_resize:
																			UpperCAmelCase_      :   Dict      =	[self.resize(image=__magic_name__							,  size=__magic_name__							,  resample=__magic_name__ ) for image in images]

													if do_center_crop:
																			UpperCAmelCase_      :   Union[str, Any]      =	[self.center_crop(image=__magic_name__							,  size=__magic_name__ ) for image in images]

													if do_rescale:
																			UpperCAmelCase_      :   Dict      =	[self.rescale(image=__magic_name__							,  scale=__magic_name__ ) for image in images]

													if do_normalize:
																			UpperCAmelCase_      :   Optional[int]      =	[self.normalize(image=__magic_name__							,  mean=__magic_name__							,  std=__magic_name__ ) for image in images]

													UpperCAmelCase_      :   Optional[Any]      =	[to_channel_dimension_format(__magic_name__							,  __magic_name__ ) for image in images]

													UpperCAmelCase_      :   int      =	{'''pixel_values''': images}
													return BatchFeature(data=__magic_name__							,  tensor_type=__magic_name__ )





