code: def test_intersections_check():
      no_users, no_items = (10, 100)
  
      train, test = _generate_data(no_users, no_items)
  
      model = LightFM(loss="bpr")
      model.fit_partial(train)
  
      # check error is raised when train and test have interactions in common
      with pytest.raises(ValueError):
          evaluation.auc_score(
              model,
              train,
              train_interactions=train,
              check_intersections=True,
          )
  
      with pytest.raises(ValueError):
          evaluation.recall_at_k(
              model,
              train,
              train_interactions=train,
              check_intersections=True,
          )
  
      with pytest.raises(ValueError):
          evaluation.precision_at_k(
              model,
              train,
              train_interactions=train,
              check_intersections=True,
          )
  
      with pytest.raises(ValueError):
          evaluation.reciprocal_rank(
              model,
              train,
              train_interactions=train,
              check_intersections=True,
          )
  
      # check no errors raised when train and test have no interactions in common
      evaluation.auc_score(
          model,
          test,
          train_interactions=train,
          check_intersections=True,
      )
      evaluation.recall_at_k(
          model,
          test,
          train_interactions=train,
          check_intersections=True,
      )
      evaluation.precision_at_k(
          model,
          test,
          train_interactions=train,
          check_intersections=True,
      )
      evaluation.reciprocal_rank(
          model,
          test,
          train_interactions=train,
          check_intersections=True,
      )
  
      # check no error is raised when there are intersections but flag is False
      evaluation.auc_score(
          model,
          train,
          train_interactions=train,
          check_intersections=False,
      )
      evaluation.recall_at_k(
          model,
          train,
          train_interactions=train,
          check_intersections=False,
      )
      evaluation.precision_at_k(
          model,
          train,
          train_interactions=train,
          check_intersections=False,
      )
      evaluation.reciprocal_rank(
          model,
          train,
          train_interactions=train,
          check_intersections=False,
      )
  
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 9 for calling a global function with example usage: test_intersections_check() without return types