code: def clean_import():
      """This fixture allows test to import {pytorch_}lightning* modules completely cleanly, regardless of the current
      state of the imported modules.
  
      Afterwards, it restores the original state of the modules.
  
      """
      import sys
  
      # copy modules to avoid modifying the original
      old_sys_modules = sys.modules
      # remove all *lightning* modules
      new_sys_modules = {
          key: value
          for key, value in sys.modules.items()
          if "lightning" not in key
      }
      sys.modules = (
          new_sys_modules  # replace sys.modules with the new one
      )
      yield
      sys.modules = old_sys_modules
  
file_path: pytorch-lightning/tests/tests_pytorch/utilities/test_imports.py
imports: import importlib
  import subprocess
  import sys
  from textwrap import dedent
  from unittest import mock
  import pytest
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from lightning_utilities.core.imports import RequirementCache
  from torch.distributed import is_available
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 3 for calling a global function with example usage: clean_import() without return types