code: def f1_score(precision, recall):
      """Creates an op for calculating the F1 score.
  
      Args:
        precision: A tensor representing precision.
        recall: A tensor representing recall.
  
      Returns:
        A tensor with the result of the F1 calculation.
      """
      return tf.where(
          tf.greater(precision + recall, 0),
          2 * ((precision * recall) / (precision + recall)),
          0,
      )
  
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 1 for calling a global function with example usage: f1_score(precision, recall) and returns: tf