def _add_to_logger(
        result: GeneratorResult,
        module: AnomalibModule,
        trainer: Trainer,
    ) -> None:
        """Add visualization to logger.

        Args:
            result (GeneratorResult): Output from the visualization generators.
            module (AnomalibModule): LightningModule from which the global step is extracted.
            trainer (Trainer): Trainer object containing the loggers.

        Example:
            Add visualization to logger::

                >>> result = generator.generate(...)  # Generate visualization
                >>> _VisualizationCallback._add_to_logger(result, model, trainer)

        Raises:
            ValueError: If ``file_name`` is ``None`` when attempting to log.
        """
        # Store names of logger and the logger in a dict
        available_loggers = {
            type(logger).__name__.lower().replace("logger", "").replace("anomalib", ""): logger
            for logger in trainer.loggers
        }
        # save image to respective logger
        if result.file_name is None:
            msg = "File name is None"
            raise ValueError(msg)
        filename = result.file_name
        image = result.image
        for log_to in available_loggers:
            # check if logger object is same as the requested object
            if isinstance(available_loggers[log_to], ImageLoggerBase):
                logger: ImageLoggerBase = cast(ImageLoggerBase, available_loggers[log_to])  # placate mypy
                _name = filename.parent.name + "_" + filename.name if isinstance(filename, Path) else filename
                logger.add_image(
                    image=image,
                    name=_name,
                    global_step=module.global_step,
                )
Add visualization to logger.

        Args:
            result (GeneratorResult): Output from the visualization generators.
            module (AnomalibModule): LightningModule from which the global step is extracted.
            trainer (Trainer): Trainer object containing the loggers.

        Example:
            Add visualization to logger::

                >>> result = generator.generate(...)  # Generate visualization
                >>> _VisualizationCallback._add_to_logger(result, model, trainer)

        Raises:
            ValueError: If ``file_name`` is ``None`` when attempting to log.
        
src/anomalib/callbacks/visualizer.py