code: def find_b_opt_max(
      gp, p_bound, p_type, w=None, n_warmup=100000, n_iter=100
  ):
      """
      refer to acq_max https://github.com/fmfn/BayesianOptimization/blob/master/bayes_opt/util.py
      """
      X = []
      for k in range(n_warmup):
          X.append(random_with_bound_type(p_bound, p_type))
      if w is not None:
          X = np.hstack((X, np.tile(w, (len(X), 1))))
      y = gp.predict(X)
      ind = np.argmax(y)
      x_max, y_max = X[ind], y[ind]
      temp_w = [] if w is None else w
  
      def utility(x, kappa=2.576):
          mean, std = gp.predict(
              [list(x) + list(temp_w)], return_std=True
          )
          # print("######### mean, std ", x, mean, std)
          return (mean + kappa * std)[0]
  
      for i in range(n_iter):
          x_try = random_with_bound_type(p_bound, p_type)
          res = minimize(
              lambda x: -utility(x),
              x_try,
              bounds=p_bound,
              method="L-BFGS-B",
          )
          if not res.success:
              continue
          if -res.fun >= y_max:
              x_max = res.x
              y_max = -res.fun
  
      return x_max, y_max
  
imports: import random
  import os
  import sys
  import collections
  import itertools
  import pickle
  import scipy.sparse
  import networkx
  import numpy
  from sklearn.cluster import SpectralClustering
  from sklearn import gaussian_process
  from scipy.optimize import minimize
  from bayes_opt import BayesianOptimization
label_desc: Use image node_id 12 for calling a global function with example usage: find_b_opt_max(gp, p_bound, p_type, w, n_warmup, n_iter) and returns: x_max,  y_max, unknown