class_docstr: DMF is an neural network enhanced matrix factorization model.
  The original interaction matrix of :math:`n_{users} \times n_{items}` is set as model input,
  we carefully design the data interface and use sparse tensor to train and test efficiently.
  We just implement the model following the original author with a pointwise training mode.
  
  Note:
  
      Our implementation is a improved version which is different from the original paper.
      For a better performance and stability, we replace cosine similarity to inner-product when calculate
      final score of user's and item's embedding.
class_docstr_tok: ["DMF","is","an","neural","network","enhanced","matrix","factorization","model",".","The","original","interaction","matrix","of",":","math",":","`","n_","{","users","}","\\times","n_","{","items","}","`","is","set","as","model","input",",","we","carefully","design","the","data","interface","and","use","sparse","tensor","to","train","and","test","efficiently",".","We","just","implement","the","model","following","the","original","author","with","a","pointwise","training","mode",".","Note",":","Our","implementation","is","a","improved","version","which","is","different","from","the","original","paper",".","For","a","better","performance","and","stability",",","we","replace","cosine","similarity","to","inner-product","when","calculate","final","score","of","user","'s","and","item","'s","embedding","."]
code: def forward(self, user, item):
      user = self.get_user_embedding(user)
  
      # Following lines construct tensor of shape [B,n_users] using the tensor of shape [B,H]
      col_indices = self.history_user_id[item].flatten()
      row_indices = (
          torch.arange(item.shape[0])
          .to(self.device)
          .repeat_interleave(self.history_user_id.shape[1], dim=0)
      )
      matrix_01 = (
          torch.zeros(1)
          .to(self.device)
          .repeat(item.shape[0], self.n_users)
      )
      matrix_01.index_put_(
          (row_indices, col_indices),
          self.history_user_value[item].flatten(),
      )
      item = self.item_linear(matrix_01)
  
      user = self.user_fc_layers(user)
      item = self.item_fc_layers(item)
  
      # cosine distance is replaced by dot product according the result of our experiments.
      vector = torch.mul(user, item).sum(dim=1)
  
      return vector
  
file_path: RecBole/recbole/model/general_recommender/dmf.py
imports: import numpy
  import torch
  import torch.nn
  from torch.nn.init import normal_
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.layers import MLPLayers
  from recbole.utils import InputType
label_desc: Use image node_id 3 for calling the DMF obj's underlying member method code with example usage: obj.forward(user, item) and returns: vector