docstr: Prepare ._gts and ._dts for evaluation based on params
  :return: None
docstr_tok: ["Prepare","._gts","and","._dts","for","evaluation","based","on","params",":","return",":","None"]
code: def _prepare(self):
      """
      Prepare ._gts and ._dts for evaluation based on params
      :return: None
      """
  
      def _toMask(anns, coco):
          # modify ann['segmentation'] by reference
          for ann in anns:
              rle = coco.annToRLE(ann)
              ann["segmentation"] = rle
  
      p = self.params
      if p.useCats:
          gts = []
          dts = []
          img_ids = set(p.imgIds)
          cat_ids = set(p.catIds)
          for gt in self.cocoGt.dataset["annotations"]:
              if (gt["category_id"] in cat_ids) and (
                  gt["image_id"] in img_ids
              ):
                  gts.append(gt)
          for dt in self.cocoDt.dataset["annotations"]:
              if (dt["category_id"] in cat_ids) and (
                  dt["image_id"] in img_ids
              ):
                  dts.append(dt)
          # gts=self.cocoGt.loadAnns(self.cocoGt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)) # noqa
          # dts=self.cocoDt.loadAnns(self.cocoDt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)) # noqa
          # gts=self.cocoGt.dataset['annotations']
          # dts=self.cocoDt.dataset['annotations']
      else:
          gts = self.cocoGt.loadAnns(
              self.cocoGt.getAnnIds(imgIds=p.imgIds)
          )
          dts = self.cocoDt.loadAnns(
              self.cocoDt.getAnnIds(imgIds=p.imgIds)
          )
  
      # convert ground truth to mask if iouType == 'segm'
      if p.iouType == "segm":
          _toMask(gts, self.cocoGt)
          _toMask(dts, self.cocoDt)
      # set ignore flag
      for gt in gts:
          gt["ignore"] = gt["ignore"] if "ignore" in gt else 0
          gt["ignore"] = "iscrowd" in gt and gt["iscrowd"]
          if p.iouType == "keypoints":
              gt["ignore"] = (gt["num_keypoints"] == 0) or gt["ignore"]
      self._gts = defaultdict(list)  # gt for evaluation
      self._dts = defaultdict(list)  # dt for evaluation
      for gt in gts:
          self._gts[gt["image_id"], gt["category_id"]].append(gt)
      for dt in dts:
          self._dts[dt["image_id"], dt["category_id"]].append(dt)
      self.evalImgs = defaultdict(
          list
      )  # per-image per-category evaluation results
      self.eval = {}
  
file_path: mmdetection/mmdet/datasets/api_wrappers/cocoeval_mp.py
imports: import copy
  import itertools
  import time
  from collections import defaultdict
  import numpy
  import torch.multiprocessing
  from mmengine.logging import MMLogger
  from pycocotools.cocoeval import COCOeval
  from tqdm import tqdm
label_desc: Use image node_id 1 for calling the COCOevalMP obj's underlying member method code with example usage: obj._prepare() without return types