keras/src/metrics/iou_metrics.py/_IoUBase/__init__
class _IoUBase:    def __init__(
        self,
        num_classes,
        name=None,
        dtype=None,
        ignore_class=None,
        sparse_y_true=True,
        sparse_y_pred=True,
        axis=-1,
    ):
        # defaulting to float32 to avoid issues with confusion matrix
        super().__init__(name=name, dtype=dtype or "float32")
        # Metric should be maximized during optimization.
        self._direction = "up"
        self.num_classes = num_classes
        self.ignore_class = ignore_class
        self.sparse_y_true = sparse_y_true
        self.sparse_y_pred = sparse_y_pred
        self.axis = axis

        self.total_cm = self.add_variable(
            name="total_confusion_matrix",
            shape=(num_classes, num_classes),
            initializer=initializers.Zeros(),
        )