code: def main():
      ref_data_root = "<path/to/refer/data/folder>"
      all_refs = []
      for dataset, split_bys in [
          ("refcoco", ["google", "unc"]),
          ("refcoco+", ["unc"]),
          ("refcocog", ["google", "umd"]),
      ]:
          for split_by in split_bys:
              refer = REFER(ref_data_root, dataset, split_by)
              for ref_id in refer.getRefIds():
                  ref = refer.Refs[ref_id]
                  ann = refer.refToAnn[ref_id]
                  ref["ann"] = ann
                  ref["dataset"] = dataset
                  ref["dataset_partition"] = split_by
                  all_refs.append(ref)
  
      coco_annotations_file = "<path/to/instances_train2014.json>"
      coco = COCO(coco_annotations_file)
      ref_image_ids = set(x["image_id"] for x in all_refs)
      coco_anns = {
          image_id: {
              "info": coco.imgs[image_id],
              "anns": coco.imgToAnns[image_id],
          }
          for image_id in ref_image_ids
      }
  
      out_file = "<path/to/refcoco.json>"
      with open(out_file, "w") as f:
          json.dump({"ref": all_refs, "coco_anns": coco_anns}, f)
  
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types