code: def update_sample_list_based_on_head(self, sample_list):
      bert_input_ids = sample_list.input_ids
      bert_input_mask = sample_list.input_mask
      bert_input_type_ids = sample_list.segment_ids
  
      if self.config.training_head_type == "nlvr2":
          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_info = getattr(img0, "image_info_0", {})
          image_dim_variable_0 = getattr(
              image_info, "max_features", None
          )
          image_feat_variable_0 = getattr(img0, "image_feature_0", None)
  
          img1 = getattr(sample_list, "img1", {})
          image_info = getattr(img1, "image_info_0", {})
          image_dim_variable_1 = getattr(
              image_info, "max_features", None
          )
          image_feat_variable_1 = getattr(img1, "image_feature_0", None)
  
          image_feat_variable = torch.cat(
              [image_feat_variable_0, image_feat_variable_1]
          )
          image_dim_variable = torch.cat(
              [image_dim_variable_0, image_dim_variable_1]
          )
      else:
          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
          )
  
      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 logging
  import math
  import os
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.modules.embeddings import BertVisioLinguisticEmbeddings
  from mmf.utils.configuration import get_mmf_cache_dir
  from mmf.utils.file_io import PathManager
  from mmf.utils.modeling import get_optimizer_parameters_for_bert
  from mmf.utils.transform import transform_to_batch_sequence, transform_to_batch_sequence_dim
  from omegaconf import OmegaConf
  from torch import nn
label_desc: Use image node_id 6 for calling the VisualBERTModule obj's underlying member method code with example usage: obj.update_sample_list_based_on_head(sample_list) and returns: sample_list