class_docstr: Filter invalid annotations.
  
  Required Keys:
  
  - gt_bboxes (BaseBoxes[torch.float32]) (optional)
  - gt_bboxes_labels (np.int64) (optional)
  - gt_masks (BitmapMasks | PolygonMasks) (optional)
  - gt_ignore_flags (bool) (optional)
  
  Modified Keys:
  
  - gt_bboxes (optional)
  - gt_bboxes_labels (optional)
  - gt_masks (optional)
  - gt_ignore_flags (optional)
  
  Args:
      min_gt_bbox_wh (tuple[float]): Minimum width and height of ground truth
          boxes. Default: (1., 1.)
      min_gt_mask_area (int): Minimum foreground area of ground truth masks.
          Default: 1
      by_box (bool): Filter instances with bounding boxes not meeting the
          min_gt_bbox_wh threshold. Default: True
      by_mask (bool): Filter instances with masks not meeting
          min_gt_mask_area threshold. Default: False
      keep_empty (bool): Whether to return None when it
          becomes an empty bbox after filtering. Defaults to True.
class_docstr_tok: ["Filter","invalid","annotations",".","Required","Keys",":","-","gt_bboxes","(","BaseBoxes","[","torch.float32","]",")","(","optional",")","-","gt_bboxes_labels","(","np.int64",")","(","optional",")","-","gt_masks","(","BitmapMasks","|","PolygonMasks",")","(","optional",")","-","gt_ignore_flags","(","bool",")","(","optional",")","Modified","Keys",":","-","gt_bboxes","(","optional",")","-","gt_bboxes_labels","(","optional",")","-","gt_masks","(","optional",")","-","gt_ignore_flags","(","optional",")","Args",":","min_gt_bbox_wh","(","tuple","[","float","]",")",":","Minimum","width","and","height","of","ground","truth","boxes",".","Default",":","(","1.",",","1",".",")","min_gt_mask_area","(","int",")",":","Minimum","foreground","area","of","ground","truth","masks",".","Default",":","1","by_box","(","bool",")",":","Filter","instances","with","bounding","boxes","not","meeting","the","min_gt_bbox_wh","threshold",".","Default",":","True","by_mask","(","bool",")",":","Filter","instances","with","masks","not","meeting","min_gt_mask_area","threshold",".","Default",":","False","keep_empty","(","bool",")",":","Whether","to","return","None","when","it","becomes","an","empty","bbox","after","filtering",".","Defaults","to","True","."]
code: def __init__(
      self,
      min_gt_bbox_wh: Tuple[int, int] = (1, 1),
      min_gt_mask_area: int = 1,
      by_box: bool = True,
      by_mask: bool = False,
      keep_empty: bool = True,
  ) -> None:
      # TODO: add more filter options
      assert by_box or by_mask
      self.min_gt_bbox_wh = min_gt_bbox_wh
      self.min_gt_mask_area = min_gt_mask_area
      self.by_box = by_box
      self.by_mask = by_mask
      self.keep_empty = keep_empty
  
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 1 to create a new FilterAnnotations object from inherited base classes: BaseTransform with example: obj = FilterAnnotations(min_gt_bbox_wh, min_gt_mask_area, by_box, by_mask, keep_empty)