code: def parse_objects(
      data: dict, xml_path: str, class_dict: dict, idx: int
  ):
      """
      解析出bboxes、labels、iscrowd以及ares等信息
      Args:
          data: 将xml解析成dict的Annotation数据
          xml_path: 对应xml的文件路径
          class_dict: 类别与索引对应关系
          idx: 图片对应的索引
  
      Returns:
  
      """
      boxes = []
      labels = []
      iscrowd = []
      assert "object" in data, "{} lack of object information.".format(
          xml_path
      )
      for obj in data["object"]:
          xmin = float(obj["bndbox"]["xmin"])
          xmax = float(obj["bndbox"]["xmax"])
          ymin = float(obj["bndbox"]["ymin"])
          ymax = float(obj["bndbox"]["ymax"])
  
          # 进一步检查数据，有的标注信息中可能有w或h为0的情况，这样的数据会导致计算回归loss为nan
          if xmax <= xmin or ymax <= ymin:
              print(
                  "Warning: in '{}' xml, there are some bbox w/h <=0".format(
                      xml_path
                  )
              )
              continue
  
          boxes.append([xmin, ymin, xmax, ymax])
          labels.append(int(class_dict[obj["name"]]))
          if "difficult" in obj:
              iscrowd.append(int(obj["difficult"]))
          else:
              iscrowd.append(0)
  
      # convert everything into a torch.Tensor
      boxes = torch.as_tensor(boxes, dtype=torch.float32)
      labels = torch.as_tensor(labels, dtype=torch.int64)
      iscrowd = torch.as_tensor(iscrowd, dtype=torch.int64)
      image_id = torch.tensor([idx])
      area = (boxes[:, 3] - boxes[:, 1]) * (boxes[:, 2] - boxes[:, 0])
  
      return {
          "boxes": boxes,
          "labels": labels,
          "iscrowd": iscrowd,
          "image_id": image_id,
          "area": area,
      }
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/mask_rcnn/my_dataset_voc.py
imports: import os
  import json
  from lxml import etree
  import numpy
  from PIL import Image
  import torch
  from torch.utils.data import Dataset
  from train_utils import convert_to_coco_api
label_desc: Use image node_id 2 for calling a global function with example usage: parse_objects(data, xml_path, class_dict, idx) and returns: dict