code: def _train_and_save(algo, file, ratings, kwargs):
      "Worker for subprocess model training"
      _log.info("training %s on %d ratings", algo, len(ratings))
      timer = Stopwatch()
      algo.fit(ratings, **kwargs)
      _log.info("trained %s in %s", algo, timer)
      if file is None:
          return persist_binpickle(algo).transfer()
      else:
          return persist_binpickle(algo, file=file).transfer()
  
imports: import logging
  from lenskit.sharing import persist, persist_binpickle
  from lenskit.util.parallel import run_sp
  from lenskit.util import Stopwatch
label_desc: Use image node_id 1 for calling a global function with example usage: _train_and_save(algo, file, ratings, kwargs) and returns: persist_binpickle, persist_binpickle