code: def safe_json(obj):
      """Encode `obj` to JSON so that it can be embedded safely inside HTML.
  
      Parameters
      ----------
      obj : object
          object to serialize
      """
      return json.dumps(obj).replace("<", "\\u003c")
  
file_path: pytensor/pytensor/d3viz/d3viz.py
imports: import json
  import os
  import shutil
  from pytensor.d3viz.formatting import PyDotFormatter
label_desc: Use image node_id 2 for calling a global function with example usage: safe_json(obj) and returns: json