class_docstr: Load and process the ``instances`` and ``seg_map`` annotation provided
  by dataset.
  
  The annotation format is as the following:
  
  .. code-block:: python
  
      {
          'instances':
          [
              {
              # List of 4 numbers representing the bounding box of the
              # instance, in (x1, y1, x2, y2) order.
              'bbox': [x1, y1, x2, y2],
  
              # Label of image classification.
              'bbox_label': 1,
  
              # Used in instance/panoptic segmentation. The segmentation mask
              # of the instance or the information of segments.
              # 1. If list[list[float]], it represents a list of polygons,
              # one for each connected component of the object. Each
              # list[float] is one simple polygon in the format of
              # [x1, y1, ..., xn, yn] (n >= 3). The Xs and Ys are absolute
              # coordinates in unit of pixels.
              # 2. If dict, it represents the per-pixel segmentation mask in
              # COCO's compressed RLE format. The dict should have keys
              # “size” and “counts”.  Can be loaded by pycocotools
              'mask': list[list[float]] or dict,
  
              }
          ]
          # Filename of semantic or panoptic segmentation ground truth file.
          'seg_map_path': 'a/b/c'
      }
  
  After this module, the annotation has been changed to the format below:
  
  .. code-block:: python
  
      {
          # In (x1, y1, x2, y2) order, float type. N is the number of bboxes
          # in an image
          'gt_bboxes': BaseBoxes(N, 4)
           # In int type.
          'gt_bboxes_labels': np.ndarray(N, )
           # In built-in class
          'gt_masks': PolygonMasks (H, W) or BitmapMasks (H, W)
           # In uint8 type.
          'gt_seg_map': np.ndarray (H, W)
           # in (x, y, v) order, float type.
      }
  
  Required Keys:
  
  - height
  - width
  - instances
  
    - bbox (optional)
    - bbox_label
    - mask (optional)
    - ignore_flag
  
  - seg_map_path (optional)
  
  Added Keys:
  
  - gt_bboxes (BaseBoxes[torch.float32])
  - gt_bboxes_labels (np.int64)
  - gt_masks (BitmapMasks | PolygonMasks)
  - gt_seg_map (np.uint8)
  - gt_ignore_flags (bool)
  
  Args:
      with_bbox (bool): Whether to parse and load the bbox annotation.
          Defaults to True.
      with_label (bool): Whether to parse and load the label annotation.
          Defaults to True.
      with_mask (bool): Whether to parse and load the mask annotation.
           Default: False.
      with_seg (bool): Whether to parse and load the semantic segmentation
          annotation. Defaults to False.
      poly2mask (bool): Whether to convert mask to bitmap. Default: True.
      box_type (str): The box type used to wrap the bboxes. If ``box_type``
          is None, gt_bboxes will keep being np.ndarray. Defaults to 'hbox'.
      reduce_zero_label (bool): Whether reduce all label value
          by 1. Usually used for datasets where 0 is background label.
          Defaults to False.
      ignore_index (int): The label index to be ignored.
          Valid only if reduce_zero_label is true. Defaults is 255.
      imdecode_backend (str): The image decoding backend type. The backend
          argument for :func:``mmcv.imfrombytes``.
          See :fun:``mmcv.imfrombytes`` for details.
          Defaults to 'cv2'.
      backend_args (dict, optional): Arguments to instantiate the
          corresponding backend. Defaults to None.
