class_docstr: DiffRec is a generative recommender model which infers users' interaction probabilities in a denoising manner.
  Note that DiffRec simultaneously ranks all items for each user.
  We implement the the DiffRec model with only user dataloader.
class_docstr_tok: ["DiffRec","is","a","generative","recommender","model","which","infers","users","'","interaction","probabilities","in","a","denoising","manner",".","Note","that","DiffRec","simultaneously","ranks","all","items","for","each","user",".","We","implement","the","the","DiffRec","model","with","only","user","dataloader","."]
docstr: 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):
      r"""
      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 = (
          self._extract_into_tensor(
              self.posterior_mean_coef1, t, x_t.shape
          )
          * x_start
          + self._extract_into_tensor(
              self.posterior_mean_coef2, t, x_t.shape
          )
          * x_t
      )
      posterior_variance = self._extract_into_tensor(
          self.posterior_variance, t, x_t.shape
      )
      posterior_log_variance_clipped = self._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 copy
  import numpy
  import torch
  import torch.nn.functional
  import torch.nn
  from recbole.model.init import xavier_normal_initialization
  from recbole.utils.enum_type import InputType
  from recbole.model.abstract_recommender import AutoEncoderMixin, GeneralRecommender
  from recbole.model.layers import MLPLayers
  import typing
label_desc: Use image node_id 13 for calling the DiffRec 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