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"]
docstr: get the config of the best parent 
          
docstr_tok: ["get","the","config","of","the","best","parent"]
code: def best_parent(self, sample_size=None):
      """get the config of the best parent"""
      samples = [p for p in self._population]  # copy population
      random.shuffle(samples)
      if sample_size is not None:
          samples = list(samples)[:sample_size]
      if self.optimize_mode == "maximize":
          parent = max(samples, key=lambda sample: sample.y)
      else:
          parent = min(samples, key=lambda sample: sample.y)
      return parent.x
  
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 2 for calling the Evolution obj's underlying member method code with example usage: obj.best_parent(sample_size) and returns: parent