code: def build_computational_graph(
      outputs,
      remove_split=True,
      variable_style="default",
      function_style="default",
      rankdir="TB",
      remove_variable=False,
      show_name=True,
  ):
      """Builds a graph of functions and variables backward-reachable from outputs.
  
      Args:
          outputs (:class:`~chainer.Variable`, \
          :class:`~chainer.variable.VariableNode`, \
          :class:`~chainer.FunctionNode`, or :class:`list`): node(s) from which
              the graph is constructed.
              Each element of outputs must be either :class:`~chainer.Variable`
              object, :class:`~chainer.variable.VariableNode` object, or
              :class:`~chainer.FunctionNode` object.
          remove_split(bool): It must be ``True``. This argument is left for
              backward compatibility.
          variable_style(dict or 'default'): Dot node style for variable.
              Possible keys are 'shape', 'color', 'fillcolor', 'style' etc.
              If the special value ``'default'`` is specified, the default
              configuration will be used.
          function_style(dict or 'default'): Dot node style for function.
              Possible keys are 'shape', 'color', 'fillcolor', 'style' etc.
              If the special value ``'default'`` is specified, the default
              configuration will be used.
          rankdir (str): Direction of the graph that must be
              TB (top to bottom), BT (bottom to top), LR (left to right)
              or RL (right to left).
          remove_variable (bool): If ``True``, :class:`VariableNode`\\ s are
              removed from the resulting computational graph. Only
              :class:`FunctionNode`\\ s are shown in the output.
          show_name (bool): If ``True``, the ``name`` attribute of each node is
              added to the label of the node. Default is ``True``.
  
      Returns:
          ComputationalGraph: A graph consisting of nodes and edges that
          are backward-reachable from at least one of ``outputs``.
  
          If ``unchain_backward`` was called in some variable in the
          computational graph before this function, backward step is
          stopped at this variable.
  
          For example, suppose that computational graph is as follows::
  
                  |--> f ---> y
              x --+
                  |--> g ---> z
  
          Let ``outputs = [y, z]``.
          Then the full graph is emitted.
  
          Next, let ``outputs = [y]``. Note that ``z`` and ``g``
          are not backward-reachable from ``y``.
          The resulting graph would be following::
  
              x ---> f ---> y
  
          See :class:`TestGraphBuilder` for details.
  
      .. note::
  
         The default configuration for ``variable_style`` is
         ``{'shape': 'octagon', 'fillcolor': '#E0E0E0', 'style': 'filled'}`` and
         the default configuration for ``function_style`` is
         ``{'shape': 'record', 'fillcolor': '#6495ED', 'style': 'filled'}``.
  
      .. note::
  
          The default behavior of :class:`~chainer.ComputationalGraph` has been
          changed from v1.23.0, so that it ouputs the richest representation of
          a graph as default, namely, styles are set and names of functions and
          variables are shown. To reproduce the same result as previous versions
          (<= v1.22.0), please specify `variable_style=None`,
          `function_style=None`, and `show_name=False` explicitly.
  
      """
      if not remove_split:
          raise ValueError(
              "remove_split=False is not supported anymore"
          )
  
      output_types = (
          variable.Variable,
          variable.VariableNode,
          function_node.FunctionNode,
      )
  
      if isinstance(outputs, output_types):
          outputs = [outputs]
      else:
          if not all(isinstance(o, output_types) for o in outputs):
              raise TypeError(
                  "element of outputs must be either Variable, VariableNode, "
                  " or FunctionNode."
              )
  
      cands = []
      seen_edges = set()
      nodes = set()
      push_count = [0]
  
      def add_cand(cand):
          heapq.heappush(cands, (-cand.rank, push_count[0], cand))
          push_count[0] += 1
  
      for o in outputs:
          if isinstance(o, variable.Variable):
              o = o.node
          add_cand(o)
          nodes.add(o)
  
      while cands:
          _, _, cand = heapq.heappop(cands)
          if isinstance(cand, variable.VariableNode):
              creator = cand.creator_node
              if (
                  creator is not None
                  and (creator, cand) not in seen_edges
              ):
                  add_cand(creator)
                  seen_edges.add((creator, cand))
                  nodes.add(creator)
                  nodes.add(cand)
          elif isinstance(cand, function_node.FunctionNode):
              for input_ in cand.inputs:
                  if (
                      input_ is not cand
                      and (input_, cand) not in seen_edges
                  ):
                      add_cand(input_)
                      seen_edges.add((input_, cand))
                      nodes.add(input_)
                      nodes.add(cand)
      return ComputationalGraph(
          list(nodes),
          list(seen_edges),
          variable_style,
          function_style,
          rankdir,
          remove_variable,
          show_name,
      )
  
file_path: chainer/chainer/computational_graph.py
imports: import heapq
  from chainer import function_node
  from chainer import variable
label_desc: Use image node_id 2 for calling a global function with example usage: build_computational_graph(outputs, remove_split, variable_style, function_style, rankdir, remove_variable, show_name) and returns: ComputationalGraph