code: def test_userpred(
      spark,
      tmp_path,
      threshold,
      similarity_type,
      file,
      header,
      sar_settings,
      demo_usage_data,
  ):
      time_now = demo_usage_data[header["col_timestamp"]].max()
  
      test_id = "{0}_{1}_{2}".format(threshold, similarity_type, file)
  
      model = SARPlus(
          spark,
          **header,
          table_prefix=test_id,
          timedecay_formula=True,
          time_decay_coefficient=30,
          time_now=time_now,
          threshold=threshold,
          similarity_type=similarity_type,
          cache_path=str(tmp_path.joinpath("test_userpred-" + test_id)),
      )
  
      df = spark.createDataFrame(demo_usage_data)
      model.fit(df)
  
      url = (
          sar_settings["FILE_DIR"]
          + "userpred_"
          + file
          + str(threshold)
          + "_userid_only.csv"
      )
  
      pred_ref = pd.read_csv(url)
      pred_ref = (
          pd.wide_to_long(pred_ref, ["rec", "score"], "user", "idx")
          .sort_values("score", ascending=False)
          .reset_index(drop=True)
      )
  
      # Note: it's important to have a separate cache_path for each run as they're interfering with each other
      pred = model.recommend_k_items(
          spark.createDataFrame(
              demo_usage_data[
                  demo_usage_data[header["col_user"]]
                  == sar_settings["TEST_USER_ID"]
              ]
          ),
          top_k=10,
          n_user_prediction_partitions=1,
          use_cache=True,
      )
  
      pred = (
          pred.toPandas()
          .sort_values("score", ascending=False)
          .reset_index(drop=True)
      )
  
      assert (pred.MovieId.values == pred_ref.rec.values).all()
      assert np.allclose(
          pred.score.values,
          pred_ref.score.values,
          atol=sar_settings["ATOL"],
      )
  
imports: import math
  from pathlib import Path
  import numpy
  import pandas
  from pyspark.sql import SparkSession
  import pytest
  from pandas.testing import assert_frame_equal
  from pysarplus import SARPlus, SARModel
label_desc: Use image node_id 14 for calling a global function with example usage: test_userpred(spark, tmp_path, threshold, similarity_type, file, header, sar_settings, demo_usage_data) without return types