class_docstr: Mixin to test a bunch of common functionality in models
  deriving from RecommenderBase
code: def test_rank_items(self):
      item_users = get_checker_board(50)
      user_items = item_users.T.tocsr()
  
      model = self._get_model()
      model.fit(item_users, show_progress=False)
  
      try:
          selected_items = np.array([1, 2, 3, 4, 5, 6])
          ids, _ = model.recommend(
              0, user_items[0], items=selected_items, N=20
          )
  
          self.assertEqual(len(ids), len(selected_items))
  
          # ranked list should have same items
          self.assertEqual(set(ids), set(selected_items))
  
          if not isinstance(model, ItemItemRecommender):
              # items 2,4,6 are in the 'filter_alread_liked_items' set
              # and should be in the last 3 positions (except with itemitemrecommenders
              # where its a little more complicated since the sparse results)
              self.assertEqual(set(ids[3:]), set([2, 4, 6]))
  
      except NotImplementedError:
          return
  
      for userid in range(50):
          selected_items = random.sample(range(50), 10)
  
          ids, _ = model.recommend(
              userid,
              user_items[userid],
              items=selected_items,
              filter_already_liked_items=False,
          )
          # ranked list should have same items
          self.assertEqual(set(ids), set(selected_items))
  
          wrong_neg_items = [-1, -3, -5]
          wrong_pos_items = [51, 300, 200]
  
          # rank_items should raise IndexError if selected items contains wrong itemids
          with self.assertRaises(IndexError):
              wrong_item_list = selected_items + wrong_neg_items
              model.recommend(
                  userid, user_items[userid], items=wrong_item_list
              )
          with self.assertRaises(IndexError):
              wrong_item_list = selected_items + wrong_pos_items
              model.recommend(
                  userid, user_items[userid], items=wrong_item_list
              )
  
imports: import os
  import pickle
  import random
  import tempfile
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from scipy.sparse import coo_matrix, csr_matrix
  from implicit.evaluation import precision_at_k
  from implicit.nearest_neighbours import ItemItemRecommender
  from implicit.utils import ParameterWarning
label_desc: Use image node_id 16 for calling the RecommenderBaseTestMixin obj's underlying member method code with example usage: obj.test_rank_items() without return types