def _get_atoms_to_count(examples, get_atoms_fn):
  """Return map of atom to count of examples containing atom."""
  atoms_to_count = collections.defaultdict(int)
  for example in examples:
    atoms = get_atoms_fn(example)
    for atom in atoms:
      atoms_to_count[atom] += 1
  return atoms_to_count
Return map of atom to count of examples containing atom.
language/compgen/nqg/tasks/mcd_utils.py