code: def test_get_popularity_based_topk(header):
      train_df = pd.DataFrame(
          {
              header["col_user"]: [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4],
              header["col_item"]: [1, 4, 2, 1, 5, 4, 1, 4, 6, 3, 2, 4],
              header["col_rating"]: [
                  1,
                  2,
                  3,
                  1,
                  2,
                  3,
                  1,
                  2,
                  3,
                  3,
                  3,
                  1,
              ],
          }
      )
  
      sar = SAR(**header)
      sar.fit(train_df)
  
      expected = pd.DataFrame(
          dict(MovieId=[4, 1, 2], prediction=[4, 3, 2])
      )
      actual = sar.get_popularity_based_topk(top_k=3, sort_top_k=True)
      assert_frame_equal(expected, actual)
  
      # get most popular users
      expected = pd.DataFrame(
          dict(UserId=[3, 2, 1], prediction=[5, 4, 2])
      )
      actual = sar.get_popularity_based_topk(
          top_k=3, sort_top_k=True, items=False
      )
      assert_frame_equal(expected, actual)
  
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 9 for calling a global function with example usage: test_get_popularity_based_topk(header) without return types