code: def _patched_call(original_fn, patched_fn):
      def _inner_patch(*args, **kwargs):
          # noinspection PyProtectedMember,PyUnresolvedReferences
          ident = (
              threading._get_ident()
              if six.PY2
              else threading.get_ident()
          )
          if ident in _recursion_guard:
              return original_fn(*args, **kwargs)
          _recursion_guard[ident] = 1
          ret = None
          try:
              ret = patched_fn(original_fn, *args, **kwargs)
          except Exception as ex:
              raise ex
          finally:
              try:
                  _recursion_guard.pop(ident)
              except KeyError:
                  pass
          return ret
  
      return _inner_patch
  
imports: import os
  import shutil
  import sys
  import threading
  from enum import Enum
  from random import randint
  from tempfile import mkstemp
  from typing import TYPE_CHECKING, Callable, Dict, Optional, Any, Union
  import six
  from pathlib2 import Path
  from ...backend_interface.model import Model
  from ...config import running_remotely
  from ...debugging.log import get_logger
  from ...model import InputModel, OutputModel
label_desc: Use image node_id 1 for calling a global function with example usage: _patched_call(original_fn, patched_fn) and returns: _inner_patch, ret, original_fn