def load_coco_panoptic_json(json_file, image_dir, gt_dir, semseg_dir, caption_file, grounding_file, lvis_file, meta):
    """
    Args:
        image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
        gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
        json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
    Returns:
        list[dict]: a list of dicts in Detectron2 standard format. (See
        `Using Custom Datasets </tutorials/datasets.html>`_ )
    """
    def _convert_category_id(segment_info, meta):
        if segment_info["category_id"] in meta["thing_dataset_id_to_contiguous_id"]:
            segment_info["category_id"] = meta["thing_dataset_id_to_contiguous_id"][
                segment_info["category_id"]
            ]
            segment_info["isthing"] = True
        else:
            segment_info["category_id"] = meta["stuff_dataset_id_to_contiguous_id"][
                segment_info["category_id"]
            ]
            segment_info["isthing"] = False
        return segment_info

    with PathManager.open(json_file) as f:
        json_info = json.load(f)

    with PathManager.open(caption_file) as f:
        caption_info = json.load(f)
    
    with PathManager.open(grounding_file) as f:
        grounding_info = json.load(f)

    with PathManager.open(lvis_file) as f:
        lvis_info = json.load(f)

    # build dict {image_id: Listof[captions]}
    cap_dict = collections.defaultdict(list)
    for cap_ann in caption_info['annotations']:
        image_id = int(cap_ann["image_id"])
        cap_dict[image_id].append(cap_ann["caption"])
        
    # build dictionary for grounding
    grd_dict = collections.defaultdict(list)
    for grd_ann in grounding_info['annotations']:
        image_id = int(grd_ann["image_id"])
        grd_dict[image_id].append(grd_ann)
    
    # build dictionary for lvis
    lvis_dict = collections.defaultdict(list)
    for lvis_ann in lvis_info['annotations']:
        image_id = int(lvis_ann["image_id"])
        lvis_dict[image_id].append(lvis_ann)

    ret = []
    for ann in json_info["annotations"]:
        image_id = int(ann["image_id"])
        # TODO: currently we assume image and label has the same filename but
        # different extension, and images have extension ".jpg" for COCO. Need
        # to make image extension a user-provided argument if we extend this
        # function to support other COCO-like datasets.
        image_file = os.path.join(image_dir, os.path.splitext(ann["file_name"])[0] + ".jpg")
        label_file = os.path.join(gt_dir, ann["file_name"])
        sem_label_file = os.path.join(semseg_dir, ann["file_name"])
        segments_info = [_convert_category_id(x, meta) for x in ann["segments_info"]]

        grounding_anno = grd_dict[image_id] if image_id in grd_dict else []
        lvis_anno = lvis_dict[image_id] if image_id in lvis_dict else []
        ret.append(
            {
                "file_name": image_file,
                "image_id": image_id,
                "captions": cap_dict[image_id],
                "grounding_info": grounding_anno,
                "lvis_info": lvis_anno,
                "pan_seg_file_name": label_file,
                "sem_seg_file_name": sem_label_file,
                "segments_info": segments_info,
            }
        )
    assert len(ret), f"No images found in {image_dir}!"
    assert PathManager.isfile(ret[0]["file_name"]), ret[0]["file_name"]
    assert PathManager.isfile(ret[0]["pan_seg_file_name"]), ret[0]["pan_seg_file_name"]
    assert PathManager.isfile(ret[0]["sem_seg_file_name"]), ret[0]["sem_seg_file_name"]
    return ret

    Args:
        image_dir (str): path to the raw dataset. e.g., "~/coco/train2017".
        gt_dir (str): path to the raw annotations. e.g., "~/coco/panoptic_train2017".
        json_file (str): path to the json file. e.g., "~/coco/annotations/panoptic_train2017.json".
    Returns:
        list[dict]: a list of dicts in Detectron2 standard format. (See
        `Using Custom Datasets </tutorials/datasets.html>`_ )
    
datasets/registration/register_coco_lvis_panoptic_annos_caption_grounding.py