def METHOD_NAME(output_tensor):
  """Function to propagate backwards in the graph and mark nodes as used.
  Traverses iteratively through the graph from the end tensor, through the op
  that generates the tensor, and then to the input tensors that feed the op.
  Nodes encountered are stored in used_node_names.
  Args:
    output_tensor: A Tensor which we start the propagation.
  Returns:
    used_node_names: A set of strings, stores the name of nodes we've marked as
      visited.
  """
  used_node_names = set()
  tensors = [output_tensor]
  #  The graph is traversed iteratively because the recursive implementation
  #  fails with stack overflow error for large graphs.
  while tensors:
    op = tensors.pop().op
    if op.name in used_node_names:
      continue
    used_node_names.add(op.name)
    tensors.extend(op.inputs)
    for control_input_op in op.control_inputs:
      used_node_names.add(control_input_op.name)
      tensors.extend(control_input_op.inputs)
  return used_node_names