code: def _patch_lightning_io():
      if PatchPyTorchModelIO.__patched_lightning:
          return
  
      if "lightning" not in sys.modules:
          return
  
      PatchPyTorchModelIO.__patched_lightning = True
  
      # noinspection PyBroadException
      try:
          import lightning  # noqa
  
          lightning.pytorch.trainer.Trainer.save_checkpoint = (
              _patched_call(
                  lightning.pytorch.trainer.Trainer.save_checkpoint,
                  PatchPyTorchModelIO._save,
              )
          )  # noqa
  
          lightning.pytorch.trainer.Trainer.restore = _patched_call(
              lightning.pytorch.trainer.Trainer.restore,
              PatchPyTorchModelIO._load_from_obj,
          )  # noqa
      except ImportError:
          pass
      except Exception:
          pass
  
      # noinspection PyBroadException
      try:
          import lightning  # noqa
  
          # noinspection PyUnresolvedReferences
          lightning.pytorch.trainer.connectors.checkpoint_connector.CheckpointConnector.save_checkpoint = _patched_call(
              lightning.pytorch.trainer.connectors.checkpoint_connector.CheckpointConnector.save_checkpoint,
              PatchPyTorchModelIO._save,
          )  # noqa
  
          # noinspection PyUnresolvedReferences
          lightning.pytorch.trainer.connectors.checkpoint_connector.CheckpointConnector.restore = _patched_call(
              lightning.pytorch.trainer.connectors.checkpoint_connector.CheckpointConnector.restore,
              PatchPyTorchModelIO._load_from_obj,
          )  # noqa
      except ImportError:
          pass
      except Exception:
          pass
  
imports: import sys
  import six
  import threading
  from pathlib2 import Path
  from ...binding.frameworks.base_bind import PatchBaseModelIO
  from ..frameworks import _patched_call, _patched_call_no_recursion_guard, WeightsFileHandler, _Empty
  from ..import_bind import PostImportHookPatching
  from ...config import running_remotely
  from ...model import Framework
label_desc: Use image node_id 5 for calling the PatchPyTorchModelIO obj's underlying member method code with example usage: obj._patch_lightning_io() without return types