def compute(self, force: bool | None = None) -> tuple[PIMOResult, AUPIMOResult]:  # type: ignore[override]
        """Compute PIMO curves and AUPIMO scores.

        Args:
            force: If provided, override instance ``force`` setting

        Returns:
            tuple: Contains:
                - PIMOResult: PIMO curve data
                - AUPIMOResult: AUPIMO score data

        Raises:
            RuntimeError: If no data has been added via update()
        """
        if self._is_empty:
            msg = "No anomaly maps and masks have been added yet. Please call `update()` first."
            raise RuntimeError(msg)
        anomaly_maps = torch.concat(self.anomaly_maps, dim=0)
        masks = torch.concat(self.masks, dim=0)
        force = force if force is not None else self.force

        # other validations are done in the numpy code

        thresholds, shared_fpr, per_image_tprs, _, aupimos, num_thresholds_auc = functional.aupimo_scores(
            anomaly_maps,
            masks,
            self.num_thresholds,
            fpr_bounds=self.fpr_bounds,
            force=force,
        )

        pimo_result = PIMOResult(
            thresholds=thresholds,
            shared_fpr=shared_fpr,
            per_image_tprs=per_image_tprs,
        )
        aupimo_result = AUPIMOResult.from_pimo_result(
            pimo_result,
            fpr_bounds=self.fpr_bounds,
            # not `num_thresholds`!
            # `num_thresholds` is the number of thresholds used to compute the PIMO curve
            # this is the number of thresholds used to compute the AUPIMO integral
            num_thresholds_auc=num_thresholds_auc,
            aupimos=aupimos,
        )
        if self.return_average:
            # normal images have NaN AUPIMO scores
            is_nan = torch.isnan(aupimo_result.aupimos)
            return aupimo_result.aupimos[~is_nan].mean()
        return pimo_result, aupimo_result
Compute PIMO curves and AUPIMO scores.

        Args:
            force: If provided, override instance ``force`` setting

        Returns:
            tuple: Contains:
                - PIMOResult: PIMO curve data
                - AUPIMOResult: AUPIMO score data

        Raises:
            RuntimeError: If no data has been added via update()
        
src/anomalib/metrics/pimo/pimo.py