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: Apply the model to get p(x_{t-1} | x_t), as well as a prediction of
  the initial x, x_0.
code: def p_mean_variance(self, x, t):
      r"""
      Apply the model to get p(x_{t-1} | x_t), as well as a prediction of
      the initial x, x_0.
      """
      B, C = x.shape[:2]
      assert t.shape == (B,)
      model_output = self.mlp(x, t)
  
      model_variance = self.posterior_variance
      model_log_variance = self.posterior_log_variance_clipped
  
      model_variance = self._extract_into_tensor(
          model_variance, t, x.shape
      )
      model_log_variance = self._extract_into_tensor(
          model_log_variance, t, x.shape
      )
  
      if self.mean_type == ModelMeanType.START_X:
          pred_xstart = model_output
      elif self.mean_type == ModelMeanType.EPSILON:
          pred_xstart = self._predict_xstart_from_eps(
              x, t, eps=model_output
          )
      else:
          raise NotImplementedError(self.mean_type)
  
      model_mean, _, _ = self.q_posterior_mean_variance(
          x_start=pred_xstart, x_t=x, t=t
      )
  
      assert (
          model_mean.shape
          == model_log_variance.shape
          == pred_xstart.shape
          == x.shape
      )
  
      return {
          "mean": model_mean,
          "variance": model_variance,
          "log_variance": model_log_variance,
          "pred_xstart": pred_xstart,
      }
  
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 14 for calling the DiffRec obj's underlying member method code with example usage: obj.p_mean_variance(x, t) and returns: dict