def METHOD_NAME(beam_entries, k):
  """Prune all but the `k` sequences with highest score from the beam."""
  indices = heapq.nlargest(k, range(len(beam_entries)),
                           key=lambda i: beam_entries[i].score)
  return [beam_entries[i] for i in indices]