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 _get_attention_mask(
      self,
      image_feat: Tensor,
      image_info: Dict[str, Tensor],
      input_mask: Tensor,
  ) -> Tensor:
      # image_dim = (bs,)
      # with the number of features per image in the batch as an int
      image_dim = image_info.get("max_features")
      if image_dim is None:
          image_mask = torch.ones(
              (image_feat.size(0), image_feat.size(1)),
              device=image_feat.device,
          ).long()
      else:
          image_mask = torch.arange(
              image_feat.size(-2), device=image_feat.device
          ).expand(image_feat.size()[:-1])
          if len(image_dim.size()) < len(image_mask.size()):
              image_dim = image_dim.unsqueeze(-1)
              assert len(image_dim.size()) == len(image_mask.size())
          image_mask = image_mask < image_dim
          image_mask = image_mask.long()
  
      attention_mask = torch.cat((input_mask, image_mask), dim=-1)
      return attention_mask
  
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 6 for calling the VinVL obj's underlying member method code with example usage: obj._get_attention_mask(image_feat, image_info, input_mask) and returns: attention_mask