class_docstr: Modification for Joint Vision-Language Encoding
class_docstr_tok: ["Modification","for","Joint","Vision-Language","Encoding"]
code: def get_attention_mask(
      self,
      sample_list: Dict[str, Tensor],
      text_embedding: Tensor,
      image_embedding: Tensor,
  ) -> Tensor:
      image_mask = getattr(sample_list, "image_mask", None)
  
      if image_mask is not None and sample_list.input_mask is not None:
          attention_mask = torch.cat(
              (sample_list.input_mask, image_mask), dim=-1
          )
      elif image_mask is not None:
          text_mask = torch.ones(
              text_embedding.size()[:-1],
              dtype=text_embedding.dtype,
              device=text_embedding.device,
          )
          attention_mask = torch.cat((image_mask, text_mask), dim=-1)
      elif sample_list.input_mask is not None:
          image_mask = torch.ones(
              image_embedding.size()[:-1],
              dtype=image_embedding.dtype,
              device=image_embedding.device,
          )
          attention_mask = torch.cat(
              (image_mask, sample_list.input_mask), dim=-1
          )
      else:
          attention_mask = None
  
      return attention_mask
  
imports: import copy
  import logging
  import random
  from collections import namedtuple
  from collections.abc import MutableMapping
  from dataclasses import asdict, dataclass, field
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.modules.losses import MMFLoss
  from mmf.utils.general import retry_n
  from omegaconf import DictConfig, MISSING, OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 8 for calling the UNITER obj's underlying member method code with example usage: obj.get_attention_mask(sample_list, text_embedding, image_embedding) and returns: attention_mask