class_docstr: Attribute:
      polygons (list[ndarray]): list[ndarray]: polygons for this mask.
          Each ndarray has format [x, y, x, y, ...]
      mask (ndarray): a binary mask
class_docstr_tok: ["Attribute",":","polygons","(","list","[","ndarray","]",")",":","list","[","ndarray","]",":","polygons","for","this","mask",".","Each","ndarray","has","format","[","x",",","y",",","x",",","y",",","...","]","mask","(","ndarray",")",":","a","binary","mask"]
code: def __init__(self, mask_or_polygons, height, width):
      self._mask = self._polygons = self._has_holes = None
      self.height = height
      self.width = width
  
      m = mask_or_polygons
      if isinstance(m, dict):
          # RLEs
          assert "counts" in m and "size" in m
          if isinstance(m["counts"], list):  # uncompressed RLEs
              h, w = m["size"]
              assert h == height and w == width
              m = mask_util.frPyObjects(m, h, w)
          self._mask = mask_util.decode(m)[:, :]
          return
  
      if isinstance(m, list):  # list[ndarray]
          self._polygons = [np.asarray(x).reshape(-1) for x in m]
          return
  
      if isinstance(m, np.ndarray):  # assumed to be a binary mask
          assert m.shape[1] != 2, m.shape
          assert m.shape == (
              height,
              width,
          ), f"mask shape: {m.shape}, target dims: {height}, {width}"
          self._mask = m.astype("uint8")
          return
  
      raise ValueError(
          "GenericMask cannot handle object {} of type '{}'".format(
              m, type(m)
          )
      )
  
imports: import colorsys
  import logging
  import math
  import numpy
  from enum import Enum, unique
  import cv2
  import matplotlib
  import matplotlib.colors
  import matplotlib.figure
  import pycocotools.mask
  import torch
  from matplotlib.backends.backend_agg import FigureCanvasAgg
  from PIL import Image
  from detectron2.data import MetadataCatalog
  from detectron2.structures import BitMasks, Boxes, BoxMode, Keypoints, PolygonMasks, RotatedBoxes
  from detectron2.utils.file_io import PathManager
  from .colormap import random_color
label_desc: Use image node_id 1 to create a new GenericMask object  with example: obj = GenericMask(mask_or_polygons, height, width)