def compute(self) -> torch.Tensor:
        """Compute the macro average PRO score across all regions.

        Returns:
            torch.Tensor: Scalar tensor containing the PRO score averaged across
                all regions in all batches

        Example:
            >>> pro = PRO()
            >>> # After updating with several batches
            >>> score = pro.compute()
            >>> print(f"PRO Score: {score:.4f}")
        """
        target = dim_zero_cat(self.target)
        preds = dim_zero_cat(self.preds)

        # kornia expects N1HW format and float dtype
        target = target.unsqueeze(1).type(torch.float)
        comps = connected_components_gpu(target) if target.is_cuda else connected_components_cpu(target)
        return pro_score(preds, comps, threshold=self.threshold)
Compute the macro average PRO score across all regions.

        Returns:
            torch.Tensor: Scalar tensor containing the PRO score averaged across
                all regions in all batches

        Example:
            >>> pro = PRO()
            >>> # After updating with several batches
            >>> score = pro.compute()
            >>> print(f"PRO Score: {score:.4f}")
        
src/anomalib/metrics/pro.py