code: def forward(
      self,
      sequence_output: Tensor,
      processed_sample_list: Dict[str, Dict[str, Tensor]],
  ) -> Dict[str, Dict[str, Tensor]]:
      output_dict = {}
      assert (
          self.mrc_label_key in processed_sample_list
          and processed_sample_list[self.mrc_label_key] is not None
      ), (
          f"MRC pretraining requires {self.mrc_label_key} to be in sample "
          + "list with value not None."
      )
      # (bs*num_feat, label_dim)  Look at unit test for example usage!
      region_labels = processed_sample_list[self.mrc_label_key]
  
      assert (
          self.mrc_mask_key in processed_sample_list
          and processed_sample_list[self.mrc_mask_key] is not None
      ), (
          f"MRC pretraining requires {self.mrc_mask_key} to be in sample "
          + "list with value not None."
      )
      # (bs, num_feat)
      image_region_masks = processed_sample_list[self.mrc_mask_key]
  
      masked_output = compute_masked_hidden(
          sequence_output, image_region_masks
      )
      prediction_soft_label = self.region_classifier(masked_output)
      if self.use_kl:
          prediction_soft_label = F.log_softmax(
              prediction_soft_label, dim=-1
          )
          mrc_loss = F.kl_div(
              prediction_soft_label,
              region_labels,
              reduction="batchmean",
          )
      else:
          # background class should not be the target
          label_targets = torch.max(region_labels[:, 1:], dim=-1)[1] + 1
          mrc_loss = F.cross_entropy(
              prediction_soft_label,
              label_targets,
              ignore_index=self.ignore_index,
              reduction="mean",
          )
  
      output_dict["losses"] = {}
      output_dict["losses"][self.loss_name] = mrc_loss
      return output_dict
  
file_path: mmf/mmf/models/transformers/heads/mrc.py
imports: from typing import Dict
  import torch
  import torch.nn.functional
  from mmf.common.registry import registry
  from mmf.models.transformers.heads.utils import compute_masked_hidden
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling the MRC obj's underlying member method code with example usage: obj.forward(sequence_output, processed_sample_list) and returns: output_dict