code: def save_json_dict(filename, json_dict):
      """Save json to file. Error if path DNE, not a dict, or invalid json."""
      if isinstance(json_dict, dict):
          # this will raise a TypeError if something goes wrong
          json_string = _json.dumps(json_dict, indent=4)
          lock.acquire()
          with open(filename, "w") as f:
              f.write(json_string)
          lock.release()
      else:
          raise TypeError("json_dict was not a dictionary. not saving.")
  
file_path: plotly.py/packages/python/chart-studio/chart_studio/utils.py
imports: from __future__ import absolute_import
  import os.path
  import re
  import threading
  import warnings
  import json
  from _plotly_utils.exceptions import PlotlyError
  from _plotly_utils.optional_imports import get_module
label_desc: Use image node_id 2 for calling a global function with example usage: save_json_dict(filename, json_dict) without return types