class_docstr: A helper class to compute metrics for MIDI output.
class_docstr_tok: ["A","helper","class","to","compute","metrics","for","MIDI","output","."]
docstr: If the input is not a piano roll, convert it, else return it as is.
docstr_tok: ["If","the","input","is","not","a","piano","roll",",","convert","it",",","else","return","it","as","is","."]
code: def _safe_convert_to_pianoroll(self, representation):
      """If the input is not a piano roll, convert it, else return it as is."""
      pr_types = [sequences_lib.Pianoroll, np.ndarray, tf.Tensor]
      if any(isinstance(representation, t) for t in pr_types):
          return representation
      else:
          return sequences_lib.sequence_to_pianoroll(
              representation,
              frames_per_second=self._frames_per_second,
              min_pitch=note_seq.MIN_MIDI_PITCH,
              max_pitch=note_seq.MAX_MIDI_PITCH,
          ).active
  
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 3 for calling the MidiMetrics obj's underlying member method code with example usage: obj._safe_convert_to_pianoroll(representation) and returns: representation, sequences_lib