code: def acq_max(
      ac,
      gp,
      y_max,
      bounds,
      random_state,
      constraint=None,
      n_warmup=10000,
      n_iter=10,
      y_max_params=None,
  ):
      """
      A function to find the maximum of the acquisition function
  
      It uses a combination of random sampling (cheap) and the 'L-BFGS-B'
      optimization method. First by sampling `n_warmup` (1e5) points at random,
      and then running L-BFGS-B from `n_iter` (10) random starting points.
  
      Parameters
      ----------
      :param ac:
          The acquisition function object that return its point-wise value.
  
      :param gp:
          A gaussian process fitted to the relevant data.
  
      :param y_max:
          The current maximum known value of the target function.
  
      :param bounds:
          The variables bounds to limit the search of the acq max.
  
      :param random_state:
          instance of np.RandomState random number generator
  
      :param constraint:
          A ConstraintModel.
  
      :param n_warmup:
          number of times to randomly sample the acquisition function
  
      :param n_iter:
          number of times to run scipy.minimize
  
      :param y_max_params:
          Function parameters that produced the maximum known value given by `y_max`.
  
      Returns
      -------
      :return: x_max, The arg max of the acquisition function.
      """
  
      # We need to adjust the acquisition function to deal with constraints when there is some
      if constraint is not None:
  
          def adjusted_ac(x):
              """Acquisition function adjusted to fulfill the constraint when necessary"""
  
              # Transforms the problem in a minimization problem, this is necessary
              # because the solver we are using later on is a minimizer
              values = -ac(
                  x.reshape(-1, bounds.shape[0]), gp=gp, y_max=y_max
              )
              p_constraints = constraint.predict(
                  x.reshape(-1, bounds.shape[0])
              )
  
              # Slower fallback for the case where any values are negative
              if np.any(values > 0):
                  # TODO: This is not exactly how Gardner et al do it.
                  # Their way would require the result of the acquisition function
                  # to be strictly positive, which is not the case here. For a
                  # positive target value, we use Gardner's version. If the target
                  # is negative, we instead slightly rescale the target depending
                  # on the probability estimate to fulfill the constraint.
                  return np.array(
                      [
                          value / (0.5 + 0.5 * p)
                          if value > 0
                          else value * p
                          for value, p in zip(values, p_constraints)
                      ]
                  )
  
              # Faster, vectorized version of Gardner et al's method
              return values * p_constraints
  
      else:
          # Transforms the problem in a minimization problem, this is necessary
          # because the solver we are using later on is a minimizer
          adjusted_ac = lambda x: -ac(
              x.reshape(-1, bounds.shape[0]), gp=gp, y_max=y_max
          )
  
      # Warm up with random points
      x_tries = random_state.uniform(
          bounds[:, 0], bounds[:, 1], size=(n_warmup, bounds.shape[0])
      )
      ys = -adjusted_ac(x_tries)
      x_max = x_tries[ys.argmax()]
      max_acq = ys.max()
  
      # Explore the parameter space more thoroughly
      x_seeds = random_state.uniform(
          bounds[:, 0],
          bounds[:, 1],
          size=(
              1 + n_iter + int(not y_max_params is None),
              bounds.shape[0],
          ),
      )
      # Add the best candidate from the random sampling to the seeds so that the
      # optimization algorithm can try to walk up to that particular local maxima
      x_seeds[0] = x_max
      if not y_max_params is None:
          # Add the provided best sample to the seeds so that the optimization
          # algorithm is aware of it and will attempt to find its local maxima
          x_seeds[1] = y_max_params
  
      for x_try in x_seeds:
          # Find the minimum of minus the acquisition function
          res = minimize(
              adjusted_ac, x_try, bounds=bounds, method="L-BFGS-B"
          )
  
          # See if success
          if not res.success:
              continue
  
          # Store it if better than previous minimum(maximum).
          if max_acq is None or -np.squeeze(res.fun) >= max_acq:
              x_max = res.x
              max_acq = -np.squeeze(res.fun)
  
      # Clip output to make sure it lies within the bounds. Due to floating
      # point technicalities this is not always the case.
      return np.clip(x_max, bounds[:, 0], bounds[:, 1])
  
imports: import warnings
  import numpy
  from scipy.stats import norm
  from scipy.optimize import minimize
  from colorama import just_fix_windows_console
  import json
label_desc: Use image node_id 1 for calling a global function with example usage: acq_max(ac, gp, y_max, bounds, random_state, constraint, n_warmup, n_iter, y_max_params) and returns: np, unknown, np