class_docstr_tok: ["Load","and","process","the","``","instances","``","and","``","seg_map","``","annotation","provided","by","dataset",".","The","annotation","format","is","as","the","following",":","..","code-block",":",":","python","{","'instances","'",":","[","{","#","List","of","4","numbers","representing","the","bounding","box","of","the","#","instance",",","in","(","x1",",","y1",",","x2",",","y2",")","order",".","'bbox","'",":","[","x1",",","y1",",","x2",",","y2","]",",","#","Label","of","image","classification",".","'bbox_label","'",":","1",",","#","Used","in","instance\/panoptic","segmentation",".","The","segmentation","mask","#","of","the","instance","or","the","information","of","segments",".","#","1",".","If","list","[","list","[","float","]","]",",","it","represents","a","list","of","polygons",",","#","one","for","each","connected","component","of","the","object",".","Each","#","list","[","float","]","is","one","simple","polygon","in","the","format","of","#","[","x1",",","y1",",","...",",","xn",",","yn","]","(","n",">","=","3",")",".","The","Xs","and","Ys","are","absolute","#","coordinates","in","unit","of","pixels",".","#","2",".","If","dict",",","it","represents","the","per-pixel","segmentation","mask","in","#","COCO","'s","compressed","RLE","format",".","The","dict","should","have","keys","#","\u201c","size","\u201d","and","\u201c","counts","\u201d",".","Can","be","loaded","by","pycocotools","'mask","'",":","list","[","list","[","float","]","]","or","dict",",","}","]","#","Filename","of","semantic","or","panoptic","segmentation","ground","truth","file",".","'seg_map_path","'",":","'","a\/b\/c'","}","After","this","module",",","the","annotation","has","been","changed","to","the","format","below",":","..","code-block",":",":","python","{","#","In","(","x1",",","y1",",","x2",",","y2",")","order",",","float","type",".","N","is","the","number","of","bboxes","#","in","an","image","'gt_bboxes","'",":","BaseBoxes","(","N",",","4",")","#","In","int","type",".","'gt_bboxes_labels","'",":","np.ndarray","(","N",",",")","#","In","built-in","class","'gt_masks","'",":","PolygonMasks","(","H",",","W",")","or","BitmapMasks","(","H",",","W",")","#","In","uint8","type",".","'gt_seg_map","'",":","np.ndarray","(","H",",","W",")","#","in","(","x",",","y",",","v",")","order",",","float","type.","}","Required","Keys",":","-","height","-","width","-","instances","-","bbox","(","optional",")","-","bbox_label","-","mask","(","optional",")","-","ignore_flag","-","seg_map_path","(","optional",")","Added","Keys",":","-","gt_bboxes","(","BaseBoxes","[","torch.float32","]",")","-","gt_bboxes_labels","(","np.int64",")","-","gt_masks","(","BitmapMasks","|","PolygonMasks",")","-","gt_seg_map","(","np.uint8",")","-","gt_ignore_flags","(","bool",")","Args",":","with_bbox","(","bool",")",":","Whether","to","parse","and","load","the","bbox","annotation",".","Defaults","to","True",".","with_label","(","bool",")",":","Whether","to","parse","and","load","the","label","annotation",".","Defaults","to","True",".","with_mask","(","bool",")",":","Whether","to","parse","and","load","the","mask","annotation",".","Default",":","False",".","with_seg","(","bool",")",":","Whether","to","parse","and","load","the","semantic","segmentation","annotation",".","Defaults","to","False",".","poly2mask","(","bool",")",":","Whether","to","convert","mask","to","bitmap",".","Default",":","True",".","box_type","(","str",")",":","The","box","type","used","to","wrap","the","bboxes",".","If","``","box_type","``","is","None",",","gt_bboxes","will","keep","being","np.ndarray",".","Defaults","to","'hbox","'",".","reduce_zero_label","(","bool",")",":","Whether","reduce","all","label","value","by","1",".","Usually","used","for","datasets","where","0","is","background","label",".","Defaults","to","False",".","ignore_index","(","int",")",":","The","label","index","to","be","ignored",".","Valid","only","if","reduce_zero_label","is","true",".","Defaults","is","255.","imdecode_backend","(","str",")",":","The","image","decoding","backend","type",".","The","backend","argument","for",":","func",":","``","mmcv.imfrombytes","``",".","See",":","fun",":","``","mmcv.imfrombytes","``","for","details",".","Defaults","to","'cv2","'",".","backend_args","(","dict",",","optional",")",":","Arguments","to","instantiate","the","corresponding","backend",".","Defaults","to","None","."]
docstr: Private function to load mask annotations.
  
  Args:
      results (dict): Result dict from :obj:``mmengine.BaseDataset``.
docstr_tok: ["Private","function","to","load","mask","annotations",".","Args",":","results","(","dict",")",":","Result","dict","from",":","obj",":","``","mmengine.BaseDataset","``","."]
code: def _load_masks(self, results: dict) -> None:
      """Private function to load mask annotations.
  
      Args:
          results (dict): Result dict from :obj:``mmengine.BaseDataset``.
      """
      h, w = results["ori_shape"]
      gt_masks = self._process_masks(results)
      if self.poly2mask:
          gt_masks = BitmapMasks(
              [self._poly2mask(mask, h, w) for mask in gt_masks], h, w
          )
      else:
          # fake polygon masks will be ignored in `PackDetInputs`
          gt_masks = PolygonMasks([mask for mask in gt_masks], h, w)
      results["gt_masks"] = gt_masks
  
imports: from typing import Optional, Tuple, Union
  import mmcv
  import numpy
  import pycocotools.mask
  import torch
  from mmcv.transforms import BaseTransform
  from mmcv.transforms import LoadAnnotations
  from mmcv.transforms import LoadImageFromFile
  from mmengine.fileio import get
  from mmengine.structures import BaseDataElement
  from mmdet.registry import TRANSFORMS
  from mmdet.structures.bbox import get_box_type
  from mmdet.structures.bbox.box_type import autocast_box_type
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
label_desc: Use image node_id 6 for calling the LoadAnnotations obj's underlying member method code with example usage: obj._load_masks(results) without return types