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: Per-Replica training step.
docstr_tok: ["Per-Replica","training","step","."]
code: def step_fn(self, batch):
      """Per-Replica training step."""
      with tf.GradientTape() as tape:
          _, losses = self.model(
              batch, return_losses=True, training=True
          )
      # Clip and apply gradients.
      grads = tape.gradient(
          losses["total_loss"], self.model.trainable_variables
      )
      grads, _ = tf.clip_by_global_norm(grads, self.grad_clip_norm)
      self.optimizer.apply_gradients(
          zip(grads, self.model.trainable_variables)
      )
      return losses
  
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 11 for calling the Trainer obj's underlying member method code with example usage: obj.step_fn(batch) and returns: losses