code: def save_json(data, save_path, indent: Optional[int] = None):
      """
      Saves json formatted data (given as "data") as save_path
      Example inputs:
          data: {"image_id": 5}
          save_path: "dirname/coco.json"
          indent: Train json files with indent=None, val json files with indent=4
      """
      # create dir if not present
      Path(save_path).parent.mkdir(parents=True, exist_ok=True)
  
      # export as json
      with open(save_path, "w", encoding="utf-8") as outfile:
          json.dump(
              data,
              outfile,
              separators=(",", ":"),
              cls=NumpyEncoder,
              indent=indent,
          )
  
imports: import glob
  import json
  import ntpath
  import os
  import pickle
  import re
  import urllib.request
  import zipfile
  from pathlib import Path
  from typing import Optional
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: save_json(data, save_path, indent) without return types