




"""simple docstring"""



from typing import Callable, Optional, Union

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


SCREAMING_SNAKE_CASE    =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE    =	{
    "microsoft/xprophetnet-large-wiki100-cased": (
        "https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased/resolve/main/config.json"
    ),
}




class      UpperCAmelCase_  (						lowerCamelCase_							):
    lowercase__						 =				"""xlm-prophetnet"""
    lowercase__						 =				["""past_key_values"""]
    lowercase__						 =				{
        """num_attention_heads""": """num_encoder_attention_heads""",
    }




    def __init__(   self						:	List[Any]     ,			snake_case_						:	Optional[float] = 0.1     ,			snake_case_						:	Optional[Union[str, Callable]] = "gelu"     ,			snake_case_						:	Optional[int] = 30_522     ,			snake_case_						:	Optional[int] = 1_024     ,			snake_case_						:	Optional[int] = 4_096     ,			snake_case_						:	Optional[int] = 12     ,			snake_case_						:	Optional[int] = 16     ,			snake_case_						:	Optional[int] = 4_096     ,			snake_case_						:	Optional[int] = 12     ,			snake_case_						:	Optional[int] = 16     ,			snake_case_						:	Optional[float] = 0.1     ,			snake_case_						:	Optional[float] = 0.1     ,			snake_case_						:	Optional[int] = 512     ,			snake_case_						:	Optional[float] = 0.02     ,			snake_case_						:	Optional[bool] = True     ,			snake_case_						:	Optional[bool] = True     ,			snake_case_						:	Optional[int] = 0     ,			snake_case_						:	Optional[int] = 2     ,			snake_case_						:	Optional[int] = 32     ,			snake_case_						:	Optional[int] = 128     ,			snake_case_						:	Optional[bool] = False     ,			snake_case_						:	Optional[float] = 0.0     ,			snake_case_						:	Optional[bool] = True     ,			snake_case_						:	Optional[int] = 0     ,			snake_case_						:	Optional[int] = 1     ,			snake_case_						:	Optional[int] = 2     ,			**snake_case_						:	Optional[int]     ,			)				->							Tuple:




     '''simple docstring'''

     A__	=    vocab_size
     A__	=    hidden_size
     A__	=    encoder_ffn_dim
     A__	=    num_encoder_layers
     A__	=    num_encoder_attention_heads
     A__	=    decoder_ffn_dim
     A__	=    num_decoder_layers
     A__	=    num_decoder_attention_heads
     A__	=    max_position_embeddings
     A__	=    init_std  # Normal(0, this parameter)
     A__	=    activation_function

     # parameters for xlmprophetnet
     A__	=    ngram
     A__	=    num_buckets
     A__	=    relative_max_distance
     A__	=    disable_ngram_loss
     A__	=    eps

     # 3 Types of Dropout
     A__	=    attention_dropout
     A__	=    activation_dropout
     A__	=    dropout

     A__	=    use_cache

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




    @property
    def 							__magic_name__							(   self						:	Optional[int]				)				->							str:




     '''simple docstring'''

     return self.num_encoder_layers + self.num_decoder_layers




    @num_hidden_layers.setter
    def 							__magic_name__							(   self						:	Optional[Any]     ,			snake_case_						:	Optional[int]				)				->							Tuple:




     '''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 ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding




class      UpperCAmelCase_  (						A_							):
    lowercase__						 =				['''image_processor''', '''tokenizer''']
    lowercase__						 =				'''AutoImageProcessor'''
    lowercase__						 =				'''AutoTokenizer'''




    def __init__(   self						:	str     ,			snake_case_						:	Dict     ,			snake_case_						:	List[str]				)				->							str:




     '''simple docstring'''

     super().__init__(snake_case_     ,			snake_case_				)
     A__	=    self.image_processor




    def __call__(   self						:	int     ,			snake_case_						:	Any=None     ,			snake_case_						:	Any=None     ,			snake_case_						:	Union[str, Any]=None     ,			**snake_case_						:	Optional[int]				)				->							Optional[int]:




     '''simple docstring'''

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

     if text is not None:
      A__	=    self.tokenizer(snake_case_     ,			return_tensors=snake_case_     ,			**snake_case_				)

     if images is not None:
      A__	=    self.image_processor(snake_case_     ,			return_tensors=snake_case_     ,			**snake_case_				)

     if text is not None and images is not None:
      A__	=    image_features.pixel_values
      return encoding
     elif text is not None:
      return encoding
     else:
      return BatchEncoding(data=dict(**snake_case_				)     ,			tensor_type=snake_case_				)




    def 							__magic_name__							(   self						:	Optional[int]     ,			*snake_case_						:	Union[str, Any]     ,			**snake_case_						:	List[Any]				)				->							int:




     '''simple docstring'''

     return self.tokenizer.batch_decode(*snake_case_     ,			**snake_case_				)




    def 							__magic_name__							(   self						:	List[str]     ,			*snake_case_						:	List[str]     ,			**snake_case_						:	Optional[int]				)				->							Tuple:




     '''simple docstring'''

     return self.tokenizer.decode(*snake_case_     ,			**snake_case_				)




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




     '''simple docstring'''

     return ["input_ids", "attention_mask", "pixel_values"]





