parameters: (n)
return_statement: return keep
docstring: Creates a filter that keeps the largest n export versions.
  
    Args:
      n: number of versions to keep.
  
    Returns:
      A filter function that keeps the n largest paths.
docstring_summary: Creates a filter that keeps the largest n export versions.
docstring_tokens: Creates a filter that keeps the largest n export versions .
function: def largest_export_versions(n):
    """Creates a filter that keeps the largest n export versions.
  
    Args:
      n: number of versions to keep.
  
    Returns:
      A filter function that keeps the n largest paths.
    """
    def keep(paths):
      heap = []
      for idx, path in enumerate(paths):
        if path.export_version is not None:
          heapq.heappush(heap, (path.export_version, idx))
      keepers = [paths[i] for _, i in heapq.nlargest(n, heap)]
      return sorted(keepers)
  
    return keep
function_tokens: def largest_export_versions ( n ) : def keep ( paths ) : heap = [ ] for idx , path in enumerate ( paths ) : if path . export_version is not None : heapq . heappush ( heap , ( path . export_version , idx ) ) keepers = [ paths [ i ] for _ , i in heapq . nlargest ( n , heap ) ] return sorted ( keepers ) return keep