code: def add_visualizer_callback(
      callbacks: list[Callback], config: DictConfig | ListConfig
  ) -> None:
      """Configure the visualizer callback based on the config and add it to the list of callbacks.
  
      Args:
          callbacks (list[Callback]): Current list of callbacks.
          config (DictConfig | ListConfig): The config object.
      """
      # visualization settings
      assert isinstance(config, (DictConfig, Namespace))
      # TODO remove this when version is upgraded to 0.4.0
      if isinstance(config, DictConfig):
          if (
              "log_images_to" in config.project.keys()
              and len(config.project.log_images_to) > 0
              or "log_images_to" in config.logging.keys()
              and len(config.logging.log_images_to) > 0
          ):
              warnings.warn(
                  "log_images_to parameter is deprecated and will be removed in version 0.4.0 Please use "
                  "the visualization.log_images and visualization.save_images parameters instead."
              )
              if "visualization" not in config.keys():
                  config["visualization"] = dict(
                      log_images=False,
                      save_images=False,
                      show_image=False,
                      image_save_path=None,
                  )
              if "local" in config.project.log_images_to:
                  config.visualization["save_images"] = True
              if (
                  "local" not in config.project.log_images_to
                  or len(config.project.log_images_to) > 1
              ):
                  config.visualization["log_images"] = True
          config.visualization.task = config.dataset.task
          config.visualization.inputs_are_normalized = (
              not config.model.normalization_method == "none"
          )
      else:
          config.visualization.task = config.data.init_args.task
          config.visualization.inputs_are_normalized = (
              not config.post_processing.normalization_method == "none"
          )
  
      if (
          config.visualization.log_images
          or config.visualization.save_images
          or config.visualization.show_images
      ):
          image_save_path = (
              config.visualization.image_save_path
              or config.project.path + "/images"
          )
          for callback in (
              ImageVisualizerCallback,
              MetricVisualizerCallback,
          ):
              callbacks.append(
                  callback(
                      task=config.visualization.task,
                      mode=config.visualization.mode,
                      image_save_path=image_save_path,
                      inputs_are_normalized=config.visualization.inputs_are_normalized,
                      show_images=config.visualization.show_images,
                      log_images=config.visualization.log_images,
                      save_images=config.visualization.save_images,
                  )
              )
  
imports: from __future__ import annotations
  import logging
  import os
  import warnings
  from importlib import import_module
  import yaml
  from jsonargparse.namespace import Namespace
  from omegaconf import DictConfig, ListConfig, OmegaConf
  from pytorch_lightning.callbacks import Callback, ModelCheckpoint
  from anomalib.deploy import ExportMode
  from .cdf_normalization import CdfNormalizationCallback
  from .graph import GraphLogger
  from .metrics_configuration import MetricsConfigurationCallback
  from .min_max_normalization import MinMaxNormalizationCallback
  from .model_loader import LoadModelCallback
  from .post_processing_configuration import PostProcessingConfigurationCallback
  from .tiler_configuration import TilerConfigurationCallback
  from .timer import TimerCallback
  from .visualizer import ImageVisualizerCallback, MetricVisualizerCallback
label_desc: Use image node_id 2 for calling a global function with example usage: add_visualizer_callback(callbacks, config) without return types