class_docstr: Registers legacy artifacts (classes, methods, etc.) that were removed but still need to be included for
  unpickling old checkpoints. The following patches apply.
  
      1. ``lightning.pytorch.utilities.argparse._gpus_arg_default``: Applies to all checkpoints saved prior to
         version 1.2.8. See: https://github.com/Lightning-AI/lightning/pull/6898
      2. ``lightning.pytorch.utilities.argparse_utils``: A module that was deprecated in 1.2 and removed in 1.4,
         but still needs to be available for import for legacy checkpoints.
      3. ``lightning.pytorch.utilities.enums._FaultTolerantMode``: This enum was removed in 2.0 but was pickled
         into older checkpoints.
      4. In legacy versions of Lightning, callback classes got pickled into the checkpoint. These classes have a
         module import path under ``pytorch_lightning`` and must be redirected to the ``lightning.pytorch``.
  
  Example:
  
      with pl_legacy_patch():
          torch.load("path/to/legacy/checkpoint.ckpt")
code: def __enter__(self) -> "pl_legacy_patch":
      _lock.acquire()
      # `pl.utilities.argparse_utils` was renamed to `pl.utilities.argparse`
      legacy_argparse_module = ModuleType(
          "lightning.pytorch.utilities.argparse_utils"
      )
      sys.modules[
          "lightning.pytorch.utilities.argparse_utils"
      ] = legacy_argparse_module
  
      # `_gpus_arg_default` used to be imported from these locations
      legacy_argparse_module._gpus_arg_default = lambda x: x
      pl.utilities.argparse._gpus_arg_default = lambda x: x
  
      # `_FaultTolerantMode` was removed from the enums
      class _FaultTolerantMode(LightningEnum):
          DISABLED = "disabled"
          AUTOMATIC = "automatic"
          MANUAL = "manual"
  
      pl.utilities.enums._FaultTolerantMode = _FaultTolerantMode
  
      # Patch Unpickler to redirect `pytorch_lightning` imports
      self._old_unpickler = pickle.Unpickler
      pickle.Unpickler = _RedirectingUnpickler  # type: ignore
      return self
  
imports: import logging
  import os
  import pickle
  import sys
  import threading
  import warnings
  from types import ModuleType, TracebackType
  from typing import Any, Dict, List, Optional, Tuple, Type
  from packaging.version import Version
  import lightning.pytorch
  from lightning.fabric.utilities.enums import LightningEnum
  from lightning.fabric.utilities.imports import _IS_WINDOWS
  from lightning.fabric.utilities.types import _PATH
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch.utilities.migration.migration import _migration_index
  from lightning.pytorch.utilities.rank_zero import rank_zero_warn
label_desc: Use image node_id 1 for calling the pl_legacy_patch obj's underlying member method code with example usage: obj.__enter__() and returns: self