class_docstr: Exploring the search space with a cost model
class_docstr_tok: ["Exploring","the","search","space","with","a","cost","model"]
code: def next_batch(self, sample_size):
      sampled_batch = []
  
      counter = 0
      while counter < sample_size:
          if len(self.visited) >= self.num_all_configs:
              break
  
          while self.trial_pt < len(self.trials):
              logger.debug(f"trials: {self.trials}")
              # Select top promising trials
              index = self.trials[self.trial_pt]
              if index not in self.visited:
                  break
              self.trial_pt += 1
  
          # To avoid over-exploitation, randomly select one that has not been explored.
          rand = np.random.rand()
          if rand < self.random_exploration_ratio:
              # Do normal selection
              feature = np.random.choice(self.trials)
              while index in self.visited:
                  index = np.random.randint(self.num_all_configs)
  
          # Need to track both the sampled configs and indices
  
          sampled_batch.append(self.all_exps[index])
          self.visited.add(index)
          counter += 1
  
      return sampled_batch
  
file_path: deepspeed/deepspeed/autotuning/tuner/model_based_tuner.py
imports: import hjson
  from ..constants import AUTOTUNING, AUTOTUNING_METRIC_PATH
  from .base_tuner import BaseTuner
  from .cost_model import XGBoostCostModel
  from .utils import *
  from ..utils import *
  import numbers
  from ..constants import AUTOTUNING_METRIC_LATENCY
label_desc: Use image node_id 3 for calling the ModelBasedTuner obj's underlying member method code with example usage: obj.next_batch(sample_size) and returns: sampled_batch