class_docstr: Utilities for training and sampling diffusion models.
  
  Ported directly from here, and then adapted over time to further experimentation.
  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.
  :param model_mean_type: a ModelMeanType determining what the model outputs.
  :param model_var_type: a ModelVarType determining how variance is output.
  :param loss_type: a LossType determining the loss function to use.
  :param rescale_timesteps: if True, pass floating point timesteps into the
                            model so that they are always scaled like in the
                            original paper (0 to 1000).
class_docstr_tok: ["Utilities","for","training","and","sampling","diffusion","models",".","Ported","directly","from","here",",","and","then","adapted","over","time","to","further","experimentation",".","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.",":","param","model_mean_type",":","a","ModelMeanType","determining","what","the","model","outputs",".",":","param","model_var_type",":","a","ModelVarType","determining","how","variance","is","output",".",":","param","loss_type",":","a","LossType","determining","the","loss","function","to","use",".",":","param","rescale_timesteps",":","if","True",",","pass","floating","point","timesteps","into","the","model","so","that","they","are","always","scaled","like","in","the","original","paper","(","0","to","1000",")","."]
docstr: Compute what the p_mean_variance output would have been, should the
  model's score function be conditioned by cond_fn.
  
  See condition_mean() for details on cond_fn.
  
  Unlike condition_mean(), this instead uses the conditioning strategy
  from Song et al (2020).
docstr_tok: ["Compute","what","the","p_mean_variance","output","would","have","been",",","should","the","model","'s","score","function","be","conditioned","by","cond_fn",".","See","condition_mean","(",")","for","details","on","cond_fn",".","Unlike","condition_mean","(",")",",","this","instead","uses","the","conditioning","strategy","from","Song","et","al","(","2020",")","."]
code: def condition_score(
      self, cond_fn, p_mean_var, x, t, model_kwargs=None
  ):
      """
      Compute what the p_mean_variance output would have been, should the
      model's score function be conditioned by cond_fn.
  
      See condition_mean() for details on cond_fn.
  
      Unlike condition_mean(), this instead uses the conditioning strategy
      from Song et al (2020).
      """
      alpha_bar = _extract_into_tensor(self.alphas_cumprod, t, x.shape)
  
      eps = self._predict_eps_from_xstart(
          x, t, p_mean_var["pred_xstart"]
      )
      eps = eps - (1 - alpha_bar).sqrt() * cond_fn(
          x, self._scale_timesteps(t), **model_kwargs
      )
  
      out = p_mean_var.copy()
      out["pred_xstart"] = self._predict_xstart_from_eps(x, t, eps)
      out["mean"], _, _ = self.q_posterior_mean_variance(
          x_start=out["pred_xstart"], x_t=x, t=t
      )
      return out
  
imports: import enum
  import math
  import numpy
  import torch
  import torch
  from tqdm import tqdm
  from TTS.tts.layers.tortoise.dpm_solver import DPM_Solver, NoiseScheduleVP, model_wrapper
label_desc: Use image node_id 11 for calling the GaussianDiffusion obj's underlying member method code with example usage: obj.condition_score(cond_fn, p_mean_var, x, t, model_kwargs) and returns: out