code: def evaluate_fold(
      fold, evaluator, hparams, eval_logdir, checkpoint_dir
  ):
      """Writes to file the neg. loglikelihood of given fold (train/valid/test)."""
      eval_run_name = "eval_%s_%s%s_%s_ensemble%s_chrono%s" % (
          lib_util.timestamp(),
          fold,
          "" if FLAGS.fold_index is None else FLAGS.fold_index,
          FLAGS.unit,
          FLAGS.ensemble_size,
          FLAGS.chronological,
      )
      log_fname = "%s__%s.npz" % (
          os.path.basename(checkpoint_dir),
          eval_run_name,
      )
      log_fpath = os.path.join(eval_logdir, log_fname)
  
      pianorolls = get_fold_pianorolls(fold, hparams)
  
      rval = lib_evaluation.evaluate(evaluator, pianorolls)
      tf.logging.info("Writing to path: %s" % log_fpath)
      with lib_util.atomic_file(log_fpath) as p:
          np.savez_compressed(p, **rval)
  
file_path: magenta/magenta/models/coconet/coconet_evaluate.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from magenta.models.coconet import lib_data
  from magenta.models.coconet import lib_evaluation
  from magenta.models.coconet import lib_graph
  from magenta.models.coconet import lib_util
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: evaluate_fold(fold, evaluator, hparams, eval_logdir, checkpoint_dir) without return types