code: def update_sample_list_based_on_head(
      self, sample_list: Dict[str, Tensor]
  ) -> Dict[str, Tensor]:
      bert_input_ids = sample_list["input_ids"]
      bert_input_mask = sample_list["input_mask"]
      bert_input_type_ids = sample_list["segment_ids"]
  
      if self.training_head_type == "nlvr2":
          if not torch.jit.is_scripting():
              bert_input_ids = torch.cat(
                  [bert_input_ids, bert_input_ids]
              )
              bert_input_mask = torch.cat(
                  [bert_input_mask, bert_input_mask]
              )
              bert_input_type_ids = torch.cat(
                  [bert_input_type_ids, bert_input_type_ids]
              )
  
              # image input
              img0 = getattr(sample_list, "img0", {})
              image_feat_variable_0 = getattr(
                  img0, "image_feature_0", None
              )
              img1 = getattr(sample_list, "img1", {})
              image_feat_variable_1 = getattr(
                  img1, "image_feature_0", None
              )
              image_feat_variable = torch.cat(
                  [image_feat_variable_0, image_feat_variable_1]
              )
  
              image_info = getattr(img0, "image_info_0", {})
              image_dim_variable_0 = getattr(
                  image_info, "max_features", None
              )
              image_info = getattr(img1, "image_info_0", {})
              image_dim_variable_1 = getattr(
                  image_info, "max_features", None
              )
              image_dim_variable = torch.cat(
                  [image_dim_variable_0, image_dim_variable_1]
              )
          else:
              raise RuntimeError(
                  "nlvr2 head doesn't support scripting as of now"
              )
      else:
          if not torch.jit.is_scripting():
              image_info = getattr(sample_list, "image_info_0", {})
              image_dim_variable = getattr(
                  image_info, "max_features", None
              )
              image_feat_variable = getattr(
                  sample_list, "image_feature_0", None
              )
          else:
              image_feat_variable = sample_list["image_feature_0"]
              image_dim_variable = None
  
      if image_dim_variable is None:
          image_dim_variable = sample_list["image_feature_0"].new_full(
              size=(image_feat_variable.size(0), 1),
              fill_value=image_feat_variable.size(1),
          )
  
      sample_list["visual_embeddings"] = image_feat_variable
      sample_list["image_dim"] = image_dim_variable
      sample_list["input_ids"] = bert_input_ids
      sample_list["input_mask"] = bert_input_mask
      sample_list["token_type_ids"] = bert_input_type_ids
      return sample_list
  
imports: import os
  from copy import deepcopy
  from typing import Dict, List, Optional, Tuple
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.modules.embeddings import BertVisioLinguisticEmbeddings
  from mmf.modules.hf_layers import BertEncoderJit, BertLayerJit
  from mmf.utils.configuration import get_mmf_cache_dir
  from mmf.utils.modeling import get_optimizer_parameters_for_bert
  from mmf.utils.torchscript import getattr_torchscriptable
  from mmf.utils.transform import transform_to_batch_sequence, transform_to_batch_sequence_dim
  from omegaconf import OmegaConf
  from torch import nn, Tensor
label_desc: Use image node_id 8 for calling the VisualBERT obj's underlying member method code with example usage: obj.update_sample_list_based_on_head(sample_list) and returns: sample_list