code: def define_metrics(
      frame_probs,
      onset_probs,
      frame_predictions,
      onset_predictions,
      offset_predictions,
      velocity_values,
      length,
      sequence_label,
      frame_labels,
      sequence_id,
      hparams,
      min_pitch=constants.MIN_MIDI_PITCH,
      max_pitch=constants.MAX_MIDI_PITCH,
      prefix="",
      onsets_only=False,
      pitch_map=None,
  ):
      """Create a metric name to tf.metric pair dict for transcription metrics."""
      with tf.device("/device:CPU:*"):
          metrics = collections.defaultdict(list)
          for i in range(hparams.eval_batch_size):
              for k, v in calculate_metrics(
                  frame_probs=frame_probs[i][: length[i]],
                  onset_probs=onset_probs[i][: length[i]],
                  frame_predictions=frame_predictions[i][: length[i]],
                  onset_predictions=onset_predictions[i][: length[i]],
                  offset_predictions=offset_predictions[i][: length[i]],
                  velocity_values=velocity_values[i][: length[i]],
                  sequence_label=sequence_label[i],
                  frame_labels=frame_labels[i][: length[i]],
                  sequence_id=sequence_id[i],
                  hparams=hparams,
                  min_pitch=min_pitch,
                  max_pitch=max_pitch,
                  onsets_only=onsets_only,
                  pitch_map=pitch_map,
              ).items():
                  metrics[k].append(v)
          return {
              "metrics/" + prefix + k: v for k, v in metrics.items()
          }
  
file_path: magenta/magenta/models/onsets_frames_transcription/metrics.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import functools
  from magenta.models.onsets_frames_transcription import constants
  from magenta.models.onsets_frames_transcription import data
  from magenta.models.onsets_frames_transcription import infer_util
  import mir_eval
  from note_seq import sequences_lib
  from note_seq.protobuf import music_pb2
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling a global function with example usage: define_metrics(frame_probs, onset_probs, frame_predictions, onset_predictions, offset_predictions, velocity_values, length, sequence_label, frame_labels, sequence_id, hparams, min_pitch, max_pitch, prefix, onsets_only, pitch_map) and returns: unknown