






from typing import Callable, Optional, Union

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


lowercase_    					=					logging.get_logger(__name__)

lowercase_    					=					{
    'microsoft/prophetnet-large-uncased': (
        'https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json'
    ),
}


class  snake_case		(							UpperCAmelCase_						):


   '''simple docstring'''

   A_						:     List[Any]									=			"prophetnet"
   A_						:     Tuple									=			["past_key_values"]
   A_						:     Optional[int]									=			{
       "num_attention_heads": "num_encoder_attention_heads",
   }


   def __init__(     self			:					str,	_lowerCamelCase			:					List[Any] = 0.1,	_lowerCamelCase			:					Optional[Any] = "gelu",	_lowerCamelCase			:					List[str] = 3_05_22,	_lowerCamelCase			:					List[Any] = 10_24,	_lowerCamelCase			:					int = 40_96,	_lowerCamelCase			:					List[Any] = 12,	_lowerCamelCase			:					Any = 16,	_lowerCamelCase			:					Dict = 40_96,	_lowerCamelCase			:					Dict = 12,	_lowerCamelCase			:					Any = 16,	_lowerCamelCase			:					List[Any] = 0.1,	_lowerCamelCase			:					Tuple = 0.1,	_lowerCamelCase			:					int = 5_12,	_lowerCamelCase			:					List[str] = 0.02,	_lowerCamelCase			:					Tuple = True,	_lowerCamelCase			:					List[Any] = True,	_lowerCamelCase			:					Union[str, Any] = 0,	_lowerCamelCase			:					str = 2,	_lowerCamelCase			:					Union[str, Any] = 32,	_lowerCamelCase			:					Optional[Any] = 1_28,	_lowerCamelCase			:					Union[str, Any] = False,	_lowerCamelCase			:					int = 0.0,	_lowerCamelCase			:					Optional[int] = True,	_lowerCamelCase			:					List[str] = 0,	_lowerCamelCase			:					Optional[int] = 1,	_lowerCamelCase			:					Union[str, Any] = 2,	**_lowerCamelCase			:					str,	):

     '''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 prophetnet
     __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     _SCREAMING_SNAKE_CASE    (     self			:					int  ):

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






   @num_hidden_layers.setter
   def     _SCREAMING_SNAKE_CASE    (     self			:					Dict,	_lowerCamelCase			:					int  ):

     '''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 collections import OrderedDict
from dataclasses import fields
from typing import Any, Tuple

import numpy as np

from .import_utils import is_torch_available



def  lowerCAmelCase    (   __UpperCamelCase			):




  """simple docstring"""







  if is_torch_available():
    import torch

    if isinstance(__UpperCamelCase		,	torch.Tensor			):
      return True

  return isinstance(__UpperCamelCase		,	np.ndarray			)





class  snake_case		(							_lowerCAmelCase						):


   '''simple docstring'''

   def     _SCREAMING_SNAKE_CASE    (     self			:					Dict  ):

     '''simple docstring'''
     __A						      =			fields(self  )

     # Safety and consistency checks
     if not len(_lowerCamelCase  ):
       raise ValueError(f'{self.__class__.__name__} has no fields.'  )

     __A						      =			getattr(self,	class_fields[0].name  )
     __A						      =			all(getattr(self,	field.name  ) is None for field in class_fields[1:]  )

     if other_fields_are_none and isinstance(_lowerCamelCase,	_lowerCamelCase  ):
       for key, value in first_field.items():
         __A						      =			value
     else:
       for field in class_fields:
         __A						      =			getattr(self,	field.name  )
         if v is not None:
           __A						      =			v


   def __delitem__(     self			:					Dict,	*_lowerCamelCase			:					int,	**_lowerCamelCase			:					Any  ):

     '''simple docstring'''
     raise Exception(f'You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.'  )


   def     _SCREAMING_SNAKE_CASE    (     self			:					List[Any],	*_lowerCamelCase			:					List[str],	**_lowerCamelCase			:					str  ):

     '''simple docstring'''
     raise Exception(f'You cannot use ``setdefault`` on a {self.__class__.__name__} instance.'  )


   def     _SCREAMING_SNAKE_CASE    (     self			:					Any,	*_lowerCamelCase			:					Optional[Any],	**_lowerCamelCase			:					str  ):

     '''simple docstring'''
     raise Exception(f'You cannot use ``pop`` on a {self.__class__.__name__} instance.'  )


   def     _SCREAMING_SNAKE_CASE    (     self			:					List[str],	*_lowerCamelCase			:					Any,	**_lowerCamelCase			:					Optional[int]  ):

     '''simple docstring'''
     raise Exception(f'You cannot use ``update`` on a {self.__class__.__name__} instance.'  )


   def __getitem__(     self			:					int,	_lowerCamelCase			:					List[Any]  ):

     '''simple docstring'''
     if isinstance(_lowerCamelCase,	_lowerCamelCase  ):
       __A						      =			dict(self.items()  )
       return inner_dict[k]
     else:
       return self.to_tuple()[k]


   def __setattr__(     self			:					Optional[int],	_lowerCamelCase			:					Tuple,	_lowerCamelCase			:					Union[str, Any]  ):

     '''simple docstring'''
     if name in self.keys() and value is not None:
       # Don't call self.__setitem__ to avoid recursion errors
       super().__setitem__(_lowerCamelCase,	_lowerCamelCase  )
     super().__setattr__(_lowerCamelCase,	_lowerCamelCase  )


   def __setitem__(     self			:					List[str],	_lowerCamelCase			:					Optional[int],	_lowerCamelCase			:					str  ):

     '''simple docstring'''
     # Will raise a KeyException if needed
     super().__setitem__(_lowerCamelCase,	_lowerCamelCase  )
     # Don't call self.__setattr__ to avoid recursion errors
     super().__setattr__(_lowerCamelCase,	_lowerCamelCase  )






   def     _SCREAMING_SNAKE_CASE    (     self			:					Any  ):

     '''simple docstring'''
     return tuple(self[k] for k in self.keys()  )




