code: def test_als_method_match():
      lu = als.BiasedMF(
          20, iterations=15, reg=(2, 0.001), method="lu", rng_spec=42
      )
      cd = als.BiasedMF(
          20, iterations=20, reg=(2, 0.001), method="cd", rng_spec=42
      )
  
      ratings = lktu.ml_test.ratings
  
      timer = Stopwatch()
      lu.fit(ratings)
      timer.stop()
      _log.info("fit with LU solver in %s", timer)
  
      timer = Stopwatch()
      cd.fit(ratings)
      timer.stop()
      _log.info("fit with CD solver in %s", timer)
  
      assert lu.bias.mean_ == approx(ratings.rating.mean())
      assert cd.bias.mean_ == approx(ratings.rating.mean())
  
      preds = []
  
      rng = numpy_rng(42)
      for u in rng.choice(np.unique(ratings.user), 15, replace=False):
          items = rng.choice(np.unique(ratings.item), 15, replace=False)
          lu_preds = lu.predict_for_user(u, items)
          cd_preds = cd.predict_for_user(u, items)
          diff = lu_preds - cd_preds
          adiff = np.abs(diff)
          _log.info(
              "user %s diffs: L2 = %f, min = %f, med = %f, max = %f, 90%% = %f",
              u,
              np.linalg.norm(diff, 2),
              np.min(adiff),
              np.median(adiff),
              np.max(adiff),
              np.quantile(adiff, 0.9),
          )
  
          preds.append(
              pd.DataFrame(
                  {
                      "user": u,
                      "item": items,
                      "lu": lu_preds,
                      "cd": cd_preds,
                      "adiff": adiff,
                  }
              )
          )
  
      preds = pd.concat(preds, ignore_index=True)
      _log.info("LU preds:\n%s", preds.lu.describe())
      _log.info("CD preds:\n%s", preds.cd.describe())
      _log.info("overall differences:\n%s", preds.adiff.describe())
      # there are differences. our check: the 90% are under a quarter star
      assert np.quantile(adiff, 0.9) <= 0.27
  
imports: import logging
  import pickle
  from pickletools import dis
  from lenskit.algorithms import als
  from lenskit import util
  import pandas
  import numpy
  from seedbank import numpy_rng
  from pytest import approx, mark
  from lenskit.util import Stopwatch
  import lenskit.util.test
label_desc: Use image node_id 13 for calling a global function with example usage: test_als_method_match() without return types