class_docstr: A helper class to compute metrics for MIDI output.
class_docstr_tok: ["A","helper","class","to","compute","metrics","for","MIDI","output","."]
docstr: Write summaries and reset state.
docstr_tok: ["Write","summaries","and","reset","state","."]
code: def flush(self, step):
      """Write summaries and reset state."""
  
      def write_summaries(counts, prefix):
          tf.summary.scalar(f"{prefix}/f1", counts.f1, step)
          tf.summary.scalar(
              f"{prefix}/precision", counts.precision, step
          )
          tf.summary.scalar(f"{prefix}/recall", counts.recall, step)
          metric_log = (
              f"{prefix}/f1: {counts.f1:0.3f} | "
              f"{prefix}/precision: {counts.precision:0.3f} | "
              f"{prefix}/recall: {counts.recall:0.3f}"
          )
          logging.info(metric_log)
  
      write_summaries(
          self.note_counts, f"metrics/midi/{self.tag}/onset"
      )
      write_summaries(
          self.note_offset_counts, f"metrics/midi/{self.tag}/full_note"
      )
      write_summaries(
          self.frame_counts, f"metrics/midi/{self.tag}/frame"
      )
  
      self.full_note_counts = EvalCounts(0, 0, 0)
      self.note_counts = EvalCounts(0, 0, 0)
      self.frame_counts = EvalCounts(0, 0, 0)
  
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 6 for calling the MidiMetrics obj's underlying member method code with example usage: obj.flush(step) without return types