def on_test_end(self, trainer: Trainer, pl_module: AnomalibModule) -> None:
        """Generate visualizations at the end of testing.

        Args:
            trainer (Trainer): PyTorch Lightning trainer instance.
            pl_module (AnomalibModule): The module that was tested.

        Example:
            Generate visualizations at the end of testing::

                >>> from anomalib.utils.visualization import MetricsVisualizer
                >>> callback = _VisualizationCallback(
                ...     visualizers=MetricsVisualizer(),
                ...     save=True,
                ...     root="results/metrics"
                ... )
                >>> callback.on_test_end(trainer, model)

        Raises:
            ValueError: If ``save`` is ``True`` but ``file_name`` is ``None``.
        """
        for generator in self.generators:
            if generator.visualize_on == VisualizationStep.STAGE_END:
                for result in generator(trainer=trainer, pl_module=pl_module):
                    if self.save:
                        if result.file_name is None:
                            msg = "``save`` is set to ``True`` but file name is ``None``"
                            raise ValueError(msg)
                        save_image(image=result.image, root=self.root, filename=result.file_name)
                    if self.show:
                        show_image(image=result.image, title=str(result.file_name))
                    if self.log:
                        self._add_to_logger(result, pl_module, trainer)

        for logger in trainer.loggers:
            if isinstance(logger, AnomalibWandbLogger):
                logger.save()
Generate visualizations at the end of testing.

        Args:
            trainer (Trainer): PyTorch Lightning trainer instance.
            pl_module (AnomalibModule): The module that was tested.

        Example:
            Generate visualizations at the end of testing::

                >>> from anomalib.utils.visualization import MetricsVisualizer
                >>> callback = _VisualizationCallback(
                ...     visualizers=MetricsVisualizer(),
                ...     save=True,
                ...     root="results/metrics"
                ... )
                >>> callback.on_test_end(trainer, model)

        Raises:
            ValueError: If ``save`` is ``True`` but ``file_name`` is ``None``.
        
src/anomalib/callbacks/visualizer.py