code: def test(self):
      # Make a dummy dataset.
      mask = make_mask()
      DatasetCatalog.register(
          "test_dataset", lambda: make_dataset_dicts(mask)
      )
      MetadataCatalog.get("test_dataset").set(
          thing_classes=["test_label"]
      )
  
      # Dump to json.
      json_dict = convert_to_coco_dict("test_dataset")
      with tempfile.TemporaryDirectory() as tmpdir:
          json_file_name = os.path.join(tmpdir, "test.json")
          with open(json_file_name, "w") as f:
              json.dump(json_dict, f)
          # Load from json.
          dicts = load_coco_json(json_file_name, "")
  
      # Check the loaded mask matches the original.
      anno = dicts[0]["annotations"][0]
      loaded_mask = mask_util.decode(anno["segmentation"])
      self.assertTrue(np.array_equal(loaded_mask, mask))
      DatasetCatalog.pop("test_dataset")
      MetadataCatalog.pop("test_dataset")
  
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 1 for calling the TestRLEToJson obj's underlying member method code with example usage: obj.test() without return types