code: def dump_json(filename, data):
      """Dump a dictionary to a file in JSON format.
  
      Args:
          filename(str): Filename for the file.
          data(dict): Data to save to file.
  
      """
      pathlib.Path(os.path.dirname(filename)).mkdir(
          parents=True, exist_ok=True
      )
      with open(filename, "w") as f:
          # We do our own circular reference handling.
          # Sometimes sort_keys fails because the keys don't get made into
          # strings early enough.
          json.dump(
              data,
              f,
              indent=2,
              sort_keys=False,
              cls=LogEncoder,
              check_circular=False,
          )
  
imports: import collections
  import datetime
  import enum
  import functools
  import gc
  import inspect
  import json
  import os
  import pathlib
  import subprocess
  import warnings
  import weakref
  import dateutil.tz
  import dowel
  from dowel import logger
  import numpy
  import __main__
label_desc: Use image node_id 4 for calling a global function with example usage: dump_json(filename, data) without return types