class_docstr: Algorithm for regularized evolution (i.e. aging evolution).
  Follows "Algorithm 1" in Real et al. "Regularized Evolution for Image Classifier Architecture Search",
  with several enhancements.
  
  Sample in this algorithm are called *individuals*.
  Specifically, the first ``population_size`` individuals are randomly sampled from the search space,
  and the rest are generated via a selection and mutation process.
  While new individuals are added to the population, the oldest one is removed to keep the population size constant.
  
  Parameters
  ----------
  population_size
      The number of individuals to keep in the population.
  sample_size
      The number of individuals that should participate in each tournament.
      When mutate, ``sample_size`` individuals can randomly selected from the population,
      and the best one among them will be treated as the parent.
  mutation_prob
      Probability that mutation happens in each dim.
  crossover
      If ``True``, the new individual will be a crossover between winners of two individual tournament.
      That means, two sets of ``sample_size`` individuals will be randomly selected from the population,
      and the best one in each set will be used as parents.
      Every dimension will be randomly selected from one of the parents.
  dedup
      Enforce one sample to never appear twice.
      The population might be smaller than ``population_size`` if this is set to ``True`` and the search space is small.
  seed
      Random seed.
code: def __init__(
      self,
      *,
      population_size: int = 100,
      sample_size: int = 25,
      mutation_prob: float = 0.05,
      crossover: bool = False,
      dedup: bool = True,
      seed: int | None = None,
      **kwargs,
  ):
      super().__init__()
  
      if (
          "on_failure" in kwargs
          or "cycles" in kwargs
          or "model_filter" in kwargs
          or "optimize_mode" in kwargs
          or "dedup_retries" in kwargs
      ):
          warnings.warn(
              "on_failure, cycles, mode_filter, optimize_mode, dedup_retries are deprecated "
              "and will be removed in the future. Specifying them has no effect now.",
              DeprecationWarning,
          )
          raise NotImplementedError(
              'on_failure != "ignore" or cycles is not None is not supported yet.'
          )
  
      if not 1 <= sample_size <= population_size:
          raise ValueError(
              "sample_size must be smaller than population_size and greater than 0."
          )
  
      self.population_size = population_size
      self.sample_size = sample_size
      self.mutation_prob = mutation_prob
      self.crossover = crossover
  
      self._dedup_helper = (
          DeduplicationHelper(raise_on_dup=True) if dedup else None
      )
      self._retry_helper = RetrySamplingHelper()
  
      # Current population. All finished running.
      self._population: Deque[Individual] = collections.deque()
      # Models that are still running. Not in the population.
      self._running_models: list[ExecutableModelSpace] = []
  
      self._random_state = RandomState(seed)
  
      self._individual_counter = 0
  
imports: from __future__ import annotations
  import collections
  import dataclasses
  import logging
  import warnings
  import copy
  from typing import Deque
  from numpy.random import RandomState
  from nni.mutable import Sample, MutableAnnotation
  from nni.nas.execution import ExecutionEngine
  from nni.nas.space import ExecutableModelSpace
  from nni.typehint import TrialMetric
  from nni.nas.execution.event import ModelEvent, ModelEventType
  from .base import Strategy
  from .utils import DeduplicationHelper, RetrySamplingHelper
label_desc: Use image node_id 1 to create a new RegularizedEvolution object from inherited base classes: Strategy with example: obj = RegularizedEvolution()