code: def update_multi_gpu_training_config(
      config: DictConfig | ListConfig,
  ) -> DictConfig | ListConfig:
      """Updates the config to change learning rate based on number of gpus assigned.
  
      Current behaviour is to ensure only ddp accelerator is used.
  
      Args:
          config (DictConfig | ListConfig): Configurable parameters for the current run
  
      Raises:
          ValueError: If unsupported accelerator is passed
  
      Returns:
          DictConfig | ListConfig: Updated config
      """
      # validate accelerator
      if config.trainer.accelerator is not None:
          if config.trainer.accelerator.lower() != "ddp":
              if config.trainer.accelerator.lower() in (
                  "dp",
                  "ddp_spawn",
                  "ddp2",
              ):
                  warn(
                      f"Using accelerator {config.trainer.accelerator.lower()} is discouraged. "
                      f"Please use one of [null, ddp]. Setting accelerator to ddp"
                  )
                  config.trainer.accelerator = "ddp"
              else:
                  raise ValueError(
                      f"Unsupported accelerator found: {config.trainer.accelerator}. Should be one of [null, ddp]"
                  )
      # Increase learning rate
      # since pytorch averages the gradient over devices, the idea is to
      # increase the learning rate by the number of devices
      if "lr" in config.model:
          # Number of GPUs can either be passed as gpus: 2 or gpus: [0,1]
          n_gpus: int | list = 1
          if "trainer" in config and "gpus" in config.trainer:
              n_gpus = config.trainer.gpus
          lr_scaler = n_gpus if isinstance(n_gpus, int) else len(n_gpus)
          config.model.lr = config.model.lr * lr_scaler
      return config
  
file_path: anomalib/src/anomalib/config/config.py
imports: from __future__ import annotations
  import time
  import warnings
  from datetime import datetime
  from pathlib import Path
  from warnings import warn
  from omegaconf import DictConfig, ListConfig, OmegaConf
  from anomalib.data.utils import TestSplitMode, ValSplitMode
label_desc: Use image node_id 4 for calling a global function with example usage: update_multi_gpu_training_config(config) and returns: config