class_docstr: Class to bind an optimizer, model, strategy, and training step function.
class_docstr_tok: ["Class","to","bind","an","optimizer",",","model",",","strategy",",","and","training","step","function","."]
docstr: Saves model and optimizer to a checkpoint.
docstr_tok: ["Saves","model","and","optimizer","to","a","checkpoint","."]
code: def save(self, save_dir):
      """Saves model and optimizer to a checkpoint."""
      # Saving weights in checkpoint format because saved_model requires
      # handling variable batch size, which some synths and effects can't.
      start_time = time.time()
      checkpoint = self.get_checkpoint()
      manager = tf.train.CheckpointManager(
          checkpoint,
          directory=save_dir,
          max_to_keep=self.checkpoints_to_keep,
      )
      step = self.step.numpy()
      manager.save(checkpoint_number=step)
      logging.info("Saved checkpoint to %s at step %s", save_dir, step)
      logging.info(
          "Saving model took %.1f seconds", time.time() - start_time
      )
  
file_path: ddsp/ddsp/training/trainers.py
imports: import time
  from absl import logging
  from ddsp.training import train_util
  import gin
  import tensorflow.compat.v2
label_desc: Use image node_id 3 for calling the Trainer obj's underlying member method code with example usage: obj.save(save_dir) without return types