code: def save_info(
      coco_evaluator,
      category_index: dict,
      save_name: str = "record_mAP.txt",
  ):
      iou_type = coco_evaluator.params.iouType
      print(f"IoU metric: {iou_type}")
      # calculate COCO info for all classes
      coco_stats, print_coco = summarize(coco_evaluator)
  
      # calculate voc info for every classes(IoU=0.5)
      classes = [v for v in category_index.values() if v != "N/A"]
      voc_map_info_list = []
      for i in range(len(classes)):
          stats, _ = summarize(coco_evaluator, catId=i)
          voc_map_info_list.append(
              " {:15}: {}".format(classes[i], stats[1])
          )
  
      print_voc = "\n".join(voc_map_info_list)
      print(print_voc)
  
      # 将验证结果保存至txt文件中
      with open(save_name, "w") as f:
          record_lines = [
              "COCO results:",
              print_coco,
              "",
              "mAP(IoU=0.5) for each category:",
              print_voc,
          ]
          f.write("\n".join(record_lines))
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/mask_rcnn/validation.py
imports: import os
  import json
  import torch
  from tqdm import tqdm
  import numpy
  import transforms
  from backbone import resnet50_fpn_backbone
  from network_files import MaskRCNN
  from my_dataset_coco import CocoDetection
  from my_dataset_voc import VOCInstances
  from train_utils import EvalCOCOMetric
label_desc: Use image node_id 2 for calling a global function with example usage: save_info(coco_evaluator, category_index, save_name) without return types