code: def to_html(nodes):
      listeners = []
      for i, n in enumerate(nodes):
          if n.context is None:
              continue
          s = _listener_template.format(
              id=str(i + 1), stack=escape(f"{n.label}:\n{n.context}")
          )
          listeners.append(s)
      dot = to_dot(nodes)
      return _template.replace("$DOT", repr(dot)).replace(
          "$LISTENERS", "\n".join(listeners)
      )
  
imports: import gc
  import sys
  from typing import Any, Dict, List, NamedTuple, Optional, Tuple
  import types
  import weakref
  import json
  from tempfile import NamedTemporaryFile
  import torch
  from torch.cuda._memory_viz import _frames_fmt, _block_extra
  import atexit
  import logging
label_desc: Use image node_id 10 for calling a global function with example usage: to_html(nodes) and returns: _template