code: def to_dot(fun: Callable[..., Any]) -> Callable[..., str]:
      """Converts a function using Haiku modules to a dot graph.
  
      To view the resulting graph in Google Colab or an iPython notebook use the
      ``graphviz`` package:
  
      .. code-block::
  
          dot = hk.to_dot(f)(x)
          import graphviz
          graphviz.Source(dot)
  
      Args:
        fun: A function using Haiku modules.
  
      Returns:
        A function that returns the source code string to a graphviz graph
        describing the operations executed by the given function clustered by Haiku
        module.
  
      See Also:
        :func:`abstract_to_dot`: Generates a graphviz graph using abstract inputs.
      """
      graph_fun = to_graph(fun)
  
      @functools.wraps(fun)
      def wrapped_fun(*args) -> str:
          return _graph_to_dot(*graph_fun(*args))
  
      return wrapped_fun
  
imports: import collections
  import contextlib
  import functools
  import html
  from typing import Any, Callable, NamedTuple, Optional
  from haiku._src import data_structures
  from haiku._src import module
  from haiku._src import utils
  import jax
  import jax.core
  from jax.experimental import pjit
  from jax.extend import linear_util
label_desc: Use image node_id 1 for calling a global function with example usage: to_dot(fun) and returns: wrapped_fun, _graph_to_dot