code: def main(unused_argv):
      """Parse gin config and run ddsp training, evaluation, or sampling."""
      restore_dir = os.path.expanduser(FLAGS.restore_dir)
      save_dir = os.path.expanduser(FLAGS.save_dir)
      # If no separate restore directory is given, use the save directory.
      restore_dir = save_dir if not restore_dir else restore_dir
      logging.info("Restore Dir: %s", restore_dir)
      logging.info("Save Dir: %s", save_dir)
  
      gfile.makedirs(
          restore_dir
      )  # Only makes dirs if they don't exist.
      parse_gin(restore_dir)
      logging.info("Operative Gin Config:\n%s", gin.config.config_str())
  
      if FLAGS.allow_memory_growth:
          allow_memory_growth()
  
      # Training.
      if FLAGS.mode == "train":
          strategy = train_util.get_strategy(
              tpu=FLAGS.tpu, cluster_config=FLAGS.cluster_config
          )
          with strategy.scope():
              model = models.get_model()
              trainer = trainers.get_trainer_class()(model, strategy)
  
          train_util.train(
              data_provider=gin.REQUIRED,
              trainer=trainer,
              save_dir=save_dir,
              restore_dir=restore_dir,
              early_stop_loss_value=FLAGS.early_stop_loss_value,
              report_loss_to_hypertune=FLAGS.hypertune,
          )
  
      # Evaluation.
      elif FLAGS.mode == "eval":
          model = models.get_model()
          delay_start()
          eval_util.evaluate(
              data_provider=gin.REQUIRED,
              model=model,
              save_dir=save_dir,
              restore_dir=restore_dir,
              run_once=FLAGS.run_once,
          )
  
      # Sampling.
      elif FLAGS.mode == "sample":
          model = models.get_model()
          delay_start()
          eval_util.sample(
              data_provider=gin.REQUIRED,
              model=model,
              save_dir=save_dir,
              restore_dir=restore_dir,
              run_once=FLAGS.run_once,
          )
  
file_path: ddsp/ddsp/training/ddsp_run.py
imports: import os
  import time
  from absl import app
  from absl import flags
  from absl import logging
  from ddsp.training import cloud
  from ddsp.training import eval_util
  from ddsp.training import models
  from ddsp.training import train_util
  from ddsp.training import trainers
  import gin
  import pkg_resources
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: main(unused_argv) without return types