class_docstr: Performs Bayesian Optimization using a Gaussian Process as an
  emulator for the unknown function.
class_docstr_tok: ["Performs","Bayesian","Optimization","using","a","Gaussian","Process","as","an","emulator","for","the","unknown","function","."]
docstr: Optimizes a differentiable function by choosing `num_candidates`
  initial points at random and calling :func:`find_a_candidate` on
  each. The best candidate is returned with its function value.
  
  :param function differentiable: a function amenable to torch autograd
  :param int num_candidates: the number of random starting points to
      use
  :return: the minimiser and its function value
  :rtype: tuple
docstr_tok: ["Optimizes","a","differentiable","function","by","choosing","`","num_candidates","`","initial","points","at","random","and","calling",":","func",":","`","find_a_candidate","`","on","each",".","The","best","candidate","is","returned","with","its","function","value",".",":","param","function","differentiable",":","a","function","amenable","to","torch","autograd",":","param","int","num_candidates",":","the","number","of","random","starting","points","to","use",":","return",":","the","minimiser","and","its","function","value",":","rtype",":","tuple"]
code: def opt_differentiable(self, differentiable, num_candidates=5):
      """Optimizes a differentiable function by choosing `num_candidates`
      initial points at random and calling :func:`find_a_candidate` on
      each. The best candidate is returned with its function value.
  
      :param function differentiable: a function amenable to torch autograd
      :param int num_candidates: the number of random starting points to
          use
      :return: the minimiser and its function value
      :rtype: tuple
      """
  
      candidates = []
      values = []
      for j in range(num_candidates):
          x_init = torch.empty(
              1,
              dtype=self.gpmodel.X.dtype,
              device=self.gpmodel.X.device,
          ).uniform_(
              self.constraints.lower_bound, self.constraints.upper_bound
          )
          x, y = self.find_a_candidate(differentiable, x_init)
          if torch.isnan(y):
              continue
          candidates.append(x)
          values.append(y)
  
      mvalue, argmin = torch.min(torch.cat(values), dim=0)
      return candidates[argmin.item()], mvalue
  
file_path: pyro/examples/contrib/oed/gp_bayes_opt.py
imports: import torch
  import torch.autograd
  import torch.optim
  from torch.distributions import transform_to
  import pyro.contrib.gp
  import pyro.optim
  from pyro.infer import TraceEnum_ELBO
label_desc: Use image node_id 4 for calling the GPBayesOptimizer obj's underlying member method code with example usage: obj.opt_differentiable(differentiable, num_candidates) and returns: candidates,  mvalue