code: def test_qdtrack_forward_loss_mode(self, cfg_file, devices):
      message_hub = MessageHub.get_instance(
          f"test_qdtrack_forward_loss_mode-{time.time()}"
      )
      message_hub.update_info("iter", 0)
      message_hub.update_info("epoch", 0)
      assert all([device in ["cpu", "cuda"] for device in devices])
  
      for device in devices:
          _model = get_detector_cfg(cfg_file)
          # _scope_ will be popped after build
          model = MODELS.build(_model)
  
          if device == "cuda":
              if not torch.cuda.is_available():
                  return unittest.skip(
                      "test requires GPU and torch+cuda"
                  )
              model = model.cuda()
  
          packed_inputs = demo_track_inputs(
              batch_size=1,
              num_frames=2,
              key_frames_inds=[0],
              image_shapes=(3, 128, 128),
              num_items=None,
          )
          out_data = model.data_preprocessor(packed_inputs, True)
          inputs, data_samples = (
              out_data["inputs"],
              out_data["data_samples"],
          )
          # Test forward
          losses = model.forward(inputs, data_samples, mode="loss")
          assert isinstance(losses, dict)
  
file_path: mmdetection/tests/test_models/test_mot/test_qdtrack.py
imports: import time
  import unittest
  from unittest import TestCase
  import torch
  from mmengine.logging import MessageHub
  from mmengine.registry import init_default_scope
  from parameterized import parameterized
  from mmdet.registry import MODELS
  from mmdet.testing import demo_track_inputs, get_detector_cfg
label_desc: Use image node_id 3 for calling the TestQDTrack obj's underlying member method code with example usage: obj.test_qdtrack_forward_loss_mode(cfg_file, devices) and returns: unittest