code: def test_prune_candidates(self):
      tkwargs = {"device": self.device, "dtype": torch.double}
      # no pruning
      X = torch.rand(6, 3, **tkwargs)
      vals = X.sum(dim=-1)
      X_pruned = prune_candidates(
          candidates=X, acq_values=vals, prune_tolerance=1e-6
      )
      self.assertTrue(
          (X[vals.argsort(descending=True), :] == X_pruned).all()
      )
      # pruning
      X[1, :] = X[0, :] + 1e-10
      X[4, :] = X[2, :] - 1e-10
      vals = torch.tensor([1, 6, 3, 4, 2, 5], **tkwargs)
      X_pruned = prune_candidates(
          candidates=X, acq_values=vals, prune_tolerance=1e-6
      )
      self.assertTrue((X[[1, 5, 3, 2]] == X_pruned).all())
      # invalid shapes
      with self.assertRaisesRegex(
          ValueError, "`candidates` must be of size `n x d`."
      ):
          prune_candidates(
              candidates=torch.zeros(3, 2, 1),
              acq_values=torch.zeros(2, 1),
              prune_tolerance=1e-6,
          )
      with self.assertRaisesRegex(
          ValueError, "`acq_values` must be of size `n`."
      ):
          prune_candidates(
              candidates=torch.zeros(3, 2),
              acq_values=torch.zeros(3, 1),
              prune_tolerance=1e-6,
          )
      with self.assertRaisesRegex(
          ValueError, "`prune_tolerance` must be >= 0."
      ):
          prune_candidates(
              candidates=torch.zeros(3, 2),
              acq_values=torch.zeros(3),
              prune_tolerance=-1.2345,
          )
  
file_path: botorch/test/optim/test_homotopy.py
imports: import unittest.mock
  import torch
  from botorch.acquisition import PosteriorMean
  from botorch.acquisition.monte_carlo import qExpectedImprovement
  from botorch.models import GenericDeterministicModel
  from botorch.optim.homotopy import FixedHomotopySchedule, Homotopy, HomotopyParameter, LinearHomotopySchedule, LogLinearHomotopySchedule
  from botorch.optim.optimize_homotopy import optimize_acqf_homotopy, prune_candidates
  from botorch.utils.testing import BotorchTestCase
  from torch.nn import Parameter
label_desc: Use image node_id 7 for calling the TestHomotopy obj's underlying member method code with example usage: obj.test_prune_candidates() without return types