code: def test_random_restart_optimization(self):
      for double in (True, False):
          self._setUp(double=double)
          with gpt_settings.debug(False):
              best_f = self.model(self.train_x).mean.max().item()
          qEI = qExpectedImprovement(self.model, best_f=best_f)
          bounds = torch.tensor([[0.0], [1.0]]).type_as(self.train_x)
          batch_ics = torch.rand(2, 1).type_as(self.train_x)
          batch_candidates, batch_acq_values = gen_candidates_scipy(
              initial_conditions=batch_ics,
              acquisition_function=qEI,
              lower_bounds=bounds[0],
              upper_bounds=bounds[1],
              options={"maxiter": 3},
          )
          candidates = get_best_candidates(
              batch_candidates=batch_candidates,
              batch_values=batch_acq_values,
          )
          self.assertTrue(-EPS <= candidates <= 1 + EPS)
  
imports: import math
  import warnings
  from unittest import mock
  import torch
  from botorch.acquisition import qExpectedImprovement, qKnowledgeGradient
  from botorch.exceptions.warnings import OptimizationWarning
  from botorch.fit import fit_gpytorch_mll
  from botorch.generation.gen import gen_candidates_scipy, gen_candidates_torch, get_best_candidates
  from botorch.models import SingleTaskGP
  from botorch.utils.testing import BotorchTestCase, MockAcquisitionFunction
  from gpytorch import settings
  from gpytorch.mlls.exact_marginal_log_likelihood import ExactMarginalLogLikelihood
  from scipy.optimize import OptimizeResult
label_desc: Use image node_id 1 for calling the TestRandomRestartOptimization obj's underlying member method code with example usage: obj.test_random_restart_optimization() without return types