code: def get_attention_mask(
      self,
      sample_list: Dict[str, Tensor],
      text_embedding: Tensor,
      image_embedding: Tensor,
  ) -> Tensor:
      text_mask = getattr(sample_list, "input_mask", None)
      image_mask = getattr(sample_list, "image_mask", None)
  
      if text_mask is None and image_mask is None:
          return None
  
      if text_mask is None:
          text_mask = torch.ones(
              text_embedding.size()[:-1],
              dtype=text_embedding.dtype,
              device=text_embedding.device,
          )
  
      if image_mask is None:
          image_mask = torch.ones(
              image_embedding.size()[:-1],
              dtype=image_embedding.dtype,
              device=image_embedding.device,
          )
  
      attention_mask = torch.cat((text_mask, image_mask), dim=-1)
      return attention_mask
  
imports: import collections.abc
  import logging
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.models.transformers.heads.utils import build_heads_dict
  from mmf.modules.encoders import TransformerEncoder, ViTEncoder
  from mmf.modules.losses import MMFLoss
  from mmf.utils.build import build_encoder
  from mmf.utils.modeling import get_bert_configured_parameters
  from omegaconf import MISSING, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 7 for calling the ViLT obj's underlying member method code with example usage: obj.get_attention_mask(sample_list, text_embedding, image_embedding) and returns: attention_mask, None