code: def forward(
      self,
      sequence_output: torch.Tensor,
      encoded_layers: Optional[List[torch.Tensor]] = None,
      processed_sample_list: Optional[
          Dict[str, Dict[str, torch.Tensor]]
      ] = None,
  ):
      assert (
          processed_sample_list is not None
      ), "ITM head requires 'processed_sample_list' argument"
  
      output_dict = {}
  
      if self.config.itm_label_key in processed_sample_list:
          next_sentence_labels = processed_sample_list[
              self.config.itm_label_key
          ]
      else:
          assert (
              LABEL_KEY in processed_sample_list
              and processed_sample_list[LABEL_KEY] is not None
          ), (
              f"ITM pretraining requires {LABEL_KEY} to be in sample "
              + "list with value not None."
          )
  
          next_sentence_labels = processed_sample_list[LABEL_KEY][
              self.config.itm_label_key
          ]
  
      pooled_output = self.pooler(sequence_output)
      seq_relationship_score = self.cls(pooled_output)
      itm_loss = self.ce_loss(
          seq_relationship_score.contiguous().view(-1, 2),
          next_sentence_labels.contiguous().view(-1),
      )
      output_dict["losses"] = {}
      output_dict["losses"][self.config.loss_name] = itm_loss
      return output_dict
  
file_path: mmf/mmf/models/transformers/heads/itm.py
imports: from dataclasses import dataclass
  from typing import Dict, List, Optional
  import torch
  from mmf.common.registry import registry
  from mmf.models.transformers.base import BaseTransformerHead
label_desc: Use image node_id 2 for calling the ITM obj's underlying member method code with example usage: obj.forward(sequence_output, encoded_layers, processed_sample_list) and returns: output_dict