



"""simple docstring"""
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxSeqaSeqConfigWithPast
from ...utils import logging


__a           =							logging.get_logger(__name__)

__a           =							{
    "google/long-t5-local-base": "https://huggingface.co/google/long-t5-local-base/blob/main/config.json",
    "google/long-t5-local-large": "https://huggingface.co/google/long-t5-local-large/blob/main/config.json",
    "google/long-t5-tglobal-base": "https://huggingface.co/google/long-t5-tglobal-base/blob/main/config.json",
    "google/long-t5-tglobal-large": "https://huggingface.co/google/long-t5-tglobal-large/blob/main/config.json",
}
class 							lowerCamelCase    (     _lowerCAmelCase							):






					'''simple docstring'''





					_A						:     Optional[Any]		=	"""longt5"""
					_A						:     Tuple		=	["""past_key_values"""]
					_A						:     Dict		=	{"""hidden_size""": """d_model""", """num_attention_heads""": """num_heads""", """num_hidden_layers""": """num_layers"""}






					def __init__(			self:				Union[str, Any]		,	snake_case:				List[Any]=32_128		,	snake_case:				Tuple=512		,	snake_case:				Union[str, Any]=64		,	snake_case:				str=2_048		,	snake_case:				Optional[int]=6		,	snake_case:				int=None		,	snake_case:				int=8		,	snake_case:				str=127		,	snake_case:				Optional[Any]=16		,	snake_case:				List[Any]=32		,	snake_case:				Union[str, Any]=128		,	snake_case:				int=0.1		,	snake_case:				Union[str, Any]=1E-6		,	snake_case:				str=1.0		,	snake_case:				str="relu"		,	snake_case:				Any=True		,	snake_case:				Optional[Any]="local"		,	snake_case:				Any=True		,	snake_case:				Dict=0		,	snake_case:				List[Any]=1		,	**snake_case:				Any		,	)  ->      Any:
											snake_case_					:int		=     vocab_size
											snake_case_					:str		=     d_model
											snake_case_					:str		=     d_kv
											snake_case_					:List[str]		=     d_ff
											snake_case_					:str		=     num_layers
											# default = symmetry
											snake_case_					:Optional[Any]		=     num_decoder_layers if num_decoder_layers is not None else self.num_layers
											snake_case_					:Tuple		=     num_heads
											snake_case_					:str		=     local_radius
											snake_case_					:List[Any]		=     global_block_size
											snake_case_					:Any		=     relative_attention_num_buckets
											snake_case_					:str		=     relative_attention_max_distance
											snake_case_					:List[Any]		=     dropout_rate
											snake_case_					:Optional[int]		=     layer_norm_epsilon
											snake_case_					:int		=     initializer_factor
											snake_case_					:Dict		=     feed_forward_proj
											snake_case_					:List[str]		=     encoder_attention_type
											snake_case_					:Any		=     use_cache

											snake_case_					:int		=     self.feed_forward_proj.split("""-"""		)
											snake_case_					:str		=     act_info[-1]
											snake_case_					:Union[str, Any]		=     act_info[0] == """gated"""

											if len(snake_case		) > 1 and act_info[0] != "gated" or len(snake_case		) > 2:
																	raise ValueError(
																	    f"""`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer."""
																	    """Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. """
																	    """'gated-gelu' or 'relu'"""		)

											# for backwards compatibility
											if feed_forward_proj == "gated-gelu":
																	snake_case_					:Tuple		=     """gelu_new"""

											super().__init__(
											    pad_token_id=snake_case		,	eos_token_id=snake_case		,	is_encoder_decoder=snake_case		,	**snake_case		,	)

class 							lowerCamelCase    (     _lowerCAmelCase							):






					'''simple docstring'''





					@property
					def   lowerCAmelCase_							(			self:				Optional[Any]		)  ->      Mapping[str, Mapping[int, str]]:
											snake_case_					:Any		=     {
											    """input_ids""": {0: """batch""", 1: """encoder_sequence"""},
											    """attention_mask""": {0: """batch""", 1: """encoder_sequence"""},
											}
											if self.use_past:
																	snake_case_					:Optional[int]		=     """past_encoder_sequence + sequence"""
																	snake_case_					:int		=     {0: """batch"""}
																	snake_case_					:Optional[int]		=     {0: """batch""", 1: """past_decoder_sequence + sequence"""}
											else:
																	snake_case_					:List[str]		=     {0: """batch""", 1: """decoder_sequence"""}
																	snake_case_					:List[Any]		=     {0: """batch""", 1: """decoder_sequence"""}

											if self.use_past:
																	self.fill_with_past_key_values_(snake_case		,	direction="""inputs"""		)

											return common_inputs






					@property
					def   lowerCAmelCase_							(			self:				int		)  ->      int:
											return 13








import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


__UpperCAmelCase      =				logging.get_logger(__name__)
class 	a_(		lowercase__	):



     """simple docstring"""



     __snake_case		:				Union[str, Any]  					='''speech-encoder-decoder'''
     __snake_case		:				List[Any]  					=True





     def __init__(		self					:	Any  ,  **lowerCAmelCase__					:	List[Any])							->	Tuple:

      """simple docstring"""
      super().__init__(**lowerCAmelCase__)
      if "encoder" not in kwargs or "decoder" not in kwargs:
       raise ValueError(
           f'''A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and'''
           f''' `decoder` sub-configurations are passed, but only {kwargs}''')

      SCREAMING_SNAKE_CASE				    =		kwargs.pop('encoder')
      SCREAMING_SNAKE_CASE				    =		encoder_config.pop('model_type')
      SCREAMING_SNAKE_CASE				    =		kwargs.pop('decoder')
      SCREAMING_SNAKE_CASE				    =		decoder_config.pop('model_type')

      SCREAMING_SNAKE_CASE				    =		AutoConfig.for_model(lowerCAmelCase__  ,  **lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		AutoConfig.for_model(lowerCAmelCase__  ,  **lowerCAmelCase__)
      SCREAMING_SNAKE_CASE				    =		True





     @classmethod
     def     __UpperCamelCase						(		cls					:	str  ,  lowerCAmelCase__					:	PretrainedConfig  ,  lowerCAmelCase__					:	PretrainedConfig  ,  **lowerCAmelCase__					:	List[str])							->	PretrainedConfig:

      """simple docstring"""
      logger.info('Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config')
      SCREAMING_SNAKE_CASE				    =		True
      SCREAMING_SNAKE_CASE				    =		True

      return cls(encoder=encoder_config.to_dict()  ,  decoder=decoder_config.to_dict()  ,  **lowerCAmelCase__)





     def     __UpperCamelCase						(		self					:	str)							->	Union[str, Any]:

      """simple docstring"""
      SCREAMING_SNAKE_CASE				    =		copy.deepcopy(self.__dict__)
      SCREAMING_SNAKE_CASE				    =		self.encoder.to_dict()
      SCREAMING_SNAKE_CASE				    =		self.decoder.to_dict()
      SCREAMING_SNAKE_CASE				    =		self.__class__.model_type
      return output




