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","."]
docstr: Get a batch of user's embedding with the user's id and history interaction matrix.
  
  Args:
      user (torch.LongTensor): The input tensor that contains user's id, shape: [batch_size, ]
  
  Returns:
      torch.FloatTensor: The embedding tensor of a batch of user, shape: [batch_size, embedding_size]
docstr_tok: ["Get","a","batch","of","user","'s","embedding","with","the","user","'s","id","and","history","interaction","matrix",".","Args",":","user","(","torch.LongTensor",")",":","The","input","tensor","that","contains","user","'s","id",",","shape",":","[","batch_size",",","]","Returns",":","torch.FloatTensor",":","The","embedding","tensor","of","a","batch","of","user",",","shape",":","[","batch_size",",","embedding_size","]"]
code: def get_user_embedding(self, user):
      r"""Get a batch of user's embedding with the user's id and history interaction matrix.
  
      Args:
          user (torch.LongTensor): The input tensor that contains user's id, shape: [batch_size, ]
  
      Returns:
          torch.FloatTensor: The embedding tensor of a batch of user, shape: [batch_size, embedding_size]
      """
      # Following lines construct tensor of shape [B,n_items] using the tensor of shape [B,H]
      col_indices = self.history_item_id[user].flatten()
      row_indices = torch.arange(user.shape[0]).to(self.device)
      row_indices = row_indices.repeat_interleave(
          self.history_item_id.shape[1], dim=0
      )
      matrix_01 = (
          torch.zeros(1)
          .to(self.device)
          .repeat(user.shape[0], self.n_items)
      )
      matrix_01.index_put_(
          (row_indices, col_indices),
          self.history_item_value[user].flatten(),
      )
      user = self.user_linear(matrix_01)
  
      return user
  
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 6 for calling the DMF obj's underlying member method code with example usage: obj.get_user_embedding(user) and returns: user