




'''simple docstring'''


import torch
import torch.nn as nn
from transformers.modeling_utils import ModuleUtilsMixin
from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm

from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin





class    __lowercase						(  __magic_name__       ,							__magic_name__       ,							__magic_name__ ):







   @register_to_config
   def __init__(	self      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase      ,							UpperCamelCase = False      ,							)				->    Dict:
     super().__init__()

     __a			=					nn.Embedding(UpperCamelCase      ,							UpperCamelCase      )

     __a			=					nn.Embedding(UpperCamelCase      ,							UpperCamelCase      )
     __a			=					False

     __a			=					nn.Dropout(p=UpperCamelCase      )

     __a			=					TaConfig(
         vocab_size=UpperCamelCase      ,							d_model=UpperCamelCase      ,							num_heads=UpperCamelCase      ,							d_kv=UpperCamelCase      ,							d_ff=UpperCamelCase      ,							dropout_rate=UpperCamelCase      ,							feed_forward_proj=UpperCamelCase      ,							is_decoder=UpperCamelCase      ,							is_encoder_decoder=UpperCamelCase      ,							)

     __a			=					nn.ModuleList()
     for lyr_num in range(UpperCamelCase      ):
       __a			=					TaBlock(UpperCamelCase      )
       self.encoders.append(UpperCamelCase      )

     __a			=					TaLayerNorm(UpperCamelCase      )
     __a			=					nn.Dropout(p=UpperCamelCase      )







   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      ,							UpperCamelCase      )				->    int:
     __a			=					self.token_embedder(UpperCamelCase      )

     __a			=					encoder_input_tokens.shape[1]
     __a			=					torch.arange(UpperCamelCase      ,							device=encoder_input_tokens.device      )
     x += self.position_encoding(UpperCamelCase      )

     __a			=					self.dropout_pre(UpperCamelCase      )

     # inverted the attention mask
     __a			=					encoder_input_tokens.size()
     __a			=					self.get_extended_attention_mask(UpperCamelCase      ,							UpperCamelCase      )

     for lyr in self.encoders:
       __a			=					lyr(UpperCamelCase      ,							UpperCamelCase      )[0]
     __a			=					self.layer_norm(UpperCamelCase      )

     return self.dropout_post(UpperCamelCase      ), encoder_inputs_mask









'''simple docstring'''


from ..utils import DummyObject, requires_backends





class    __lowercase						(  metaclass=__magic_name__ ):
   _a							=      ["""onnx"""]







   def __init__(	self      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    str:
     requires_backends(self      ,							['onnx']      )







   @classmethod
   def 		UpperCamelCase__			(	cls      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    Tuple:
     requires_backends(cls      ,							['onnx']      )







   @classmethod
   def 		UpperCamelCase__			(	cls      ,							*UpperCamelCase      ,							**UpperCamelCase      )				->    Tuple:
     requires_backends(cls      ,							['onnx']      )



