def update(self, outputs: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:
        """Updates segmentation statistics with new data
        and return intermediate metrics values.

        Args:
            outputs: tensor of logits
            targets: tensor of targets

        Returns:
            metric for each class
        """
        tp, fp, fn = get_segmentation_statistics(
            outputs=outputs.cpu().detach(),
            targets=targets.cpu().detach(),
            class_dim=self.class_dim,
            threshold=self.threshold,
        )

        for idx, (tp_class, fp_class, fn_class) in enumerate(zip(tp, fp, fn)):
            if idx in self.statistics:
                self.statistics[idx]["tp"] += tp_class
                self.statistics[idx]["fp"] += fp_class
                self.statistics[idx]["fn"] += fn_class
            else:
                self.statistics[idx] = {}
                self.statistics[idx]["tp"] = tp_class
                self.statistics[idx]["fp"] = fp_class
                self.statistics[idx]["fn"] = fn_class

        # need only one time
        if not self._checked_params:
            self._check_parameters()
            self._checked_params = True

        metrics_per_class = self.metric_fn(tp, fp, fn)
        return metrics_per_class
Updates segmentation statistics with new data
        and return intermediate metrics values.

        Args:
            outputs: tensor of logits
            targets: tensor of targets

        Returns:
            metric for each class
        
catalyst/metrics/_segmentation.py