code: def prepare_all_predictions(
      data,
      uid_map,
      iid_map,
      interactions,
      model,
      num_threads,
      user_features=None,
      item_features=None,
  ):
      """Function to prepare all predictions for evaluation.
      Args:
          data (pandas df): dataframe of all users, items and ratings as loaded
          uid_map (dict): Keys to map internal user indices to external ids.
          iid_map (dict): Keys to map internal item indices to external ids.
          interactions (np.float32 coo_matrix): user-item interaction
          model (LightFM instance): fitted LightFM model
          num_threads (int): number of parallel computation threads
          user_features (np.float32 csr_matrix): User weights over features
          item_features (np.float32 csr_matrix):  Item weights over features
      Returns:
          pandas.DataFrame: all predictions
      """
      users, items, preds = [], [], []  # noqa: F841
      item = list(data.itemID.unique())
      for user in data.userID.unique():
          user = [user] * len(item)
          users.extend(user)
          items.extend(item)
      all_predictions = pd.DataFrame(
          data={"userID": users, "itemID": items}
      )
      all_predictions["uid"] = all_predictions.userID.map(uid_map)
      all_predictions["iid"] = all_predictions.itemID.map(iid_map)
  
      dok_weights = interactions.todok()
      all_predictions["rating"] = all_predictions.apply(
          lambda x: dok_weights[x.uid, x.iid], axis=1
      )
  
      all_predictions = all_predictions[
          all_predictions.rating < 1
      ].reset_index(drop=True)
      all_predictions = all_predictions.drop("rating", axis=1)
  
      all_predictions["prediction"] = all_predictions.apply(
          lambda x: model.predict(
              user_ids=np.array([x["uid"]], dtype=np.int32),
              item_ids=np.array([x["iid"]], dtype=np.int32),
              user_features=user_features,
              item_features=item_features,
              num_threads=num_threads,
          )[0],
          axis=1,
      )
  
      return all_predictions[["userID", "itemID", "prediction"]]
  
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 7 for calling a global function with example usage: prepare_all_predictions(data, uid_map, iid_map, interactions, model, num_threads, user_features, item_features) and returns: all_predictions