class_docstr: Binary numpy array representation of a mask.
  
  # Arguments
      data: Mask array, with the dimensions: (num_instances, height, width)
      pad_dim: bool
docstr: From https://stackoverflow.com/a/49547872/6772672
docstr_tok: ["From","https",":","\/\/stackoverflow.com\/a\/49547872\/6772672"]
code: def to_coco_rle(self, h, w) -> List[dict]:
      """From https://stackoverflow.com/a/49547872/6772672"""
      assert self.data.shape[1:] == (h, w)
      rles = []
      for mask in self.data:
          counts = []
          flat = itertools.groupby(mask.ravel(order="F"))
          for i, (value, elements) in enumerate(flat):
              if i == 0 and value == 1:
                  counts.append(0)
              counts.append(len(list(elements)))
          rles.append({"counts": counts, "size": (h, w)})
      return rles
  
imports: from icevision.imports import *
  from icevision.utils import *
  from PIL import Image
label_desc: Use image node_id 7 for calling the MaskArray obj's underlying member method code with example usage: obj.to_coco_rle(h, w) and returns: rles