code: def _calc_f1(tp: float, fp: float, fn: float) -> float:
      """Calculate F1 for given matches and number of positives."""
      if tp + fn == 0:
          return -1
      if tp + fp == 0:
          return 0
      rc = tp / (tp + fn + np.finfo(float).eps)
      pr = tp / (tp + fp + np.finfo(float).eps)
      f1 = (2 * rc * pr) / (rc + pr + np.finfo(float).eps)
      return f1
  
imports: import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: _calc_f1(tp, fp, fn) and returns: f1, unknown, int