






from typing import Callable, Optional, Union

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


snake_case     					=		logging.get_logger(__name__)

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


class 			SCREAMING_SNAKE_CASE      (      lowerCAmelCase       ):
     '''simple docstring'''


     UpperCamelCase_				:		Tuple								=						'''xlm-prophetnet'''
     UpperCamelCase_				:		Tuple								=						['''past_key_values''']
     UpperCamelCase_				:		int								=						{
         '''num_attention_heads''': '''num_encoder_attention_heads''',
     }


     def __init__(					self							:						Dict       ,			UpperCAmelCase_							:						Optional[float] = 0.1       ,			UpperCAmelCase_							:						Optional[Union[str, Callable]] = "gelu"       ,			UpperCAmelCase_							:						Optional[int] = 3_0522       ,			UpperCAmelCase_							:						Optional[int] = 1024       ,			UpperCAmelCase_							:						Optional[int] = 4096       ,			UpperCAmelCase_							:						Optional[int] = 12       ,			UpperCAmelCase_							:						Optional[int] = 16       ,			UpperCAmelCase_							:						Optional[int] = 4096       ,			UpperCAmelCase_							:						Optional[int] = 12       ,			UpperCAmelCase_							:						Optional[int] = 16       ,			UpperCAmelCase_							:						Optional[float] = 0.1       ,			UpperCAmelCase_							:						Optional[float] = 0.1       ,			UpperCAmelCase_							:						Optional[int] = 512       ,			UpperCAmelCase_							:						Optional[float] = 0.02       ,			UpperCAmelCase_							:						Optional[bool] = True       ,			UpperCAmelCase_							:						Optional[bool] = True       ,			UpperCAmelCase_							:						Optional[int] = 0       ,			UpperCAmelCase_							:						Optional[int] = 2       ,			UpperCAmelCase_							:						Optional[int] = 32       ,			UpperCAmelCase_							:						Optional[int] = 128       ,			UpperCAmelCase_							:						Optional[bool] = False       ,			UpperCAmelCase_							:						Optional[float] = 0.0       ,			UpperCAmelCase_							:						Optional[bool] = True       ,			UpperCAmelCase_							:						Optional[int] = 0       ,			UpperCAmelCase_							:						Optional[int] = 1       ,			UpperCAmelCase_							:						Optional[int] = 2       ,			**UpperCAmelCase_							:						Dict       ,			):
       SCREAMING_SNAKE_CASE							:   Any						    =     vocab_size
       SCREAMING_SNAKE_CASE							:   str						    =     hidden_size
       SCREAMING_SNAKE_CASE							:   Tuple						    =     encoder_ffn_dim
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     num_encoder_layers
       SCREAMING_SNAKE_CASE							:   Any						    =     num_encoder_attention_heads
       SCREAMING_SNAKE_CASE							:   Dict						    =     decoder_ffn_dim
       SCREAMING_SNAKE_CASE							:   List[str]						    =     num_decoder_layers
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     num_decoder_attention_heads
       SCREAMING_SNAKE_CASE							:   List[Any]						    =     max_position_embeddings
       SCREAMING_SNAKE_CASE							:   Dict						    =     init_std  # Normal(0, this parameter)
       SCREAMING_SNAKE_CASE							:   Union[str, Any]						    =     activation_function

       # parameters for xlmprophetnet
       SCREAMING_SNAKE_CASE							:   Dict						    =     ngram
       SCREAMING_SNAKE_CASE							:   Any						    =     num_buckets
       SCREAMING_SNAKE_CASE							:   str						    =     relative_max_distance
       SCREAMING_SNAKE_CASE							:   str						    =     disable_ngram_loss
       SCREAMING_SNAKE_CASE							:   Dict						    =     eps

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

       SCREAMING_SNAKE_CASE							:   int						    =     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 					_A							(					self							:						int   ):
       return self.num_encoder_layers + self.num_decoder_layers






     @num_hidden_layers.setter
     def 					_A							(					self							:						str       ,			UpperCAmelCase_							:						Optional[Any]   ):
       raise NotImplementedError(
           "This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"
           " `num_decoder_layers`."   )













'''simple docstring'''






import warnings

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




class  _A (					__lowercase		):
		lowercase__:   Any				     =   ['''image_processor''', '''tokenizer''']
		lowercase__:   Any				     =   '''CLIPImageProcessor'''
		lowercase__:   Optional[Any]				     =   ('''CLIPTokenizer''', '''CLIPTokenizerFast''')

		def __init__(   self					:   int  ,      __magic_name__					:   Dict=None  ,      __magic_name__					:   Dict=None  ,      **__magic_name__					:   Union[str, Any]			)					->    Any:


					"""simple docstring"""

					__snake_case					:      Optional[Any]							      =     None
					if "feature_extractor" in kwargs:
								warnings.warn(
								    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
								    """ instead."""  ,      __magic_name__  ,      )
								__snake_case					:      List[Any]							      =     kwargs.pop("""feature_extractor"""			)

					__snake_case					:      List[str]							      =     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__(__magic_name__  ,      __magic_name__			)

		def __call__(   self					:   int  ,      __magic_name__					:   List[str]=None  ,      __magic_name__					:   Tuple=None  ,      __magic_name__					:   Any=None  ,      **__magic_name__					:   Union[str, Any]			)					->    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:
								__snake_case					:      int							      =     self.tokenizer(__magic_name__  ,      return_tensors=__magic_name__  ,      **__magic_name__			)

					if images is not None:
								__snake_case					:      str							      =     self.image_processor(__magic_name__  ,      return_tensors=__magic_name__  ,      **__magic_name__			)

					if text is not None and images is not None:
								__snake_case					:      Union[str, Any]							      =     image_features.pixel_values
								return encoding
					elif text is not None:
								return encoding
					else:
								return BatchEncoding(data=dict(**__magic_name__			)  ,      tensor_type=__magic_name__			)

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


					"""simple docstring"""

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

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


					"""simple docstring"""

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

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


					"""simple docstring"""

					__snake_case					:      Dict							      =     self.tokenizer.model_input_names
					__snake_case					:      str							      =     self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names			)			)

		@property
		def 	lowercase__     (   self					:   int			)					->    List[str]:


					"""simple docstring"""

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

		@property
		def 	lowercase__     (   self					:   Union[str, Any]			)					->    Dict:


					"""simple docstring"""

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


