class_docstr: Utilities for training and sampling diffusion models.
  
  Original ported from this codebase:
  https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py#L42
  
  :param betas: a 1-D numpy array of betas for each diffusion timestep,
                starting at T and going to 1.
docstr: Sample x_{t-1} from the model using DDIM.
  
  Same usage as p_sample().
docstr_tok: ["Sample","x_","{","t-1","}","from","the","model","using","DDIM",".","Same","usage","as","p_sample","(",")","."]
code: def ddim_sample(
      self,
      model,
      x,
      t,
      clip_denoised=True,
      denoised_fn=None,
      cond_fn=None,
      model_kwargs=None,
      eta=0.0,
  ):
      """
      Sample x_{t-1} from the model using DDIM.
  
      Same usage as p_sample().
      """
      out = self.p_mean_variance(
          model,
          x,
          t,
          clip_denoised=clip_denoised,
          denoised_fn=denoised_fn,
          model_kwargs=model_kwargs,
      )
      if cond_fn is not None:
          out = self.condition_score(
              cond_fn, out, x, t, model_kwargs=model_kwargs
          )
  
      # Usually our model outputs epsilon, but we re-derive it
      # in case we used x_start or x_prev prediction.
      eps = self._predict_eps_from_xstart(x, t, out["pred_xstart"])
  
      alpha_bar = _extract_into_tensor(self.alphas_cumprod, t, x.shape)
      alpha_bar_prev = _extract_into_tensor(
          self.alphas_cumprod_prev, t, x.shape
      )
      sigma = (
          eta
          * th.sqrt((1 - alpha_bar_prev) / (1 - alpha_bar))
          * th.sqrt(1 - alpha_bar / alpha_bar_prev)
      )
      # Equation 12.
      noise = th.randn_like(x)
      mean_pred = (
          out["pred_xstart"] * th.sqrt(alpha_bar_prev)
          + th.sqrt(1 - alpha_bar_prev - sigma**2) * eps
      )
      nonzero_mask = (
          (t != 0).float().view(-1, *([1] * (len(x.shape) - 1)))
      )  # no noise when t == 0
      sample = mean_pred + nonzero_mask * sigma * noise
      return {"sample": sample, "pred_xstart": out["pred_xstart"]}
  
imports: import math
  import numpy
  import torch
label_desc: Use image node_id 13 for calling the GaussianDiffusion obj's underlying member method code with example usage: obj.ddim_sample(model, x, t, clip_denoised, denoised_fn, cond_fn, model_kwargs, eta) and returns: dict