def _sources_for_node(node, graph):
  """Gets the input op nodes for 'node'.

  Args:
    node: The node.
    graph: The graph containing the node.

  Returns:
    The unique input nodes.
  """
  inputs = set()
  for name in node.node_def.input:
    if name.startswith("^"):
      name = name[1:]
    try:
      tensor = graph.get_tensor_by_name(name)
      op = tensor.op
    except (KeyError, ValueError):
      try:
        op = graph.get_operation_by_name(name)
      except KeyError:
        continue
    inputs.add(op)

  return list(inputs)