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
  -------
  A tuple contains
  
  - If 'self.extract_feature' = True
      - contextual_embedding
          - layout = 'NT'
              Shape (batch_size, tgt_length, units)
          - layout = 'TN'
              Shape (tgt_length, batch_size, units)
  
      - pooled_output, optional, only enabled if use_pooler = True
          Shape (batch_size, units)
  
  - If 'self.extract_feature' = False
      - dec_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","--","--","--","-","A","tuple","contains","-","If","'self.extract_feature","'","=","True","-","contextual_embedding","-","layout","=","'NT'","Shape","(","batch_size",",","tgt_length",",","units",")","-","layout","=","'TN'","Shape","(","tgt_length",",","batch_size",",","units",")","-","pooled_output",",","optional",",","only","enabled","if","use_pooler","=","True","Shape","(","batch_size",",","units",")","-","If","'self.extract_feature","'","=","False","-","dec_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
      -------
      A tuple contains
  
      - If 'self.extract_feature' = True
          - contextual_embedding
              - layout = 'NT'
                  Shape (batch_size, tgt_length, units)
              - layout = 'TN'
                  Shape (tgt_length, batch_size, units)
  
          - pooled_output, optional, only enabled if use_pooler = True
              Shape (batch_size, units)
  
      - If 'self.extract_feature' = False
          - dec_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)
      contextual_embedding = self.decode_seq(
          tgt_data, tgt_valid_length, enc_out, src_valid_length
      )
      if self.extract_feature:
          if self.use_pooler:
              pooled_output = self.apply_pooling(
                  contextual_embedding, tgt_valid_length
              )
              return contextual_embedding, pooled_output
          else:
              return contextual_embedding
      else:
          dec_out = self.tgt_final_layer(contextual_embedding)
          return dec_out
  
imports: import os
  from typing import Tuple, List
  import mxnet
  from mxnet import use_np
  from mxnet.gluon import nn
  from .base import BACKBONE_REGISTRY
  from .transformer import TransformerModel
  from ..base import get_model_zoo_home_dir, get_repo_model_zoo_url, get_model_zoo_checksum_dir
  from ..utils.misc import download, load_checksum_stats
  from ..utils.config import CfgNode
  from ..utils.registry import Registry
  from ..data.tokenizers import HuggingFaceByteBPETokenizer
label_desc: Use image node_id 2 for calling the BartModel 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, contextual_embedding,  pooled_output, contextual_embedding