class_docstr: A Matrices object wraps a Dict[float, Dict[MatrixEntryKey, float]].
  
  A specific confusion matrix entry can be accessed for a threshold,
  actual_class and predicted_class with
  
      instance[threshold][MatrixEntryKey(actual_class_id, predicted_class_id)]
class_docstr_tok: ["A","Matrices","object","wraps","a","Dict","[","float",",","Dict","[","MatrixEntryKey",",","float","]","]",".","A","specific","confusion","matrix","entry","can","be","accessed","for","a","threshold",",","actual_class","and","predicted_class","with","instance","[","threshold","]","[","MatrixEntryKey","(","actual_class_id",",","predicted_class_id",")","]"]
code: def to_proto(self) -> metrics_for_slice_pb2.MetricValue:
      result = metrics_for_slice_pb2.MetricValue()
      multi_class_confusion_matrices_at_thresholds_proto = (
          result.multi_class_confusion_matrix_at_thresholds
      )
      for threshold in sorted(self):
          # Convert -epsilon and 1.0+epsilon back to 0.0 and 1.0.
          if threshold == -_EPSILON:
              t = 0.0
          elif threshold == 1.0 + _EPSILON:
              t = 1.0
          else:
              t = threshold
          matrix = multi_class_confusion_matrices_at_thresholds_proto.matrices.add(
              threshold=t
          )
          for k in sorted(self[threshold]):
              matrix.entries.add(
                  actual_class_id=k.actual_class_id,
                  predicted_class_id=k.predicted_class_id,
                  num_weighted_examples=self[threshold][k],
              )
      return result
  
imports: from typing import Any, Callable, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple
  import apache_beam
  import numpy
  from tensorflow_model_analysis.api import types
  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