class_docstr: MacridVAE is an item-based collaborative filtering model that learns disentangled representations from user
  behavior and simultaneously ranks all items for each user.
  
  We implement the model following the original author.
class_docstr_tok: ["MacridVAE","is","an","item-based","collaborative","filtering","model","that","learns","disentangled","representations","from","user","behavior","and","simultaneously","ranks","all","items","for","each","user",".","We","implement","the","model","following","the","original","author","."]
code: def forward(self, rating_matrix):
      cores = F.normalize(self.k_embedding.weight, dim=1)
      items = F.normalize(self.item_embedding.weight, dim=1)
  
      rating_matrix = F.normalize(rating_matrix)
      rating_matrix = F.dropout(
          rating_matrix, self.drop_out, training=self.training
      )
  
      cates_logits = (
          torch.matmul(items, cores.transpose(0, 1)) / self.tau
      )
  
      if self.nogb:
          cates = torch.softmax(cates_logits, dim=-1)
      else:
          cates_sample = F.gumbel_softmax(
              cates_logits, tau=1, hard=False, dim=-1
          )
          cates_mode = torch.softmax(cates_logits, dim=-1)
          cates = (
              self.training * cates_sample
              + (1 - self.training) * cates_mode
          )
  
      probs = None
      mulist = []
      logvarlist = []
      for k in range(self.kfac):
          cates_k = cates[:, k].reshape(1, -1)
          # encoder
          x_k = rating_matrix * cates_k
          h = self.encoder(x_k)
          mu = h[:, : self.embedding_size]
          mu = F.normalize(mu, dim=1)
          logvar = h[:, self.embedding_size :]
  
          mulist.append(mu)
          logvarlist.append(logvar)
  
          z = self.reparameterize(mu, logvar)
  
          # decoder
          z_k = F.normalize(z, dim=1)
          logits_k = torch.matmul(z_k, items.transpose(0, 1)) / self.tau
          probs_k = torch.exp(logits_k)
          probs_k = probs_k * cates_k
          probs = probs_k if (probs is None) else (probs + probs_k)
  
      logits = torch.log(probs)
  
      return logits, mulist, logvarlist
  
file_path: RecBole/recbole/model/general_recommender/macridvae.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from recbole.model.abstract_recommender import AutoEncoderMixin, GeneralRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.loss import EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 4 for calling the MacridVAE obj's underlying member method code with example usage: obj.forward(rating_matrix) and returns: logits,  mulist,  logvarlist