code: def test_als_isolate(ml20m, rng):
      users = rng.choice(ml20m["user"].unique(), 5000, replace=False)
      algo = BiasedMF(20, iterations=10)
      algo = Recommender.adapt(algo)
      _log.info("training %s", algo)
      ares = batch.train_isolated(algo, ml20m)
      try:
          _log.info("recommending with %s", algo)
          recs = batch.recommend(ares, users, 10)
          assert recs["user"].nunique() == 5000
          _log.info("predicting with %s", algo)
          pairs = ml20m.sample(1000)
          preds = batch.predict(ares, pairs)
          assert len(preds) == len(pairs)
      finally:
          ares.close()
  
file_path: lkpy/tests/test_ml20m.py
imports: import logging
  from pathlib import Path
  from lenskit.datasets import MovieLens
  from lenskit import batch
  from lenskit.algorithms import Recommender
  from lenskit.algorithms.basic import Popular
  from lenskit.algorithms.als import BiasedMF
  import pytest
label_desc: Use image node_id 3 for calling a global function with example usage: test_als_isolate(ml20m, rng) without return types