def all_input_tagged_nodes(
    graph):
  """Gets all input-tagged nodes that are reachable in a graph.

  An input-tagged node is considered reachable if there is a way to get to that
  node by an edge of that input type.

  Output will be ordered lexicographically, first by the node ordering in the
  input graph's keys, then by edge type.

  Args:
    graph: Graph to process.

  Returns:
    List of all input-tagged nodes.
  """
  node_id_to_index = {node_id: i for i, node_id in enumerate(graph)}
  reachable_itns = set()
  for node in graph.values():
    for itns in node.out_edges.values():
      reachable_itns.update(itns)

  return sorted(
      reachable_itns,
      key=lambda itn: (node_id_to_index[itn.node_id], itn.in_edge))