code: def _compute_precision_recall(input_, labels, threshold,
                                per_example_weights):
    
  
    # To apply per_example_weights, we need to collapse each row to a scalar, but
    # we really want the sum.
    labels.get_shape().assert_is_compatible_with(input_.get_shape())
    relevant = tf.to_float(tf.greater(labels, 0))
    retrieved = tf.to_float(tf.greater(input_, threshold))
    selected = relevant * retrieved
  
    if per_example_weights is not None:
      per_example_weights = _convert_and_assert_per_example_weights_compatible(
          input_,
          per_example_weights,
          dtype=None)
      per_example_weights = tf.to_float(tf.greater(per_example_weights, 0))
      selected = functions.reduce_batch_sum(selected) * per_example_weights
      relevant = functions.reduce_batch_sum(relevant) * per_example_weights
      retrieved = functions.reduce_batch_sum(retrieved) * per_example_weights
    sum_relevant = tf.reduce_sum(relevant)
    sum_retrieved = tf.reduce_sum(retrieved)
    selected = tf.reduce_sum(selected)
    return selected, sum_retrieved, sum_relevant
docs: Returns the numerator of both, the denominator of precision and recall.