code: def get_annotations(fname, prefix=None):
      "Open a COCO style json in `fname` and returns the lists of filenames (with maybe `prefix`) and labelled bboxes."
      annot_dict = json.load(open(fname))
      id2images, id2bboxes, id2cats = (
          {},
          collections.defaultdict(list),
          collections.defaultdict(list),
      )
      classes = {o["id"]: o["name"] for o in annot_dict["categories"]}
      for o in annot_dict["annotations"]:
          bb = o["bbox"]
          id2bboxes[o["image_id"]].append(
              [bb[0], bb[1], bb[0] + bb[2], bb[1] + bb[3]]
          )
          id2cats[o["image_id"]].append(classes[o["category_id"]])
      id2images = {
          o["id"]: ifnone(prefix, "") + o["file_name"]
          for o in annot_dict["images"]
          if o["id"] in id2bboxes
      }
      ids = list(id2images.keys())
      return [id2images[k] for k in ids], [
          (id2bboxes[k], id2cats[k]) for k in ids
      ]
  
imports: from __future__ import annotations
  from ..torch_basics import *
  from ..data.all import *
  from PIL import Image
  from matplotlib import patches, patheffects
label_desc: Use image node_id 12 for calling a global function with example usage: get_annotations(fname, prefix) and returns: unknown,  unknown