class_docstr: Ensemble method that select N model out of all using the models' best_metric scores
  
  Args:
      n_best: number of models to pick for ensemble (N).
class_docstr_tok: ["Ensemble","method","that","select","N","model","out","of","all","using","the","models","'","best_metric","scores","Args",":","n_best",":","number","of","models","to","pick","for","ensemble","(","N",")","."]
docstr: Rank the algos by finding the top N (n_best) validation scores.
code: def collect_algos(self, n_best: int = -1) -> None:
      """
      Rank the algos by finding the top N (n_best) validation scores.
      """
  
      if n_best <= 0:
          n_best = self.n_best
  
      ranks = self.sort_score()
      if len(ranks) < n_best:
          warn(
              f"Found {len(ranks)} available algos (pre-defined n_best={n_best}). All {len(ranks)} will be used."
          )
          n_best = len(ranks)
  
      # get the ranks for which the indices are lower than N-n_best
      indices = [
          r for (i, r) in enumerate(ranks) if i < (len(ranks) - n_best)
      ]
  
      # remove the found indices
      indices = sorted(indices, reverse=True)
  
      self.algo_ensemble = deepcopy(self.algos)
      for idx in indices:
          if idx < len(self.algo_ensemble):
              self.algo_ensemble.pop(idx)
  
imports: from __future__ import annotations
  import os
  from abc import ABC, abstractmethod
  from collections.abc import Mapping, Sequence
  from copy import deepcopy
  from typing import Any, cast
  from warnings import warn
  import numpy
  import torch
  import torch.distributed
  from monai.apps.auto3dseg.bundle_gen import BundleAlgo
  from monai.apps.auto3dseg.utils import get_name_from_algo_id, import_bundle_algo_history
  from monai.apps.utils import get_logger
  from monai.auto3dseg import concat_val_to_np
  from monai.auto3dseg.utils import _prepare_cmd_bcprun, _prepare_cmd_torchrun, _run_cmd_bcprun, _run_cmd_torchrun, datafold_read
  from monai.bundle import ConfigParser
  from monai.data import partition_dataset
  from monai.transforms import MeanEnsemble, SaveImage, VoteEnsemble
  from monai.utils import RankFilter
  from monai.utils.enums import AlgoKeys
  from monai.utils.misc import check_kwargs_exist_in_class_init, prob2class
  from monai.utils.module import look_up_option, optional_import
label_desc: Use image node_id 3 for calling the AlgoEnsembleBestN obj's underlying member method code with example usage: obj.collect_algos(n_best) without return types