code: def preprocess_sample(
      self, sample_list: Dict[str, Tensor], image_embedding: Tensor
  ):
      head_names = self.heads_dict.head_names
      if isinstance(head_names, collections.abc.Mapping):
          head_names = head_names[sample_list["dataset_name"]]
  
      head_string = " ".join(head_names)
      prepare_itm = "itm" in head_string
      prepare_mlm = "mlm" in head_string
  
      if prepare_itm:
          sample_list["itm_labels"] = self._infer_itm_labels(
              sample_list
          )
      if prepare_mlm:
          sample_list["mlm_labels"] = self._infer_mlm_labels(
              sample_list, image_embedding.size()[:-1]
          )
          self._encode_mlm(sample_list, image_embedding)
  
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 5 for calling the ViLT obj's underlying member method code with example usage: obj.preprocess_sample(sample_list, image_embedding) without return types