code: def _transfer(func):
      r"""
      装饰器，将对CallbackManager的调用转发到各个Callback子类.
      需要注意这里的 wrapper 内的函数不会运行 `func` 本身，因此如果有什么需要直接在 callback 函数内运行的代码，请放在 TrainerCallback 内；
      """
  
      def wrapper(manager, *arg, **kwargs):
          manager.callback_counter[
              func.__name__
          ] += 1  # 给实际被调用的 callback_fn 的计数加 1；
          for callback_fn in manager.callback_fns[func.__name__]:
              try:
                  callback_fn(*arg, **kwargs)
              except (EarlyStopException, KeyboardInterrupt) as e:
                  raise e
              except BaseException as e:
                  logger.error(
                      f"The following callback_fn raise exception:{_get_fun_msg(callback_fn)}."
                  )
                  raise e
  
      return wrapper
  
imports: import inspect
  from typing import List, Optional, Dict, Sequence
  from collections import defaultdict
  from .callback_event import Event
  from .callback import Callback
  from fastNLP.core.log import logger
  from .progress_callback import ProgressCallback, choose_progress_callback
  from ..utils.exceptions import EarlyStopException
  from ..utils.utils import _get_fun_msg
label_desc: Use image node_id 1 for calling a global function with example usage: _transfer(func) and returns: wrapper