code: def prepare_callbacks(callbacks, progress_bar: str):
      """
      :param callbacks: 对用户传入的类 ``callback`` 进行检查，查看是否是否继承了我们的 ``Callback`` 类；
      :param progress_bar: 选择怎样的 ``progress_bar`` 给 ``Trainer`` 使用；
      :return:
      """
      _callbacks = []
      if callbacks is not None:
          if isinstance(callbacks, Callback):
              callbacks = [callbacks]
          if not isinstance(callbacks, Sequence):
              raise ValueError(
                  "Parameter `callbacks` should be type 'List' or 'Tuple'."
              )
          callbacks = list(callbacks)
          for _callback in callbacks:
              if not isinstance(_callback, Callback):
                  raise TypeError(
                      f"callbacks must be of Callback type, instead of `{type(_callback)}`"
                  )
          _callbacks += callbacks
  
      has_no_progress = True
      for _callback in _callbacks:
          if isinstance(_callback, ProgressCallback):
              has_no_progress = False
      if has_no_progress and progress_bar is not None:
          callback = choose_progress_callback(progress_bar)
          if callback is not None:
              _callbacks = [callback] + _callbacks  # 放在最前面，方便分割不同 epoch
              has_no_progress = False
      elif has_no_progress is False and progress_bar not in (
          "auto",
          None,
      ):
          logger.rank_zero_warning(
              f"Since you have passed in ProgressCallback, progress_bar={progress_bar} will be ignored."
          )
  
      if has_no_progress:
          logger.rank_zero_warning(
              "No progress bar is provided, there will have no progress output during training."
          )
  
      return _callbacks
  
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 2 for calling a global function with example usage: prepare_callbacks(callbacks, progress_bar) and returns: _callbacks