code: def test_modal_end_token(self):
      finetune_model = build_model(self.model_config)
      finetune_model.eval()
  
      # Suppose 0 for <cls>, 1 for <pad> 2 for <sep>
      CLS = 0
      PAD = 1
      SEP = 2
      size = 128
  
      input_ids = torch.randint(low=0, high=30255, size=(size,)).long()
      input_mask = torch.ones(size).long()
  
      input_ids[0] = CLS
      length = torch.randint(low=2, high=size - 1, size=(1,))
      input_ids[length] = SEP
      input_ids[length + 1 :] = PAD
      input_mask[length + 1 :] = 0
  
      test_sample = Sample()
      test_sample.input_ids = input_ids.clone()
      test_sample.input_mask = input_mask.clone()
      test_sample.segment_ids = torch.zeros(size).long()
      test_sample.image = torch.rand((3, 300, 300)).float()
      test_sample_list = SampleList([test_sample])
  
      mmbt_base = finetune_model.model.bert
      with torch.no_grad():
          actual_modal_end_token = mmbt_base.extract_modal_end_token(
              test_sample_list
          )
  
      expected_modal_end_token = torch.zeros([1]).fill_(SEP).long()
      self.assertTrue(
          torch.equal(actual_modal_end_token, expected_modal_end_token)
      )
      self.assertTrue(
          torch.equal(test_sample_list.input_ids[0, :-1], input_ids[1:])
      )
      self.assertTrue(
          torch.equal(
              test_sample_list.input_mask[0, :-1], input_mask[1:]
          )
      )
  
imports: import gc
  import unittest
  import tests.test_utils
  import torch
  from mmf.common.sample import Sample, SampleList
  from mmf.models.mmbt import MMBT
  from mmf.modules.encoders import ImageEncoderFactory, ImageEncoderTypes, ResNet152ImageEncoder, TextEncoderFactory, TextEncoderTypes
  from mmf.modules.hf_layers import undo_replace_with_jit
  from mmf.utils.build import build_model
  from mmf.utils.configuration import Configuration
  from mmf.utils.env import setup_imports, teardown_imports
  from omegaconf import OmegaConf
label_desc: Use image node_id 5 for calling the TestMMBTTorchscript obj's underlying member method code with example usage: obj.test_modal_end_token() without return types