code: def test_get_item_based_topk(header, pandas_dummy):
      sar = SAR(**header)
      sar.fit(pandas_dummy)
  
      # test with just items provided
      expected = pd.DataFrame(
          dict(
              UserId=[0, 0, 0],
              MovieId=[8, 7, 6],
              prediction=[2.0, 2.0, 2.0],
          )
      )
      items = pd.DataFrame({header["col_item"]: [1, 5, 10]})
      actual = sar.get_item_based_topk(items, top_k=3)
      assert_frame_equal(expected, actual, check_dtype=False)
  
      # test with items and users
      expected = pd.DataFrame(
          dict(
              UserId=[100, 100, 100, 1, 1, 1],
              MovieId=[8, 7, 6, 4, 3, 10],
              prediction=[2.0, 2.0, 2.0, 2.0, 2.0, 1.0],
          )
      )
      items = pd.DataFrame(
          {
              header["col_user"]: [100, 100, 1, 100, 1, 1],
              header["col_item"]: [1, 5, 1, 10, 2, 6],
          }
      )
      actual = sar.get_item_based_topk(items, top_k=3, sort_top_k=True)
      assert_frame_equal(expected, actual, check_dtype=False)
  
      # test with items, users, and ratings
      expected = pd.DataFrame(
          dict(
              UserId=[100, 100, 100, 1, 1, 1],
              MovieId=[2, 4, 3, 4, 3, 10],
              prediction=[5.0, 5.0, 5.0, 8.0, 8.0, 4.0],
          )
      ).set_index(["UserId", "MovieId"])
      items = pd.DataFrame(
          {
              header["col_user"]: [100, 100, 1, 100, 1, 1],
              header["col_item"]: [1, 5, 1, 10, 2, 6],
              header["col_rating"]: [5, 1, 3, 1, 5, 4],
          }
      )
      actual = sar.get_item_based_topk(items, top_k=3).set_index(
          ["UserId", "MovieId"]
      )
      assert_frame_equal(expected, actual, check_like=True)
  
imports: import json
  import pytest
  import itertools
  import numpy
  import pandas
  from pandas.testing import assert_frame_equal
  from recommenders.utils.constants import DEFAULT_PREDICTION_COL
  from recommenders.models.sar import SAR
label_desc: Use image node_id 8 for calling a global function with example usage: test_get_item_based_topk(header, pandas_dummy) without return types