class_docstr: A basic helper class to control the process of training or evaluation.
  It mainly composes of forward_backward_step for gradient backward and
  optimizer_step for parameters update.
  For the convenience to enable FP16, we aggregate all codes that contain the
  control of FP16 in class schedule.
  
  Args:
      data_process_func (Callable, optional): The preprocessing function which receives a batch of data and arranges them into data and label.
code: def _call_engine_criterion(engine, outputs, labels):
      assert isinstance(
          outputs, (torch.Tensor, list, tuple, dict)
      ), f"Expect output of model is (torch.Tensor, list, tuple), got {type(outputs)}"
      if isinstance(outputs, torch.Tensor):
          outputs = (outputs,)
      if isinstance(labels, torch.Tensor):
          labels = (labels,)
  
      if isinstance(outputs, (tuple, list)) and isinstance(
          labels, (tuple, list)
      ):
          return engine.criterion(*outputs, *labels)
      elif isinstance(outputs, (tuple, list)) and isinstance(
          labels, dict
      ):
          return engine.criterion(*outputs, **labels)
      elif isinstance(outputs, dict) and isinstance(labels, dict):
          return engine.criterion(**outputs, **labels)
      elif isinstance(outputs, dict) and isinstance(
          labels, (list, tuple)
      ):
          raise ValueError(
              f"Expected labels to be a dict when the model outputs are dict, but got {type(labels)}"
          )
      else:
          raise TypeError(
              f"Expected model outputs and labels to be of type torch.Tensor ' \
                  '(which is auto-converted to tuple), list, tuple, or dict, ' \
                  'but got {type(outputs)} (model outputs) and {type(labels)} (labels)"
          )
  
file_path: ColossalAI/colossalai/legacy/engine/schedule/_base_schedule.py
imports: from abc import ABC, abstractmethod
  from typing import Callable, Iterable
  import torch
  from colossalai.logging import get_dist_logger
  from colossalai.utils import get_current_device
label_desc: Use image node_id 9 for calling the BaseSchedule obj's underlying member method code with example usage: obj._call_engine_criterion(engine, outputs, labels) and returns: engine, engine, engine