class_docstr: A Bayesian optimizer for neural architectures.
  Attributes:
      searcher: The Searcher which is calling the Bayesian optimizer.
      t_min: The minimum temperature for simulated annealing.
      metric: An instance of the Metric subclasses.
      gpr: A GaussianProcessRegressor for bayesian optimization.
      beta: The beta in acquisition function. (refer to our paper)
      search_tree: The network morphism search tree.
class_docstr_tok: ["A","Bayesian","optimizer","for","neural","architectures",".","Attributes",":","searcher",":","The","Searcher","which","is","calling","the","Bayesian","optimizer",".","t_min",":","The","minimum","temperature","for","simulated","annealing",".","metric",":","An","instance","of","the","Metric","subclasses",".","gpr",":","A","GaussianProcessRegressor","for","bayesian","optimization",".","beta",":","The","beta","in","acquisition","function",".","(","refer","to","our","paper",")","search_tree",":","The","network","morphism","search","tree","."]
docstr: Generate new architecture.
  Args:
      descriptors: All the searched neural architectures.
  Returns:
      graph: An instance of Graph. A morphed neural network with weights.
      father_id: The father node ID in the search tree.
docstr_tok: ["Generate","new","architecture",".","Args",":","descriptors",":","All","the","searched","neural","architectures",".","Returns",":","graph",":","An","instance","of","Graph",".","A","morphed","neural","network","with","weights",".","father_id",":","The","father","node","ID","in","the","search","tree","."]
code: def generate(self, descriptors):
      """Generate new architecture.
      Args:
          descriptors: All the searched neural architectures.
      Returns:
          graph: An instance of Graph. A morphed neural network with weights.
          father_id: The father node ID in the search tree.
      """
      model_ids = self.search_tree.adj_list.keys()
  
      target_graph = None
      father_id = None
      descriptors = deepcopy(descriptors)
      elem_class = Elem
      if self.optimizemode is OptimizeMode.Maximize:
          elem_class = ReverseElem
  
      # Initialize the priority queue.
      pq = PriorityQueue()
      temp_list = []
      for model_id in model_ids:
          metric_value = self.searcher.get_metric_value_by_id(model_id)
          temp_list.append((metric_value, model_id))
      temp_list = sorted(temp_list)
      for metric_value, model_id in temp_list:
          graph = self.searcher.load_model_by_id(model_id)
          graph.clear_operation_history()
          graph.clear_weights()
          pq.put(elem_class(metric_value, model_id, graph))
  
      t = 1.0
      t_min = self.t_min
      alpha = 0.9
      opt_acq = self._get_init_opt_acq_value()
      while not pq.empty() and t > t_min:
          elem = pq.get()
          if self.optimizemode is OptimizeMode.Maximize:
              temp_exp = min((elem.metric_value - opt_acq) / t, 1.0)
          else:
              temp_exp = min((opt_acq - elem.metric_value) / t, 1.0)
          ap = math.exp(temp_exp)
          if ap >= random.uniform(0, 1):
              for temp_graph in transform(elem.graph):
                  if contain(
                      descriptors, temp_graph.extract_descriptor()
                  ):
                      continue
  
                  temp_acq_value = self.acq(temp_graph)
                  pq.put(
                      elem_class(
                          temp_acq_value, elem.father_id, temp_graph
                      )
                  )
                  descriptors.append(temp_graph.extract_descriptor())
                  if self._accept_new_acq_value(
                      opt_acq, temp_acq_value
                  ):
                      opt_acq = temp_acq_value
                      father_id = elem.father_id
                      target_graph = deepcopy(temp_graph)
          t *= alpha
  
      # Did not found a not duplicated architecture
      if father_id is None:
          return None, None
      nm_graph = self.searcher.load_model_by_id(father_id)
      for args in target_graph.operation_history:
          getattr(nm_graph, args[0])(*list(args[1:]))
      return nm_graph, father_id
  
imports: import math
  import random
  from copy import deepcopy
  from functools import total_ordering
  from queue import PriorityQueue
  import numpy
  from scipy.linalg import LinAlgError, cho_solve, cholesky, solve_triangular
  from scipy.optimize import linear_sum_assignment
  from sklearn.metrics.pairwise import rbf_kernel
  from nni.utils import OptimizeMode
  from .graph_transformer import transform
  from .utils import Constant
  from .layers import is_layer
label_desc: Use image node_id 3 for calling the BayesianOptimizer obj's underlying member method code with example usage: obj.generate(descriptors) and returns: nm_graph,  father_id, None,  None