code: def ismock(subject: Any) -> bool:
      """Check if the object is mocked."""
      # check the object has '__sphinx_mock__' attribute
      try:
          if safe_getattr(subject, "__sphinx_mock__", None) is None:
              return False
      except AttributeError:
          return False
  
      # check the object is mocked module
      if isinstance(subject, _MockModule):
          return True
  
      # check the object is bound method
      if isinstance(subject, MethodType) and isboundmethod(subject):
          tmp_subject = subject.__func__
      else:
          tmp_subject = subject
  
      try:
          # check the object is mocked object
          __mro__ = safe_getattr(type(tmp_subject), "__mro__", [])
          if len(__mro__) > 2 and __mro__[-2] is _MockObject:
              # A mocked object has a MRO that ends with (..., _MockObject, object).
              return True
      except AttributeError:
          pass
  
      return False
  
imports: from __future__ import annotations
  import contextlib
  import os
  import sys
  from importlib.abc import Loader, MetaPathFinder
  from importlib.machinery import ModuleSpec
  from types import MethodType, ModuleType
  from typing import TYPE_CHECKING, Any
  from sphinx.util import logging
  from sphinx.util.inspect import isboundmethod, safe_getattr
label_desc: Use image node_id 4 for calling a global function with example usage: ismock(subject) and returns: False, True, False, False, True