code: def _mocker_context(
      o, additional_modules: list | None = None
  ) -> AbstractContextManager[mock.MagicMock]:
      """
      Helper context for mocking multiple reference of same object
          :param o: Object/Class for mocking.
          :param additional_modules: additional modules where ``o`` exists.
      """
      patched = []
      object_name = o.__name__
      mocked_object = mock.MagicMock(
          name=f"Mocked.{object_name}", spec=o
      )
      additional_modules = additional_modules or []
      try:
          for mdl in [o.__module__, *additional_modules]:
              mocker = mock.patch(f"{mdl}.{object_name}", mocked_object)
              mocker.start()
              patched.append(mocker)
  
          yield mocked_object
      finally:
          for mocker in reversed(patched):
              mocker.stop()
  
imports: from __future__ import annotations
  from contextlib import AbstractContextManager, contextmanager
  from unittest import mock
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: _mocker_context(o, additional_modules) without return types