class_docstr: VinVL base model called by MMF.
  VinVL paper, 3-way contrastive loss:
  https://arxiv.org/pdf/2101.00529.pdf
  
  Implementation based on https://github.com/microsoft/Oscar
  
  Expects VinVL features extracted by
  https://github.com/microsoft/scene_graph_benchmark
  using Visual Genome object detection labels.
  
  The label map used for training is available at
  https://github.com/microsoft/scene_graph_benchmark/blob/main/README.md
code: def forward(
      self, sample_list: Dict[str, Tensor]
  ) -> Dict[str, Tensor]:
      attention_mask = self._get_attention_mask(
          sample_list["image_feature_0"],
          sample_list["image_info_0"],
          sample_list["input_mask"],
      )
  
      if self.do_pretraining:
          corrupt_attention_mask = self._get_attention_mask(
              sample_list["image_feature_0"],
              sample_list["image_info_0"],
              sample_list["input_mask_corrupt"],
          )
          return self.vinvl(
              sample_list["input_ids_masked"],
              sample_list["input_ids_corrupt"],
              sample_list["lm_label_ids"],
              sample_list["contrastive_labels"],
              sample_list["segment_ids"],
              attention_mask,
              sample_list["segment_ids_corrupt"],
              corrupt_attention_mask,
              sample_list["image_feature_0"],
          )
      else:
          return self.vinvl(
              sample_list["input_ids"],
              sample_list["segment_ids"],
              attention_mask,
              sample_list["image_feature_0"],
              labels=sample_list.get("labels"),
          )
  
imports: import logging
  from collections import namedtuple
  from dataclasses import asdict, dataclass
  from typing import Any, Dict, Optional, Tuple
  import torch
  from mmf.common.registry import registry
  from mmf.common.sample import SampleList
  from mmf.models.base_model import BaseModel
  from mmf.models.transformers.heads.contrastive import ThreeWayContrastive
  from mmf.models.transformers.heads.mlm import MLM
  from mmf.models.transformers.heads.mlp import MLP
  from mmf.utils.general import retry_n
  from omegaconf import MISSING, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 5 for calling the VinVL obj's underlying member method code with example usage: obj.forward(sample_list) and returns: self, self