code: def make_dataset_dicts(mask, compressed: bool = True):
      """
      Returns a list of dicts that represents a single COCO data point for
      object detection. The single instance given by `mask` is represented by
      RLE, either compressed or uncompressed.
      """
      record = {}
      record["file_name"] = "test"
      record["image_id"] = 0
      record["height"] = mask.shape[0]
      record["width"] = mask.shape[1]
  
      y, x = np.nonzero(mask)
      if compressed:
          segmentation = mask_util.encode(np.asarray(mask, order="F"))
      else:
          segmentation = uncompressed_rle(mask)
      min_x = np.min(x)
      max_x = np.max(x)
      min_y = np.min(y)
      max_y = np.max(y)
      obj = {
          "bbox": [min_x, min_y, max_x, max_y],
          "bbox_mode": BoxMode.XYXY_ABS,
          "category_id": 0,
          "iscrowd": 0,
          "segmentation": segmentation,
      }
      record["annotations"] = [obj]
      return [record]
  
file_path: detectron2/tests/data/test_coco.py
imports: import json
  import numpy
  import os
  import tempfile
  import unittest
  import pycocotools.mask
  from detectron2.data import DatasetCatalog, MetadataCatalog
  from detectron2.data.datasets.coco import convert_to_coco_dict, load_coco_json
  from detectron2.structures import BoxMode
label_desc: Use image node_id 3 for calling a global function with example usage: make_dataset_dicts(mask, compressed) and returns: list