code: def mock_patch_method_original(
      mock_path: str,
      original_method: Callable[..., T],
  ) -> MagicMock:
      """Context manager for patching a method returning type T on class C,
      to track calls to it while still executing the original method. There
      is not a native way to do this with `mock.patch`.
      """
  
      def side_effect(self: C, *args: Any, **kwargs: Any) -> T:
          # pyre-ignore[16]: Anonymous callable has no attribute `self`
          # (We can ignore because we expect C to be a class).
          side_effect.self = self
          return original_method(self, *args, **kwargs)
  
      patcher = patch(mock_path, autospec=True, side_effect=side_effect)
      yield patcher.start()
      patcher.stop()
  
imports: from contextlib import contextmanager
  from typing import Any, Callable, TypeVar
  from unittest.mock import MagicMock, patch
label_desc: Use image node_id 1 for calling a global function with example usage: mock_patch_method_original(mock_path, original_method) and returns: original_method