code: def stop_gradient(
      graph,
      stop_edges=True,
      stop_nodes=True,
      stop_globals=True,
      name="graph_stop_gradient",
  ):
      """Stops the gradient flow through a graph.
  
      Args:
        graph: An instance of `graphs.GraphsTuple` containing `Tensor`s.
        stop_edges: (bool, default=True) indicates whether to stop gradients for
          the edges.
        stop_nodes: (bool, default=True) indicates whether to stop gradients for
          the nodes.
        stop_globals: (bool, default=True) indicates whether to stop gradients for
          the globals.
        name: (string, optional) A name for the operation.
  
      Returns:
        GraphsTuple after stopping the gradients according to the provided
        parameters.
  
      Raises:
        ValueError: If attempting to stop gradients through a field which has a
          `None` value in `graph`.
      """
  
      base_err_msg = "Cannot stop gradient through {0} if {0} are None"
      fields_to_stop = []
      if stop_globals:
          if graph.globals is None:
              raise ValueError(base_err_msg.format(GLOBALS))
          fields_to_stop.append(GLOBALS)
      if stop_nodes:
          if graph.nodes is None:
              raise ValueError(base_err_msg.format(NODES))
          fields_to_stop.append(NODES)
      if stop_edges:
          if graph.edges is None:
              raise ValueError(base_err_msg.format(EDGES))
          fields_to_stop.append(EDGES)
  
      with tf.name_scope(name):
          return graph.map(tf.stop_gradient, fields_to_stop)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import functools
  from absl import logging
  from graph_nets import graphs
  from graph_nets import utils_np
  import six
  from six.moves import range
  import tensorflow
  import tree
label_desc: Use image node_id 10 for calling a global function with example usage: stop_gradient(graph, stop_edges, stop_nodes, stop_globals, name) and returns: graph