code: def graph_to_dotfile(graph):
      visited = set()
  
      def node_to_fragment(node):
          visited.add(node)
          if node.isroot:
              return dot_variable_node(node, "input")
          fragment = dot_function_node(node, node.fun_name)
          for argnum, arg in enumerate(node.args):
              if argnum in node.parents:
                  parent = node.parents[argnum]
                  fragment += dot_edge(parent, node)
                  if parent not in visited:
                      fragment += node_to_fragment(parent)
              else:
                  argnode = "{}_arg_{}".format(node, argnum)
                  fragment += dot_edge(argnode, node)
                  fragment += dot_variable_node(argnode, arg)
  
          return fragment
  
      dot_body = node_to_fragment(graph)
      dot_body += dot_variable_node("output", "output")
      dot_body += dot_edge(graph, "output")
      return dot_graph(dot_body)
  
file_path: autograd/examples/dot_graph.py
imports: from __future__ import print_function
  import autograd.numpy
  from autograd.tracer import trace, Node
  from autograd import grad
label_desc: Use image node_id 2 for calling a global function with example usage: graph_to_dotfile(graph) and returns: dot_graph, fragment, dot_variable_node