docstr: Tests cascade rpn head loss and predict function.
docstr_tok: ["Tests","cascade","rpn","head","loss","and","predict","function","."]
code: def test_cascade_rpn_head_loss_and_predict(self):
      """Tests cascade rpn head loss and predict function."""
      cascade_rpn_head = CascadeRPNHead(**cascade_rpn_config)
  
      s = 256
      feats = [
          torch.rand(1, 1, s // stride[1], s // stride[0])
          for stride in cascade_rpn_head.stages[
              0
          ].prior_generator.strides
      ]
      img_metas = {
          "img_shape": (s, s),
          "pad_shape": (s, s),
          "scale_factor": 1,
      }
      sample = DetDataSample()
      sample.set_metainfo(img_metas)
  
      gt_instances = InstanceData()
      gt_instances.bboxes = torch.empty((0, 4))
      gt_instances.labels = torch.LongTensor([])
      sample.gt_instances = gt_instances
      proposal_cfg = ConfigDict(
          dict(max_per_img=300, nms=dict(iou_threshold=0.8))
      )
  
      cascade_rpn_head.loss_and_predict(feats, [sample], proposal_cfg)
  
file_path: mmdetection/tests/test_models/test_dense_heads/test_cascade_rpn_head.py
imports: from unittest import TestCase
  import torch
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from mmdet.models.dense_heads import CascadeRPNHead
  from mmdet.structures import DetDataSample
label_desc: Use image node_id 2 for calling the TestStageCascadeRPNHead obj's underlying member method code with example usage: obj.test_cascade_rpn_head_loss_and_predict() without return types