code: def prepare_test_df(test_idx, uids, iids, uid_map, iid_map, weights):
      """Function to prepare test df for evaluation
  
      Args:
          test_idx (slice): slice of test indices
          uids (numpy.ndarray): Array of internal user indices
          iids (numpy.ndarray): Array of internal item indices
          uid_map (dict): Keys to map internal user indices to external ids.
          iid_map (dict): Keys to map internal item indices to external ids.
          weights (numpy.float32 coo_matrix): user-item interaction
  
      Returns:
          pandas.DataFrame: user-item selected for testing
      """
      test_df = pd.DataFrame(
          zip(
              uids[test_idx],
              iids[test_idx],
              [list(uid_map.keys())[x] for x in uids[test_idx]],
              [list(iid_map.keys())[x] for x in iids[test_idx]],
          ),
          columns=["uid", "iid", "userID", "itemID"],
      )
  
      dok_weights = weights.todok()
      test_df["rating"] = test_df.apply(
          lambda x: dok_weights[x.uid, x.iid], axis=1
      )
  
      return test_df[["userID", "itemID", "rating"]]
  
file_path: recommenders/recommenders/models/lightfm/lightfm_utils.py
imports: import pandas
  import numpy
  import seaborn
  from lightfm.evaluation import precision_at_k, recall_at_k
label_desc: Use image node_id 6 for calling a global function with example usage: prepare_test_df(test_idx, uids, iids, uid_map, iid_map, weights) and returns: test_df