code: def test_coco_run(self):
      coco_metric = COCOMetric(
          classes=["c0", "c1", "c2"], iou_list=[0.1], max_detection=[10]
      )
  
      num_images = 10
  
      val_outputs_all = []
      val_targets_all = []
      for _ in range(num_images):
          # randomly generate gt boxes and pred boxes
          num_gt_boxes = random.randint(1, 3)
          num_pred_boxes = random.randint(0, 3)
  
          box_start = torch.randint(3, (num_pred_boxes, 3))
          box_stop = box_start + torch.randint(
              1, 32, (num_pred_boxes, 3)
          )
          boxes = torch.cat((box_start, box_stop), dim=1).to(
              torch.float16
          )
          val_outputs_all.append(
              {
                  "boxes": boxes,
                  "labels": torch.randint(3, (num_pred_boxes,)),
                  "scores": torch.randn((num_pred_boxes,)).absolute(),
              }
          )
  
          box_start = torch.randint(3, (num_gt_boxes, 3))
          box_stop = box_start + torch.randint(1, 32, (num_gt_boxes, 3))
          boxes = torch.cat((box_start, box_stop), dim=1).to(
              torch.float16
          )
          val_targets_all.append(
              {
                  "boxes": boxes,
                  "labels": torch.randint(3, (num_gt_boxes,)),
              }
          )
  
      results_metric = matching_batch(
          iou_fn=box_iou,
          iou_thresholds=coco_metric.iou_thresholds,
          pred_boxes=[
              val_data_i["boxes"].numpy()
              for val_data_i in val_outputs_all
          ],
          pred_classes=[
              val_data_i["labels"].numpy()
              for val_data_i in val_outputs_all
          ],
          pred_scores=[
              val_data_i["scores"].numpy()
              for val_data_i in val_outputs_all
          ],
          gt_boxes=[
              val_data_i["boxes"].numpy()
              for val_data_i in val_targets_all
          ],
          gt_classes=[
              val_data_i["labels"].numpy()
              for val_data_i in val_targets_all
          ],
      )
      val_epoch_metric_dict = coco_metric(results_metric)[0]
      np.testing.assert_array_less(
          [-16.01], [sum(val_epoch_metric_dict.values())]
      )
  
file_path: MONAI/tests/test_detection_coco_metrics.py
imports: from __future__ import annotations
  import random
  import unittest
  import numpy
  import torch
  from monai.apps.detection.metrics.coco import COCOMetric
  from monai.apps.detection.metrics.matching import matching_batch
  from monai.data.box_utils import box_iou
label_desc: Use image node_id 1 for calling the TestCOCOMetrics obj's underlying member method code with example usage: obj.test_coco_run() without return types