code: def main():
      args = parse_args()
  
      cfg = Config.fromfile(args.config)
  
      # replace the ${key} with the value of cfg.key
      cfg = replace_cfg_vals(cfg)
  
      # update data root according to MMDET_DATASETS
      update_data_root(cfg)
  
      if args.cfg_options is not None:
          cfg.merge_from_dict(args.cfg_options)
  
      init_default_scope(cfg.get("default_scope", "mmdet"))
  
      results = load(args.prediction_path)
  
      if not os.path.exists(args.save_dir):
          os.makedirs(args.save_dir)
  
      dataset = DATASETS.build(cfg.test_dataloader.dataset)
  
      confusion_matrix = calculate_confusion_matrix(
          dataset,
          results,
          args.score_thr,
          args.nms_iou_thr,
          args.tp_iou_thr,
      )
      plot_confusion_matrix(
          confusion_matrix,
          dataset.metainfo["classes"] + ("background",),
          save_dir=args.save_dir,
          show=args.show,
          color_theme=args.color_theme,
      )
  
file_path: mmdetection/tools/analysis_tools/confusion_matrix.py
imports: import argparse
  import os
  import matplotlib.pyplot
  import numpy
  from matplotlib.ticker import MultipleLocator
  from mmcv.ops import nms
  from mmengine import Config, DictAction
  from mmengine.fileio import load
  from mmengine.registry import init_default_scope
  from mmengine.utils import ProgressBar
  from mmdet.evaluation import bbox_overlaps
  from mmdet.registry import DATASETS
  from mmdet.utils import replace_cfg_vals, update_data_root
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types