class_docstr: RaCT is a collaborative filtering model which uses methods based on actor-critic reinforcement learning for training.
  
  We implement the RaCT model with only user dataloader.
class_docstr_tok: ["RaCT","is","a","collaborative","filtering","model","which","uses","methods","based","on","actor-critic","reinforcement","learning","for","training",".","We","implement","the","RaCT","model","with","only","user","dataloader","."]
code: def calculate_ndcg(
      self, predict_matrix, true_matrix, input_matrix, k
  ):
      users_num = predict_matrix.shape[0]
      predict_matrix[input_matrix.nonzero(as_tuple=True)] = -np.inf
      _, idx_sorted = torch.sort(predict_matrix, dim=1, descending=True)
  
      topk_result = true_matrix[
          np.arange(users_num)[:, np.newaxis], idx_sorted[:, :k]
      ]
  
      number_non_zero = ((true_matrix > 0) * 1).sum(dim=1)
  
      tp = 1.0 / torch.log2(
          torch.arange(2, k + 2).type(torch.FloatTensor)
      ).to(topk_result.device)
      DCG = (topk_result * tp).sum(dim=1)
      IDCG = torch.Tensor(
          [(tp[: min(n, k)]).sum() for n in number_non_zero]
      ).to(topk_result.device)
      IDCG = torch.maximum(
          0.1 * torch.ones_like(IDCG).to(IDCG.device), IDCG
      )
  
      return DCG / IDCG
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  import numpy
  from recbole.model.abstract_recommender import AutoEncoderMixin, GeneralRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.utils import InputType
label_desc: Use image node_id 8 for calling the RaCT obj's underlying member method code with example usage: obj.calculate_ndcg(predict_matrix, true_matrix, input_matrix, k) and returns: unknown