code: def benchmark_accuracy(plays):
      output = defaultdict(list)
  
      def store_loss(name):
          def inner(iteration, elapsed, loss):
              print(
                  f"model {name} iteration {iteration} loss {loss:.5f}"
              )
              output[name].append(loss)
  
          return inner
  
      for steps in [2, 3, 4]:
          model = AlternatingLeastSquares(
              factors=128,
              use_gpu=False,
              regularization=0,
              iterations=25,
              calculate_training_loss=True,
          )
          model.cg_steps = steps
          model.fit_callback = store_loss(f"cg{steps}")
          model.fit(plays)
  
      if HAS_CUDA:
          model = AlternatingLeastSquares(
              factors=128,
              use_native=True,
              use_gpu=True,
              regularization=0,
              iterations=25,
              calculate_training_loss=True,
          )
          model.fit_callback = store_loss("gpu")
          model.use_gpu = True
          model.fit(plays)
  
      model = AlternatingLeastSquares(
          factors=128,
          use_native=True,
          use_cg=False,
          use_gpu=False,
          regularization=0,
          iterations=25,
          calculate_training_loss=True,
      )
      model.fit_callback = store_loss("cholesky")
      model.fit(plays)
  
      return output
  
file_path: implicit/benchmarks/benchmark_als.py
imports: import argparse
  import json
  import logging
  from collections import defaultdict
  import matplotlib.pyplot
  import scipy.io
  import seaborn
  from implicit.als import AlternatingLeastSquares
  from implicit.gpu import HAS_CUDA
  from implicit.nearest_neighbours import bm25_weight
label_desc: Use image node_id 1 for calling a global function with example usage: benchmark_accuracy(plays) and returns: output, inner