def metrics_to_cpu(self, metrics: Metric | list[Metric] | ModuleList) -> None:
        """Set the compute_on_cpu attribute of the metrics to True."""
        if isinstance(metrics, Metric):
            metrics.compute_on_cpu = True
        elif isinstance(metrics, (list | ModuleList)):
            for metric in metrics:
                self.metrics_to_cpu(metric)
        else:
            msg = f"metrics must be a Metric or a list of metrics, got {type(metrics)}"
            raise TypeError(msg)
Set the compute_on_cpu attribute of the metrics to True.
src/anomalib/metrics/evaluator.py