code: def test_import_pytorch_lightning_with_torch_dist_unavailable():
      """Test that the package can be imported regardless of whether torch.distributed is available."""
      code = dedent(
          """
          import torch
  
          # pretend torch.distributed not available
          for name in list(torch.distributed.__dict__.keys()):
              if not name.startswith("__"):
                  delattr(torch.distributed, name)
  
          torch.distributed.is_available = lambda: False
  
          import lightning.pytorch
          """
      )
      # run in complete isolation
      assert subprocess.call([sys.executable, "-c", code]) == 0
  
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 5 for calling a global function with example usage: test_import_pytorch_lightning_with_torch_dist_unavailable() without return types