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.
class_docstr_tok: ["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: Compute the mean and variance of the diffusion posterior:
      q(x_{t-1} | x_t, x_0)
docstr_tok: ["Compute","the","mean","and","variance","of","the","diffusion","posterior",":","q","(","x_","{","t-1","}","|","x_t",",","x_0",")"]
code: def q_posterior_mean_variance(self, x_start, x_t, t):
      """
      Compute the mean and variance of the diffusion posterior:
          q(x_{t-1} | x_t, x_0)
      """
      assert x_start.shape == x_t.shape
      posterior_mean = (
          _extract_into_tensor(self.posterior_mean_coef1, t, x_t.shape)
          * x_start
          + _extract_into_tensor(
              self.posterior_mean_coef2, t, x_t.shape
          )
          * x_t
      )
      posterior_variance = _extract_into_tensor(
          self.posterior_variance, t, x_t.shape
      )
      posterior_log_variance_clipped = _extract_into_tensor(
          self.posterior_log_variance_clipped, t, x_t.shape
      )
      assert (
          posterior_mean.shape[0]
          == posterior_variance.shape[0]
          == posterior_log_variance_clipped.shape[0]
          == x_start.shape[0]
      )
      return (
          posterior_mean,
          posterior_variance,
          posterior_log_variance_clipped,
      )
  
imports: import enum
  import math
  import numpy
  import torch
label_desc: Use image node_id 4 for calling the GaussianDiffusion obj's underlying member method code with example usage: obj.q_posterior_mean_variance(x_start, x_t, t) and returns: posterior_mean,  posterior_variance,  posterior_log_variance_clipped