code: def test_maximize():
      from sklearn.exceptions import NotFittedError
  
      class Tracker:
          def __init__(self):
              self.start_count = 0
              self.step_count = 0
              self.end_count = 0
  
          def update_start(self, event, instance):
              self.start_count += 1
  
          def update_step(self, event, instance):
              self.step_count += 1
  
          def update_end(self, event, instance):
              self.end_count += 1
  
          def reset(self):
              self.__init__()
  
      optimizer = BayesianOptimization(
          target_func,
          PBOUNDS,
          random_state=np.random.RandomState(1),
          allow_duplicate_points=True,
      )
  
      tracker = Tracker()
      optimizer.subscribe(
          event=Events.OPTIMIZATION_START,
          subscriber=tracker,
          callback=tracker.update_start,
      )
      optimizer.subscribe(
          event=Events.OPTIMIZATION_STEP,
          subscriber=tracker,
          callback=tracker.update_step,
      )
      optimizer.subscribe(
          event=Events.OPTIMIZATION_END,
          subscriber=tracker,
          callback=tracker.update_end,
      )
  
      optimizer.maximize(init_points=0, n_iter=0)
      assert optimizer._queue.empty
      assert len(optimizer.space) == 1
      assert tracker.start_count == 1
      assert tracker.step_count == 1
      assert tracker.end_count == 1
  
      optimizer.set_gp_params(alpha=1e-2)
      acquisition_function = UtilityFunction()
      optimizer.maximize(
          init_points=2,
          n_iter=0,
          acquisition_function=acquisition_function,
      )
      assert optimizer._queue.empty
      assert len(optimizer.space) == 3
      assert optimizer._gp.alpha == 1e-2
      assert tracker.start_count == 2
      assert tracker.step_count == 3
      assert tracker.end_count == 2
  
      optimizer.maximize(init_points=0, n_iter=2)
      assert optimizer._queue.empty
      assert len(optimizer.space) == 5
      assert tracker.start_count == 3
      assert tracker.step_count == 5
      assert tracker.end_count == 3
  
imports: import pytest
  import numpy
  from bayes_opt import UtilityFunction
  from bayes_opt import BayesianOptimization
  from bayes_opt.logger import ScreenLogger
  from bayes_opt.event import Events, DEFAULT_EVENTS
  from bayes_opt.util import NotUniqueError
  import pickle
  import os
label_desc: Use image node_id 14 for calling a global function with example usage: test_maximize() without return types