class_docstr: Algorithm for regularized evolution (i.e. aging evolution).
  Follows "Algorithm 1" in Real et al. "Regularized Evolution for Image Classifier Architecture Search".
  
  Parameters
  ----------
  optimize_mode : str
      Can be one of "maximize" and "minimize". Default: maximize.
  population_size : int
      The number of individuals to keep in the population. Default: 100.
  cycles : int
      The number of cycles (trials) the algorithm should run for. Default: 20000.
  sample_size : int
      The number of individuals that should participate in each tournament. Default: 25.
  mutation_prob : float
      Probability that mutation happens in each dim. Default: 0.05
class_docstr_tok: ["Algorithm","for","regularized","evolution","(","i.e",".","aging","evolution",")",".","Follows","``","Algorithm","1","''","in","Real","et","al",".","``","Regularized","Evolution","for","Image","Classifier","Architecture","Search","''",".","Parameters","--","--","--","--","--","optimize_mode",":","str","Can","be","one","of","``","maximize","''","and","``","minimize","''",".","Default",":","maximize",".","population_size",":","int","The","number","of","individuals","to","keep","in","the","population",".","Default",":","100.","cycles",":","int","The","number","of","cycles","(","trials",")","the","algorithm","should","run","for",".","Default",":","20000.","sample_size",":","int","The","number","of","individuals","that","should","participate","in","each","tournament",".","Default",":","25.","mutation_prob",":","float","Probability","that","mutation","happens","in","each","dim",".","Default",":","0.05"]
code: def search(
      self, space: BaseSpace, nas_modules, dset, estimator, device
  ):
      self.model = space
      self.dataset = dset
      self.estimator = estimator
      self.nas_modules = nas_modules
      self.device = device
  
      self._prepare()
      LOGGER.info("Initializing the first population.")
      with tqdm(
          range(self.population_size), disable=self.disable_progress
      ) as bar:
          for i in bar:
              config = self.uniform.resample()
              metric = self._get_metric(config)
              individual = Individual(config, metric)
              # LOGGER.debug('Individual created: %s', str(individual))
              self._population.append(individual)
              self._history.append(individual)
              bar.set_postfix(
                  metric=metric,
                  max=max(x.y for x in self._population),
                  min=min(x.y for x in self._population),
              )
  
      LOGGER.info("Running mutations.")
      with tqdm(
          range(self.cycles), disable=self.disable_progress
      ) as bar:
          for i in bar:
              parent = self.best_parent(self.sample_size)
              config = self.mutation.resample(parent)
              metric = self._get_metric(
                  config
              )  # todo : add aging factor
              individual = Individual(config, metric)
              LOGGER.debug("Individual created: %s", str(individual))
              self._population.append(individual)
              self._history.append(individual)
              if len(self._population) > self.population_size:
                  self._population.popleft()
              bar.set_postfix(
                  metric=metric,
                  max_h=max(x.y for x in self._history),
                  max=max(x.y for x in self._population),
                  min=min(x.y for x in self._population),
              )
  
      # todo: origin is best in history | or the population may need to be retrained
      self._history.sort(key=lambda x: x.y)
      # best=self.best_parent()
      if self.optimize_mode == "maximize":
          best = self._history[-1].x
      else:
          best = self._history[0].x
      return best
  
imports: import copy
  from logging import Logger
  from numpy.core.fromnumeric import sort
  import torch
  import torch.nn
  import torch.nn.functional
  from .None import register_nas_algo
  from .base import BaseNAS
  from ..space import BaseSpace
  from ..utils import AverageMeterGroup, replace_layer_choice, replace_input_choice, get_module_order, sort_replaced_module, PathSamplingLayerChoice, PathSamplingInputChoice
  from tqdm import tqdm, trange
  from ....utils import get_logger
  import numpy
  import collections
  import dataclasses
  import random
label_desc: Use image node_id 5 for calling the Evolution obj's underlying member method code with example usage: obj.search(space, nas_modules, dset, estimator, device) and returns: best