code: def similar_users(user_id, user_features, model, N=10):
      """Function to return top N similar users based on https://github.com/lyst/lightfm/issues/244#issuecomment-355305681
  
       Args:
          user_id (int): id of user to be used as reference
          user_features (scipy sparse CSR matrix): user feature matric
          model (LightFM instance): fitted LightFM model
          N (int): Number of top similar users to return
  
      Returns:
          pandas.DataFrame: top N most similar users with score
      """
      _, user_representations = model.get_user_representations(
          features=user_features
      )
  
      # Cosine similarity
      scores = user_representations.dot(
          user_representations[user_id, :]
      )
      user_norms = np.linalg.norm(user_representations, axis=1)
      user_norms[user_norms == 0] = 1e-10
      scores /= user_norms
  
      best = np.argpartition(scores, -(N + 1))[-(N + 1) :]
      return pd.DataFrame(
          sorted(
              zip(best, scores[best] / user_norms[user_id]),
              key=lambda x: -x[1],
          )[1:],
          columns=["userID", "score"],
      )
  
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 4 for calling a global function with example usage: similar_users(user_id, user_features, model, N) and returns: pd