def update_state(self, y_true, y_pred, sample_weight=None):
        """Accumulates the confusion matrix statistics.

        Before the confusion matrix is updated, the predicted values are
        thresholded to be:
            0 for values that are smaller than the `threshold`
            1 for values that are larger or equal to the `threshold`

        Args:
            y_true: The ground truth values.
            y_pred: The predicted values.
            sample_weight: Optional weighting of each example. Can
                be a `Tensor` whose rank is either 0, or the same as `y_true`,
                and must be broadcastable to `y_true`. Defaults to `1`.

        Returns:
            Update op.
        """
        y_true = ops.convert_to_tensor(y_true, dtype=self.dtype)
        # convert y_pred on float 32 and cast just after to dtype
        y_pred = ops.convert_to_tensor(y_pred, dtype="float32")
        y_pred = ops.cast(y_pred >= self.threshold, self.dtype)
        return super().update_state(y_true, y_pred, sample_weight)
Accumulates the confusion matrix statistics.

        Before the confusion matrix is updated, the predicted values are
        thresholded to be:
            0 for values that are smaller than the `threshold`
            1 for values that are larger or equal to the `threshold`

        Args:
            y_true: The ground truth values.
            y_pred: The predicted values.
            sample_weight: Optional weighting of each example. Can
                be a `Tensor` whose rank is either 0, or the same as `y_true`,
                and must be broadcastable to `y_true`. Defaults to `1`.

        Returns:
            Update op.
        
keras/src/metrics/iou_metrics.py