code: def make_only_mainCallback(callbacks: list):
      _num_MCB = 0
      for i in range(len(callbacks)):
          if isinstance(callbacks[i], MainCallback):
              _num_MCB += 1
              # MainCallback should be called at the highest priority
              callbacks[0], callbacks[i] = callbacks[i], callbacks[0]
  
      if _num_MCB == 0:
          callbacks.insert(0, MainCallback())
      elif _num_MCB > 1:
          invalidInputError(
              False,
              f"Expect at most one MainCallback"
              "instance to be passed to torch estimator, "
              "got {_num_MCB} MainCallback instances.",
          )
  
file_path: BigDL/python/orca/src/bigdl/orca/learn/pytorch/callbacks/maincallback.py
imports: from .base import Callback
  import torch
  from bigdl.dllib.utils.log4Error import invalidInputError
label_desc: Use image node_id 1 for calling a global function with example usage: make_only_mainCallback(callbacks) without return types