code: def main(unused_argv):
      checkpoint_dir = FLAGS.checkpoint
      if not checkpoint_dir:
          # If a checkpoint directory is not specified, see if there is only one
          # subdir in this folder and use that.
          possible_checkpoint_dirs = tf.gfile.ListDirectory(
              FLAGS.eval_logdir
          )
          possible_checkpoint_dirs = [
              i
              for i in possible_checkpoint_dirs
              if tf.gfile.IsDirectory(
                  os.path.join(FLAGS.eval_logdir, i)
              )
          ]
          if EVAL_SUBDIR in possible_checkpoint_dirs:
              possible_checkpoint_dirs.remove(EVAL_SUBDIR)
          if len(possible_checkpoint_dirs) == 1:
              checkpoint_dir = os.path.join(
                  FLAGS.eval_logdir, possible_checkpoint_dirs[0]
              )
              tf.logging.info(
                  "Using checkpoint dir: %s", checkpoint_dir
              )
          else:
              raise ValueError(
                  "Need to provide a path to checkpoint directory or use an "
                  "eval_logdir with only 1 checkpoint subdirectory."
              )
      wmodel = lib_graph.load_checkpoint(checkpoint_dir)
      if FLAGS.eval_logdir is None:
          raise ValueError(
              "Set flag eval_logdir to specify a path for saving eval statistics."
          )
      else:
          eval_logdir = os.path.join(FLAGS.eval_logdir, EVAL_SUBDIR)
          tf.gfile.MakeDirs(eval_logdir)
  
      evaluator = lib_evaluation.BaseEvaluator.make(
          FLAGS.unit, wmodel=wmodel, chronological=FLAGS.chronological
      )
      evaluator = lib_evaluation.EnsemblingEvaluator(
          evaluator, FLAGS.ensemble_size
      )
  
      if not FLAGS.sample_npy_path and FLAGS.fold is None:
          raise ValueError(
              "Either --fold must be specified, or paths of npy files to load must "
              "be given, but not both."
          )
      if FLAGS.fold is not None:
          evaluate_fold(
              FLAGS.fold,
              evaluator,
              wmodel.hparams,
              eval_logdir,
              checkpoint_dir,
          )
      if FLAGS.sample_npy_path is not None:
          evaluate_paths(
              [FLAGS.sample_npy_path],
              evaluator,
              wmodel.hparams,
              eval_logdir,
          )
      tf.logging.info("Done")
  
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 1 for calling a global function with example usage: main(unused_argv) without return types