def postprocess_fn(nodes):
    """Discard nodes that cannot reach goal and aggregate counts."""
    counts_dict = collections.defaultdict(int)
    for target_string, count in nodes:
      # Discard any targets that are not substrings of goal target.
      if target_string not in goal_target_string:
        continue
      counts_dict[target_string] += count
    return [
        (target_string, count) for target_string, count in counts_dict.items()
    ]
Discard nodes that cannot reach goal and aggregate counts.
language/compgen/nqg/model/induction/codelength_utils.py