def run(self, task_id: int | None = None) -> dict:
        """Run a job that calculates image and pixel level metrics.

        Args:
            task_id: Not used in this case.

        Returns:
            dict[str, float]: Dictionary containing calculated metric values.
        """
        del task_id  # not needed here

        logger.info("Starting metrics calculation.")

        # add predicted data to metrics
        for data in tqdm(self.predictions, desc="Calculating metrics"):
            # on_test_batch_end updates test metrics
            self.evaluator.on_test_batch_end(None, None, None, batch=data, batch_idx=0)

        # compute all metrics on specified accelerator
        metrics_dict = {}
        for metric in self.evaluator.test_metrics:
            metric.to(self.accelerator)
            metrics_dict[metric.name] = metric.compute().item()
            metric.cpu()

        for name, value in metrics_dict.items():
            print(f"{name}: {value:.4f}")

        # save path used in `save` method
        metrics_dict["save_path"] = self.root_dir / "metric_results.csv"

        return metrics_dict
Run a job that calculates image and pixel level metrics.

        Args:
            task_id: Not used in this case.

        Returns:
            dict[str, float]: Dictionary containing calculated metric values.
        
src/anomalib/pipelines/tiled_ensemble/components/metrics_calculation.py