code: def _generate_data(
      num_users, num_items, density=0.1, test_fraction=0.2
  ):
      # Generate a dataset where every user has interactions
      # in both the train and the test set.
  
      train = sp.lil_matrix((num_users, num_items), dtype=np.float32)
      test = sp.lil_matrix((num_users, num_items), dtype=np.float32)
  
      for user_id in range(num_users):
          positives = np.random.choice(
              num_items, size=int(density * num_items), replace=False
          )
  
          for item_id in positives[
              : int(test_fraction * len(positives))
          ]:
              test[user_id, item_id] = 1.0
  
          for item_id in positives[
              int(test_fraction * len(positives)) :
          ]:
              train[user_id, item_id] = 1.0
  
      return train.tocoo(), test.tocoo()
  
file_path: lightfm/tests/test_evaluation.py
imports: import numpy
  import pytest
  import scipy.sparse
  from sklearn.metrics import roc_auc_score
  from lightfm.lightfm import LightFM
  from lightfm import evaluation
label_desc: Use image node_id 1 for calling a global function with example usage: _generate_data(num_users, num_items, density, test_fraction) and returns: train,  test