import collections


def InvertDictOfLists(report_per_node):
  """Invert a dict of lists so that values in the lists become keys."""
  results = collections.defaultdict(list)
  for node, values in report_per_node.iteritems():
    for value in values:
      results[value].append(node)
  return results