code: def predict_sequence(
      frame_probs,
      onset_probs,
      frame_predictions,
      onset_predictions,
      offset_predictions,
      velocity_values,
      min_pitch,
      hparams,
      onsets_only=False,
  ):
      """Predict sequence given model output."""
      if not hparams.predict_onset_threshold:
          onset_predictions = None
      if not hparams.predict_offset_threshold:
          offset_predictions = None
  
      if onsets_only:
          if onset_predictions is None:
              raise ValueError(
                  "Cannot do onset only prediction if onsets are not defined."
              )
          sequence_prediction = (
              sequences_lib.pianoroll_onsets_to_note_sequence(
                  onsets=onset_predictions,
                  frames_per_second=data.hparams_frames_per_second(
                      hparams
                  ),
                  note_duration_seconds=0.05,
                  min_midi_pitch=min_pitch,
                  velocity_values=velocity_values,
                  velocity_scale=hparams.velocity_scale,
                  velocity_bias=hparams.velocity_bias,
              )
          )
      else:
          if hparams.viterbi_decoding:
              pianoroll = probs_to_pianoroll_viterbi(
                  frame_probs, onset_probs, alpha=hparams.viterbi_alpha
              )
              onsets = np.concatenate(
                  [
                      pianoroll[:1, :],
                      pianoroll[1:, :] & ~pianoroll[:-1, :],
                  ],
                  axis=0,
              )
              sequence_prediction = (
                  sequences_lib.pianoroll_to_note_sequence(
                      frames=pianoroll,
                      frames_per_second=data.hparams_frames_per_second(
                          hparams
                      ),
                      min_duration_ms=0,
                      min_midi_pitch=min_pitch,
                      onset_predictions=onsets,
                      velocity_values=velocity_values,
                      velocity_scale=hparams.velocity_scale,
                      velocity_bias=hparams.velocity_bias,
                  )
              )
          else:
              sequence_prediction = (
                  sequences_lib.pianoroll_to_note_sequence(
                      frames=frame_predictions,
                      frames_per_second=data.hparams_frames_per_second(
                          hparams
                      ),
                      min_duration_ms=0,
                      min_midi_pitch=min_pitch,
                      onset_predictions=onset_predictions,
                      offset_predictions=offset_predictions,
                      velocity_values=velocity_values,
                      velocity_scale=hparams.velocity_scale,
                      velocity_bias=hparams.velocity_bias,
                  )
              )
  
      return sequence_prediction
  
file_path: magenta/magenta/models/onsets_frames_transcription/infer_util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from magenta.models.onsets_frames_transcription import data
  from note_seq import sequences_lib
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: predict_sequence(frame_probs, onset_probs, frame_predictions, onset_predictions, offset_predictions, velocity_values, min_pitch, hparams, onsets_only) and returns: sequence_prediction