class_docstr: Implementation of an intensifier supporting multi-fidelity, multi-objective, and multi-processing.
  Races challengers against current incumbents.
  
  The behaviour of this intensifier is as follows:
  
  - First, adds configs from the runhistory to the queue with N=1 (they will be ignored if they are already
    evaluated).
  - While loop:
  
    - If queue is empty: Intensifies exactly one more instance of one incumbent and samples a new configuration
      afterwards.
    - If queue is not empty: Configs in the queue are evaluated on N=(N*2) instances if they might be better
      than the incumbents. If not, they are removed from the queue and rejected forever.
  
  Parameters
  ----------
  max_config_calls : int, defaults to 3
      Maximum number of configuration evaluations. Basically, how many instance-seed keys should be maxed evaluated
      for a configuration.
  max_incumbents : int, defaults to 10
      How many incumbents to keep track of in the case of multi-objective.
  retries : int, defaults to 16
      How many more iterations should be done in case no new trial is found.
  seed : int, defaults to None
      Internal seed used for random events, like shuffle seeds.
class_docstr_tok: ["Implementation","of","an","intensifier","supporting","multi-fidelity",",","multi-objective",",","and","multi-processing",".","Races","challengers","against","current","incumbents",".","The","behaviour","of","this","intensifier","is","as","follows",":","-","First",",","adds","configs","from","the","runhistory","to","the","queue","with","N=1","(","they","will","be","ignored","if","they","are","already","evaluated",")",".","-","While","loop",":","-","If","queue","is","empty",":","Intensifies","exactly","one","more","instance","of","one","incumbent","and","samples","a","new","configuration","afterwards",".","-","If","queue","is","not","empty",":","Configs","in","the","queue","are","evaluated","on","N=","(","N","*","2",")","instances","if","they","might","be","better","than","the","incumbents",".","If","not",",","they","are","removed","from","the","queue","and","rejected","forever",".","Parameters","--","--","--","--","--","max_config_calls",":","int",",","defaults","to","3","Maximum","number","of","configuration","evaluations",".","Basically",",","how","many","instance-seed","keys","should","be","maxed","evaluated","for","a","configuration",".","max_incumbents",":","int",",","defaults","to","10","How","many","incumbents","to","keep","track","of","in","the","case","of","multi-objective",".","retries",":","int",",","defaults","to","16","How","many","more","iterations","should","be","done","in","case","no","new","trial","is","found",".","seed",":","int",",","defaults","to","None","Internal","seed","used","for","random","events",",","like","shuffle","seeds","."]
docstr: Returns the next trials of the configuration based on ``get_trials_of_interest``. If N is specified,
  maximum N trials are returned but not necessarily all of them (depending on evaluated already or still running).
  
  Parameters
  ----------
  N : int | None, defaults to None
      The maximum number of trials to return. If None, all trials (``max_config_calls``) are returned.
      Running and evaluated trials are counted in.
  from_keys : list[InstanceSeedBudgetKey], defaults to None
      Only instances from the list are considered for the trials.
  shuffle : bool, defaults to True
      Shuffles the trials in groups. First, all instances are shuffled, then all seeds.
docstr_tok: ["Returns","the","next","trials","of","the","configuration","based","on","``","get_trials_of_interest","``",".","If","N","is","specified",",","maximum","N","trials","are","returned","but","not","necessarily","all","of","them","(","depending","on","evaluated","already","or","still","running",")",".","Parameters","--","--","--","--","--","N",":","int","|","None",",","defaults","to","None","The","maximum","number","of","trials","to","return",".","If","None",",","all","trials","(","``","max_config_calls","``",")","are","returned",".","Running","and","evaluated","trials","are","counted","in",".","from_keys",":","list","[","InstanceSeedBudgetKey","]",",","defaults","to","None","Only","instances","from","the","list","are","considered","for","the","trials",".","shuffle",":","bool",",","defaults","to","True","Shuffles","the","trials","in","groups",".","First",",","all","instances","are","shuffled",",","then","all","seeds","."]
code: def _get_next_trials(
      self,
      config: Configuration,
      *,
      N: int | None = None,
      from_keys: list[InstanceSeedBudgetKey] | None = None,
      shuffle: bool = True,
  ) -> list[TrialInfo]:
      """Returns the next trials of the configuration based on ``get_trials_of_interest``. If N is specified,
      maximum N trials are returned but not necessarily all of them (depending on evaluated already or still running).
  
      Parameters
      ----------
      N : int | None, defaults to None
          The maximum number of trials to return. If None, all trials (``max_config_calls``) are returned.
          Running and evaluated trials are counted in.
      from_keys : list[InstanceSeedBudgetKey], defaults to None
          Only instances from the list are considered for the trials.
      shuffle : bool, defaults to True
          Shuffles the trials in groups. First, all instances are shuffled, then all seeds.
      """
      rh = self.runhistory
      is_keys = self.get_instance_seed_keys_of_interest()
  
      # Create trials from the instance seed pairs
      # trials: list[TrialInfo] = []
      # for is_key in is_keys:
      #    trials.append(TrialInfo(config=config, instance=is_key.instance, seed=is_key.seed))
  
      # Keep ``from_keys`` trials only
      if from_keys is not None:
          valid_is_keys = [
              key.get_instance_seed_key() for key in from_keys
          ]
          for is_key in is_keys.copy():
              if is_key not in valid_is_keys:
                  is_keys.remove(is_key)
  
      # Counter is important to actually subtract the number of trials that are already evaluated/running
      # Otherwise, evaluated/running trials are not considered
      # Example: max_config_calls=16, N=8, 2 trials are running, 2 trials are evaluated, 4 trials are pending
      # Without a counter, we would return 8 trials because there are still so many trials left open
      # With counter, we would return only 4 trials because 4 trials are already evaluated/running
      counter = 0
  
      # Now we actually have to check whether the trials have been evaluated already
      evaluated_isb_keys = rh.get_instance_seed_budget_keys(
          config, highest_observed_budget_only=False
      )
      for isb_key in evaluated_isb_keys:
          is_key = isb_key.get_instance_seed_key()
          if is_key in is_keys:
              counter += 1
              is_keys.remove(is_key)
  
      # It's also important to remove running trials from the selection (we don't want to queue them again)
      running_trials = rh.get_running_trials(config)
      for trial in running_trials:
          is_key = trial.get_instance_seed_key()
          if is_key in is_keys:
              counter += 1
              is_keys.remove(is_key)
  
      if shuffle:
          is_keys = self._reorder_instance_seed_keys(is_keys)
  
      # Return only N trials
      if N is not None:
          N = N - counter
          if len(is_keys) > N:
              is_keys = is_keys[:N]
  
      # Now we convert to trials
      trials: list[TrialInfo] = []
      for is_key in is_keys:
          trials.append(
              TrialInfo(
                  config=config,
                  instance=is_key.instance,
                  seed=is_key.seed,
              )
          )
  
      return trials
  
file_path: SMAC3/smac/intensifier/intensifier.py
imports: from __future__ import annotations
  from typing import Any, Iterator
  from ConfigSpace import Configuration
  from smac.intensifier.abstract_intensifier import AbstractIntensifier
  from smac.runhistory import TrialInfo
  from smac.runhistory.dataclasses import InstanceSeedBudgetKey
  from smac.scenario import Scenario
  from smac.utils.configspace import get_config_hash
  from smac.utils.logging import get_logger
label_desc: Use image node_id 9 for calling the Intensifier obj's underlying member method code with example usage: obj._get_next_trials(config) and returns: trials