code: def __init__(self, hyperparameters, config, logger):
      self.hyperparameters = hyperparameters
      self.config = config
      self.logger = logger
  
      self.opts = cma.CMAOptions()
      for param, value in six.iteritems(self.config["cmaes_config"]):
          if param in self.opts and value is not None:
              self.opts[param] = value
      self.dim = 0
      for h in self.hyperparameters:
          assert self.dim == h.index
          self.dim += (
              h.array_length if h.array_length is not None else 1
          )
  
      self.init = np.empty(self.dim)
      # self.sigma = np.random.random(self.dim) # not allowed
      self.sigma = self.config["cmaes_config"]["sigma0"]
      self.opts["CMA_stds"] = np.ones(self.dim)
      self.gen = 0
      self.start_time = time.time()
      self.best_fitnesses = []
      self.mean_fitnesses = []
      self.best = None
  
      for h in self.hyperparameters:
          if h.array_length is None:
              if h.rand_init:
                  self.init[h.index] = (
                      random.random() * (h.max_range - h.min_range)
                      + h.min_range
                  )
              else:
                  self.init[h.index] = (h.max_range + h.min_range) / 2.0
          else:
              if h.rand_init:
                  self.init[h.index : h.index + h.array_length] = (
                      np.random.random(h.array_length)
                      * (h.max_range - h.min_range)
                      + h.min_range
                  )
              else:
                  self.init[h.index : h.index + h.array_length] = (
                      np.ones(h.array_length)
                      * (h.max_range + h.min_range)
                      / 2.0
                  )
  
          if h.array_length is None:
              if h.max_range - h.min_range > EPSILON:
                  self.opts["CMA_stds"][h.index] *= (
                      h.max_range - h.min_range
                  )
          else:
              if h.max_range - h.min_range > EPSILON:
                  self.opts["CMA_stds"][
                      h.index : h.index + h.array_length
                  ] *= (h.max_range - h.min_range)
  
      # If min range and max range are exactly the same,
      # use a sigma calculated
      # from mean of init
      # if max([h.max_range for h in hyperparameters]) - \
      #     min([h.min_range for h in hyperparameters]) < EPSILON:
      #     self.logger.warn("min range == max range, overwriting sigma0")
      #     self.sigma = np.mean(self.init) * MISC_CONFIG['sigma0']
      self.es = cma.CMAEvolutionStrategy(
          self.init, self.sigma, self.opts
      )
      self.__load_checkpoint()
  
      self.logger.info("Init: %s" % self.init)
      self.logger.info("CMA stds: %s" % self.opts["CMA_stds"])
      self.logger.info(pprint.pformat(self.get_config()))
  
imports: import cma
  import random
  import copy
  import pickle
  import os
  import pprint
  import time
  import six
  import numpy
  from opt_util import EPSILON
label_desc: Use image node_id 1 to create a new Optimizer object from inherited base classes: object with example: obj = Optimizer(hyperparameters, config, logger)