code: def rename_substrings_recursively(
      mapping: Mapping[str, str],
      root_dir: Union[str, Path],
      dry_run=False,
  ):
      assert os.path.isdir(root_dir)
  
      for filename in glob.iglob(
          str(root_dir).rstrip("/") + "/**/*.py", recursive=True
      ):
          with open(filename, "r") as fpy:
              edit_count, edited_lines = rename_imports(mapping, fpy)
          stat = f"processed {edit_count} lines for: {filename}"
          if dry_run:
              print(stat)
              continue
          if edit_count > 0:
              print(stat)
              with open(filename, "w") as fpy:
                  fpy.writelines(edited_lines)
  
imports: import glob
  import os
  from pathlib import Path
  from typing import Mapping, Iterable, List, Tuple, Union
  from fedot.core.utils import fedot_project_root
label_desc: Use image node_id 2 for calling a global function with example usage: rename_substrings_recursively(mapping, root_dir, dry_run) without return types