code: def _patch_model_io():
      if PatchPyTorchModelIO.__patched:
          return
  
      if "torch" not in sys.modules:
          return
  
      PatchPyTorchModelIO.__patched = True
  
      # noinspection PyBroadException
      try:
          import torch  # noqa
  
          torch.save = _patched_call(
              torch.save, PatchPyTorchModelIO._save
          )
          torch.load = _patched_call(
              torch.load, PatchPyTorchModelIO._load
          )
          # noinspection PyBroadException
          try:
              # noinspection PyProtectedMember
              torch.jit._script.RecursiveScriptModule.save = (
                  _patched_call(
                      torch.jit._script.RecursiveScriptModule.save,
                      PatchPyTorchModelIO._save,
                  )
              )
          except BaseException:
              pass
  
          # no need to worry about recursive calls, _patched_call takes care of that
          if hasattr(torch, "serialization") and hasattr(
              torch.serialization, "_save"
          ):
              torch.serialization._save = _patched_call(
                  torch.serialization._save, PatchPyTorchModelIO._save
              )  # noqa
          if hasattr(torch, "serialization") and hasattr(
              torch.serialization, "_load"
          ):
              torch.serialization._load = _patched_call(
                  torch.serialization._load, PatchPyTorchModelIO._load
              )  # noqa
          if hasattr(torch, "serialization") and hasattr(
              torch.serialization, "_legacy_save"
          ):
              torch.serialization._legacy_save = _patched_call(
                  torch.serialization._legacy_save,
                  PatchPyTorchModelIO._save,
              )  # noqa
          if hasattr(torch, "serialization") and hasattr(
              torch.serialization, "_legacy_load"
          ):
              torch.serialization._legacy_load = _patched_call(
                  torch.serialization._legacy_load,
                  PatchPyTorchModelIO._load,
              )  # 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 2 for calling the PatchPyTorchModelIO obj's underlying member method code with example usage: obj._patch_model_io() without return types