class_docstr: Base object for computing metrics on generated audio samples.
class_docstr_tok: ["Base","object","for","computing","metrics","on","generated","audio","samples","."]
docstr: Add summaries for each metric and reset the state.
docstr_tok: ["Add","summaries","for","each","metric","and","reset","the","state","."]
code: def flush(self, step):
      """Add summaries for each metric and reset the state."""
      # Log metrics
      logging.info(
          "Computing %s metrics complete. Flushing all metrics",
          self._name,
      )
      metrics_str = " | ".join(
          "{}: {:0.3f}".format(k, v.result())
          for k, v in self.metrics.items()
      )
      logging.info(metrics_str)
  
      # Write tf summaries.
      for metric_name, metric in self.metrics.items():
          tf.summary.scalar(
              "metrics/{}/{}".format(self._name, metric_name),
              metric.result(),
              step,
          )
          metric.reset_states()
  
imports: import dataclasses
  from absl import logging
  import ddsp
  import librosa
  import mir_eval
  import note_seq
  from note_seq import sequences_lib
  import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 4 for calling the BaseMetrics obj's underlying member method code with example usage: obj.flush(step) without return types