code: def forward(
      self,
      txt_emb,
      txt_mask,
      obj_emb,
      obj_mask,
      ocr_emb,
      ocr_mask,
      fixed_ans_emb,
      prev_inds,
  ):
      # build embeddings for predictions in previous decoding steps
      # fixed_ans_emb is an embedding lookup table for each fixed vocabulary
      dec_emb = self.prev_pred_embeddings(
          fixed_ans_emb, ocr_emb, prev_inds
      )
  
      # a zero mask for decoding steps, so the encoding steps elements can't
      # attend to decoding steps.
      # A triangular causal mask will be filled for the decoding steps
      # later in extended_attention_mask
      dec_mask = torch.zeros(
          dec_emb.size(0),
          dec_emb.size(1),
          dtype=torch.float32,
          device=dec_emb.device,
      )
      encoder_inputs = torch.cat(
          [txt_emb, obj_emb, ocr_emb, dec_emb], dim=1
      )
      attention_mask = torch.cat(
          [txt_mask, obj_mask, ocr_mask, dec_mask], dim=1
      )
  
      # offsets of each modality in the joint embedding space
      txt_max_num = txt_mask.size(-1)
      obj_max_num = obj_mask.size(-1)
      ocr_max_num = ocr_mask.size(-1)
      dec_max_num = dec_mask.size(-1)
      txt_begin = 0
      txt_end = txt_begin + txt_max_num
      ocr_begin = txt_max_num + obj_max_num
      ocr_end = ocr_begin + ocr_max_num
  
      # We create a 3D attention mask from a 2D tensor mask.
      # Sizes are [batch_size, 1, from_seq_length, to_seq_length]
      # So we can broadcast to
      # [batch_size, num_heads, from_seq_length, to_seq_length]
      to_seq_length = attention_mask.size(1)
      from_seq_length = to_seq_length
  
      # generate the attention mask similar to prefix LM
      # all elements can attend to the elements in encoding steps
      extended_attention_mask = attention_mask.unsqueeze(1).unsqueeze(2)
      extended_attention_mask = extended_attention_mask.repeat(
          1, 1, from_seq_length, 1
      )
      # decoding step elements can attend to themselves in a causal manner
      extended_attention_mask[
          :, :, -dec_max_num:, -dec_max_num:
      ] = _get_causal_mask(dec_max_num, encoder_inputs.device)
  
      # flip the mask, so that invalid attention pairs have -10000.
      extended_attention_mask = (
          1.0 - extended_attention_mask
      ) * -10000.0
      assert not extended_attention_mask.requires_grad
      head_mask = [None] * self.config.num_hidden_layers
  
      encoder_outputs = self.encoder(
          encoder_inputs, extended_attention_mask, head_mask=head_mask
      )
  
      mmt_seq_output = encoder_outputs[0]
      mmt_txt_output = mmt_seq_output[:, txt_begin:txt_end]
      mmt_ocr_output = mmt_seq_output[:, ocr_begin:ocr_end]
      mmt_dec_output = mmt_seq_output[:, -dec_max_num:]
  
      results = {
          "mmt_seq_output": mmt_seq_output,
          "mmt_txt_output": mmt_txt_output,
          "mmt_ocr_output": mmt_ocr_output,
          "mmt_dec_output": mmt_dec_output,
      }
      return results
  
imports: import functools
  import logging
  import math
  import torch
  import torch.nn.functional
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.modules.layers import ClassifierLayer
  from mmf.utils.build import build_image_encoder
  from omegaconf import OmegaConf
  from torch import nn
label_desc: Use image node_id 2 for calling the MMT obj's underlying member method code with example usage: obj.forward(txt_emb, txt_mask, obj_emb, obj_mask, ocr_emb, ocr_mask, fixed_ans_emb, prev_inds) and returns: results