code: def test_user_affinity(demo_usage_data, sar_settings, header):
      time_now = demo_usage_data[header["col_timestamp"]].max()
      model = SAR(
          similarity_type="cooccurrence",
          timedecay_formula=True,
          time_decay_coefficient=30,
          time_now=time_now,
          **header,
      )
      model.fit(demo_usage_data)
  
      true_user_affinity = pd.read_csv(
          sar_settings["FILE_DIR"] + "user_aff.csv", index_col=0
      )
      sar_user_affinity = (
          model.user_affinity[
              model.user2index[sar_settings["TEST_USER_ID"]],
              pd.Series(model.item2index)[true_user_affinity.columns],
          ]
          .toarray()
          .flatten()
      )
      assert np.allclose(
          true_user_affinity.astype("float64"),
          sar_user_affinity.astype("float64"),
          atol=sar_settings["ATOL"],
      )
  
      # Set time_now to 60 days later
      two_months = 2 * 30 * (24 * 60 * 60)
      model = SAR(
          similarity_type="cooccurrence",
          timedecay_formula=True,
          time_decay_coefficient=30,
          time_now=demo_usage_data[header["col_timestamp"]].max()
          + two_months,
          **header,
      )
      model.fit(demo_usage_data)
  
      true_user_affinity = pd.read_csv(
          sar_settings["FILE_DIR"] + "user_aff_2_months_later.csv",
          index_col=0,
      )
      sar_user_affinity = (
          model.user_affinity[
              model.user2index[sar_settings["TEST_USER_ID"]],
              pd.Series(model.item2index)[true_user_affinity.columns],
          ]
          .toarray()
          .flatten()
      )
      assert np.allclose(
          true_user_affinity.astype("float64"),
          sar_user_affinity.astype("float64"),
          atol=sar_settings["ATOL"],
      )
  
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 6 for calling a global function with example usage: test_user_affinity(demo_usage_data, sar_settings, header) without return types