class_docstr: A class representing a set of binary confusion matrices at thresholds.
  
  For each threshold, in addition to the count of examples per prediction and
  label, this class also contains a sample of raw examples. Threshold values are
  sorted, and the entries within  tp[i], tn[i], fp[i], and fn[i] correspond to
  thresholds[i].
class_docstr_tok: ["A","class","representing","a","set","of","binary","confusion","matrices","at","thresholds",".","For","each","threshold",",","in","addition","to","the","count","of","examples","per","prediction","and","label",",","this","class","also","contains","a","sample","of","raw","examples",".","Threshold","values","are","sorted",",","and","the","entries","within","tp","[","i","]",",","tn","[","i","]",",","fp","[","i","]",",","and","fn","[","i","]","correspond","to","thresholds","[","i","]","."]
docstr: Converts matrices into ConfusionMatrixAtThresholds proto.
  
  If precision or recall are undefined then 1.0 and 0.0 will be used.
  
  Returns:
    A MetricValue proto containing a ConfusionMatrixAtThresholds proto.
docstr_tok: ["Converts","matrices","into","ConfusionMatrixAtThresholds","proto",".","If","precision","or","recall","are","undefined","then","1.0","and","0.0","will","be","used",".","Returns",":","A","MetricValue","proto","containing","a","ConfusionMatrixAtThresholds","proto","."]
code: def to_proto(self) -> metrics_for_slice_pb2.MetricValue:
      """Converts matrices into ConfusionMatrixAtThresholds proto.
  
      If precision or recall are undefined then 1.0 and 0.0 will be used.
  
      Returns:
        A MetricValue proto containing a ConfusionMatrixAtThresholds proto.
      """
  
      result = metrics_for_slice_pb2.MetricValue()
      tp, fp = np.array(self.tp), np.array(self.fp)
      tn, fn = np.array(self.tn), np.array(self.fn)
      predicted_positives, labeled_positives = tp + fp, tp + fn
      predicated_negatives, labeled_negatives = tn + fn, tn + fp
  
      precision = np.divide(
          tp,
          predicted_positives,
          out=np.ones_like(predicted_positives),
          where=(predicted_positives > 0),
      )
      recall = np.divide(
          tp,
          labeled_positives,
          out=np.zeros_like(labeled_positives),
          where=(labeled_positives > 0),
      )
      f1 = 2 * precision * recall / (precision + recall)
      accuracy = (tp + tn) / (tp + tn + fp + fn)
      false_positive_rate = fp / labeled_negatives
      false_omission_rate = fn / predicated_negatives
      confusion_matrix_at_thresholds_proto = (
          result.confusion_matrix_at_thresholds
      )
      for i, threshold in enumerate(self.thresholds):
          confusion_matrix_at_thresholds_proto.matrices.add(
              threshold=round(threshold, 6),
              true_positives=tp[i],
              false_positives=fp[i],
              true_negatives=tn[i],
              false_negatives=fn[i],
              precision=precision[i],
              recall=recall[i],
              false_positive_rate=false_positive_rate[i],
              false_omission_rate=false_omission_rate[i],
              f1=f1[i],
              accuracy=accuracy[i],
          )
      return result
  
imports: from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Tuple, Union
  import apache_beam
  import numpy
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.contrib.aggregates import binary_confusion_matrices
  from tensorflow_model_analysis.metrics import calibration_histogram
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
label_desc: Use image node_id 3 for calling the Matrices obj's underlying member method code with example usage: obj.to_proto() and returns: result