code: def optimize(self, duplicate_manager=None):
          
          if not self.analytical_gradient_acq:
              out = self.optimizer.optimize(f=self.acquisition_function, duplicate_manager=duplicate_manager)
          else:
              out = self.optimizer.optimize(f=self.acquisition_function, f_df=self.acquisition_function_withGradients, duplicate_manager=duplicate_manager)
          return out
docs: Optimizes the acquisition function (uses a flag from the model to use gradients or not).