code: def _prune_branches(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]
  
imports: import collections
  import copy
  import heapq
label_desc: Use image node_id 2 for calling a global function with example usage: _prune_branches(beam_entries, k) and returns: unknown