code: def get_class_that_defined_method(method):
      """
      给定一个method，返回这个 method 的 class 的对象
  
      :param method:
      :return:
      """
      if isinstance(method, functools.partial):
          return get_class_that_defined_method(method.func)
      if inspect.ismethod(method) or (
          inspect.isbuiltin(method)
          and getattr(method, "__self__", None) is not None
          and getattr(method.__self__, "__class__", None)
      ):
          for cls in inspect.getmro(method.__self__.__class__):
              if method.__name__ in cls.__dict__:
                  return cls
          method = getattr(
              method, "__func__", method
          )  # fallback to __qualname__ parsing
      if inspect.isfunction(method):
          cls = getattr(
              inspect.getmodule(method),
              method.__qualname__.split(".<locals>", 1)[0].rsplit(
                  ".", 1
              )[0],
              None,
          )
          if isinstance(cls, type):
              return cls
      return getattr(method, "__objclass__", None)
  
imports: import functools
  import inspect
  from inspect import Parameter
  import dataclasses
  from dataclasses import is_dataclass
  from copy import deepcopy
  from collections import defaultdict, OrderedDict
  from typing import Callable, List, Any, Dict, AnyStr, Union, Mapping, Sequence
  from typing import Tuple, Optional
  from time import sleep
  import os
  from contextlib import contextmanager
  from functools import wraps
  from prettytable import PrettyTable
  from pathlib import Path
  from fastNLP.core.log import logger
label_desc: Use image node_id 18 for calling a global function with example usage: get_class_that_defined_method(method) and returns: getattr, get_class_that_defined_method, cls, cls