docstr: Parameters
  ----------
  src_data
      - layout = 'NT'
          Shape (batch_size, src_length)
      - layout = 'TN'
          Shape (src_length, batch_size)
  
  src_valid_length
      Shape (batch_size,)
  tgt_data
      - layout = 'NT'
          Shape (batch_size, tgt_length)
      - layout = 'TN'
          Shape (tgt_length, batch_size)
  
  tgt_valid_length
      Shape (batch_size,)
  
  Returns
  -------
  out
      - layout = 'NT'
          Shape (batch_size, tgt_length, tgt_vocab_size)
      - layout = 'TN'
          Shape (tgt_length, batch_size, tgt_vocab_size)
docstr_tok: ["Parameters","--","--","--","--","--","src_data","-","layout","=","'NT'","Shape","(","batch_size",",","src_length",")","-","layout","=","'TN'","Shape","(","src_length",",","batch_size",")","src_valid_length","Shape","(","batch_size",",",")","tgt_data","-","layout","=","'NT'","Shape","(","batch_size",",","tgt_length",")","-","layout","=","'TN'","Shape","(","tgt_length",",","batch_size",")","tgt_valid_length","Shape","(","batch_size",",",")","Returns","--","--","--","-","out","-","layout","=","'NT'","Shape","(","batch_size",",","tgt_length",",","tgt_vocab_size",")","-","layout","=","'TN'","Shape","(","tgt_length",",","batch_size",",","tgt_vocab_size",")"]
code: def forward(
      self, src_data, src_valid_length, tgt_data, tgt_valid_length
  ):
      """
  
      Parameters
      ----------
      src_data
          - layout = 'NT'
              Shape (batch_size, src_length)
          - layout = 'TN'
              Shape (src_length, batch_size)
  
      src_valid_length
          Shape (batch_size,)
      tgt_data
          - layout = 'NT'
              Shape (batch_size, tgt_length)
          - layout = 'TN'
              Shape (tgt_length, batch_size)
  
      tgt_valid_length
          Shape (batch_size,)
  
      Returns
      -------
      out
          - layout = 'NT'
              Shape (batch_size, tgt_length, tgt_vocab_size)
          - layout = 'TN'
              Shape (tgt_length, batch_size, tgt_vocab_size)
  
      """
      enc_out = self.encode(src_data, src_valid_length)
      dec_out = self.decode_seq(
          tgt_data, tgt_valid_length, enc_out, src_valid_length
      )
      dec_out = self.tgt_final_layer(dec_out)
      return dec_out
  
imports: import numpy
  import mxnet
  from mxnet import np, npx
  from mxnet import use_np
  from mxnet.gluon import nn, HybridBlock
  from typing import Optional, Tuple, List
  from ..utils.registry import Registry
  from ..attention_cell import MultiHeadAttentionCell, gen_self_attn_mask, gen_mem_attn_mask
  from ..layers import PositionalEmbedding, PositionwiseFFN, InitializerType
  from ..utils.config import CfgNode
  from ..sequence_sampler import BaseStepDecoder
label_desc: Use image node_id 7 for calling the TransformerModel obj's underlying member method code with example usage: obj.forward(src_data, src_valid_length, tgt_data, tgt_valid_length) and returns: dec_out