code: def test_ii_batch_recommend(ncpus):
      import lenskit.crossfold as xf
      from lenskit import topn
  
      ratings = lktu.ml100k.ratings
  
      def eval(train, test):
          _log.info("running training")
          algo = knn.ItemItem(30)
          algo = Recommender.adapt(algo)
          algo.fit(train)
          _log.info("testing %d users", test.user.nunique())
          recs = batch.recommend(
              algo, test.user.unique(), 100, n_jobs=ncpus
          )
          return recs
  
      test_frames = []
      recs = []
      for train, test in xf.partition_users(
          ratings, 5, xf.SampleFrac(0.2)
      ):
          test_frames.append(test)
          recs.append(eval(train, test))
  
      test = pd.concat(test_frames)
      recs = pd.concat(recs)
  
      _log.info("analyzing recommendations")
      rla = topn.RecListAnalysis()
      rla.add_metric(topn.ndcg)
      results = rla.compute(recs, test)
      dcg = results.ndcg
      _log.info("nDCG for %d users is %f", len(dcg), dcg.mean())
      assert dcg.mean() > 0.03
  
imports: from lenskit import ConfigWarning, DataWarning
  from lenskit.algorithms import Recommender
  from lenskit.algorithms.basic import Fallback
  from lenskit.algorithms.bias import Bias
  from lenskit import batch
  import lenskit.algorithms.item_knn
  from lenskit.sharing import persist
  from lenskit.util.parallel import run_sp
  from lenskit.util import clone
  import gc
  from pathlib import Path
  import logging
  import pickle
  import pandas
  import numpy
  from scipy import linalg
  import csr.kernel
  import pytest
  from pytest import approx, mark, fixture
  import lenskit.util.test
  from lenskit.util.parallel import invoker
  from lenskit.util import Stopwatch
label_desc: Use image node_id 27 for calling a global function with example usage: test_ii_batch_recommend(ncpus) and returns: recs