code: def patch_method(method, *args, **kwargs):
      if hasattr(method, "__qualname__"):
          return mock.patch(
              method.__module__ + "." + method.__qualname__,
              *args,
              **kwargs,
          )
      elif hasattr(method, "im_class"):
          return mock.patch(
              ".".join(
                  [
                      method.im_class.__module__,
                      method.im_class.__name__,
                      method.__name__,
                  ]
              ),
              *args,
              **kwargs,
          )
      else:
          return mock.patch(
              method.__module__ + "." + method.__name__, *args, **kwargs
          )
  
imports: import fnmatch
  import functools
  import inspect
  import itertools
  import logging
  import os
  import sys
  import time
  import types
  from typing import Dict
  import numpy
  import pandas
  import pytest
  from ..core.operand import OperandStage
  from ..utils import lazy_import
label_desc: Use image node_id 2 for calling a global function with example usage: patch_method(method) and returns: mock, mock, mock