code: def update_data_root(cfg, logger=None):
      """Update data root according to env MMDET_DATASETS.
  
      If set env MMDET_DATASETS, update cfg.data_root according to
      MMDET_DATASETS. Otherwise, using cfg.data_root as default.
  
      Args:
          cfg (:obj:`Config`): The model config need to modify
          logger (logging.Logger | str | None): the way to print msg
      """
      assert isinstance(
          cfg, Config
      ), f"cfg got wrong type: {type(cfg)}, expected mmengine.Config"
  
      if "MMDET_DATASETS" in os.environ:
          dst_root = os.environ["MMDET_DATASETS"]
          print_log(
              f"MMDET_DATASETS has been set to be {dst_root}."
              f"Using {dst_root} as data root."
          )
      else:
          return
  
      assert isinstance(
          cfg, Config
      ), f"cfg got wrong type: {type(cfg)}, expected mmengine.Config"
  
      def update(cfg, src_str, dst_str):
          for k, v in cfg.items():
              if isinstance(v, ConfigDict):
                  update(cfg[k], src_str, dst_str)
              if isinstance(v, str) and src_str in v:
                  cfg[k] = v.replace(src_str, dst_str)
  
      update(cfg.data, cfg.data_root, dst_root)
      cfg.data_root = dst_root
  
file_path: mmdetection/mmdet/utils/misc.py
imports: import glob
  import os
  import os.path
  import urllib
  import warnings
  from typing import Union
  import torch
  from mmengine.config import Config, ConfigDict
  from mmengine.logging import print_log
  from mmengine.utils import scandir
label_desc: Use image node_id 2 for calling a global function with example usage: update_data_root(cfg, logger) without return types