code: def prune_candidates(
      candidates: Tensor, acq_values: Tensor, prune_tolerance: float
  ) -> Tensor:
      r"""Prune candidates based on their distance to other candidates.
  
      Args:
          candidates: An `n x d` tensor of candidates.
          acq_values: An `n` tensor of candidate values.
          prune_tolerance: The minimum distance to prune candidates.
  
      Returns:
          An `m x d` tensor of pruned candidates.
      """
      if candidates.ndim != 2:
          raise ValueError("`candidates` must be of size `n x d`.")
      if acq_values.ndim != 1 or len(acq_values) != candidates.shape[0]:
          raise ValueError("`acq_values` must be of size `n`.")
      if prune_tolerance < 0:
          raise ValueError("`prune_tolerance` must be >= 0.")
      sorted_inds = acq_values.argsort(descending=True)
      candidates = candidates[sorted_inds]
  
      candidates_new = candidates[:1, :]
      for i in range(1, candidates.shape[0]):
          if (
              torch.cdist(
                  candidates[i : i + 1, :], candidates_new
              ).min()
              > prune_tolerance
          ):
              candidates_new = torch.cat(
                  [candidates_new, candidates[i : i + 1, :]], dim=-2
              )
      return candidates_new
  
file_path: botorch/botorch/optim/optimize_homotopy.py
imports: from typing import Callable, Dict, Optional, Tuple, Union
  import torch
  from botorch.acquisition import AcquisitionFunction
  from botorch.optim.homotopy import Homotopy
  from botorch.optim.optimize import optimize_acqf
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: prune_candidates(candidates, acq_values, prune_tolerance) and returns: candidates_new