class_docstr: Bracket of rungs for the algorithm ASHA.
  
  Parameters
  ----------
  asha: `ASHA` algorithm
      The asha algorithm object which this bracket will be part of.
  budgets: list of tuple
      Each tuple gives the (n_trials, resource_budget) for the respective rung.
  repetition_id: int
      The id of hyperband execution this bracket belongs to
docstr: Promote the first candidate that is found and return it
  
  The rungs are iterated over in reversed order, so that high rungs
  are prioritised for promotions. When a candidate is promoted, the loop is broken and
  the method returns the promoted trial.
  
  .. note ::
  
      All trials are part of the rungs, for any state. Only completed trials
      are eligible for promotion, i.e., only completed trials can be part of top-k.
      Lookup for promotion in rung l + 1 contains trials of any status.
docstr_tok: ["Promote","the","first","candidate","that","is","found","and","return","it","The","rungs","are","iterated","over","in","reversed","order",",","so","that","high","rungs","are","prioritised","for","promotions",".","When","a","candidate","is","promoted",",","the","loop","is","broken","and","the","method","returns","the","promoted","trial",".","..","note",":",":","All","trials","are","part","of","the","rungs",",","for","any","state",".","Only","completed","trials","are","eligible","for","promotion",",","i.e.",",","only","completed","trials","can","be","part","of","top-k.","Lookup","for","promotion","in","rung","l","+","1","contains","trials","of","any","status","."]
code: def promote(self, num: int) -> list[Trial]:
      """Promote the first candidate that is found and return it
  
      The rungs are iterated over in reversed order, so that high rungs
      are prioritised for promotions. When a candidate is promoted, the loop is broken and
      the method returns the promoted trial.
  
      .. note ::
  
          All trials are part of the rungs, for any state. Only completed trials
          are eligible for promotion, i.e., only completed trials can be part of top-k.
          Lookup for promotion in rung l + 1 contains trials of any status.
  
      """
      if num < 1 or self.is_done:
          return []
  
      candidates = []
      for rung_id in range(len(self.rungs) - 2, -1, -1):
          for candidate in self.get_candidates(rung_id):
              # pylint: disable=logging-format-interpolation
              logger.debug(
                  f"Promoting {candidate} from rung {rung_id} with fidelity "
                  f"{flatten(candidate.params)[self.owner.fidelity_index]} to "
                  f"rung {rung_id + 1} with fidelity {self.rungs[rung_id + 1]['resources']}"
              )
  
              candidate = candidate.branch(
                  status="new",
                  params={
                      self.owner.fidelity_index: self.rungs[
                          rung_id + 1
                      ]["resources"]
                  },
              )
  
              if not self.owner.has_suggested(candidate):
                  candidates.append(candidate)
  
              if len(candidates) >= num:
                  return candidates
  
      return candidates
  
imports: from __future__ import annotations
  import copy
  import logging
  from collections import defaultdict
  from typing import Sequence
  import numpy
  from orion.algo.hyperband import BudgetTuple, Hyperband, HyperbandBracket, display_budgets
  from orion.algo.space import Space
  from orion.core.utils.flatten import flatten
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 5 for calling the ASHABracket obj's underlying member method code with example usage: obj.promote(num) and returns: candidates, list, candidates