code: def RecallPrecision_ATk(test_data, r, k):
      """
      test_data should be a list? cause users may have different amount of pos items. shape (test_batch, k)
      pred_data : shape (test_batch, k) NOTE: pred_data should be pre-sorted
      k : top-k
      """
      right_pred = r[:, :k].sum(1)
      precis_n = k
      recall_n = np.array(
          [len(test_data[i]) for i in range(len(test_data))]
      )
      recall = np.sum(right_pred / recall_n)
      precis = np.sum(right_pred) / precis_n
      return {"recall": recall, "precision": precis}
  
imports: import paddle
  from paddle import nn, optimizer
  import numpy
  from paddle import log
  from dataloader import BasicDataset
  from paddle.io import Dataset
  from time import time
  from sklearn.metrics import roc_auc_score
  import random
  import os
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: RecallPrecision_ATk(test_data, r, k) and returns: dict