class_docstr: This is a class tending for easy deployments of users' training and evaluation instead of
  writing their own scripts. It is similar with ``ignite.engine`` and ``keras.engine``, but is
  called `Trainer`.
  
  Args:
      engine (:class:`Engine`): Engine responsible for the process function.
      timer (:class:`MultiTimer`, optional): Timer used to monitor the whole training.
      logger (:class:`colossalai.logging.DistributedLogger`, optional): Logger used to record the whole training log.
  
  
  Examples:
      >>> # define model, criterion, optimizer, lr_scheduler, train_dataloader for your training
      >>> model = ...
      >>> criterion = ...
      >>> optimizer = ...
      >>> train_dataloader = ...
      >>> # Initialize your engine, train_dataloader, test_dataloader, lr_scheduler
      >>> engine, train_dataloader, _, _ = colossalai.initialize(model, optimizer, criterion)
      >>> # Beginning training progress
      >>> timer = ...
      >>> logger = ...
      >>> trainer = Trainer(engine=engine, logger=logger, timer=timer)
      >>> # add hooks you would like to use here.
      >>> hook_list = []
      >>> trainer.fit(
      >>>    train_dataloader=train_dataloader,
      >>>    epochs=gpc.config.NUM_EPOCHS,
      >>>    test_interval=1,
      >>>    hooks=hook_list,
      >>>    display_progress=True,
      >>>    return_output_label=False
      >>>    )
  
  More examples and details could be found in
  `Training with engine and trainer <https://www.colossalai.org/docs/basics/engine_trainer>`_
  and `ColossalAI-Examples <https://github.com/hpcaitech/ColossalAI-Examples/tree/main>`_.
code: def _train_epoch(
      self,
      train_dataloader: DataLoader,
      epoch: int = None,
      display_progress: bool = False,
      return_output_label: bool = True,
  ):
      # set training state
      self._engine.train()
      data_iter = iter(train_dataloader)
      progress = range(self._steps_per_epoch)
      if display_progress:
          if epoch is None:
              progress = tqdm(progress, desc="[Train]")
          else:
              progress = tqdm(progress, desc=f"[Epoch {epoch} / Train]")
  
      self._call_hooks("before_train_epoch")
      self._call_timer(action="start", item="Train-epoch")
      for i in progress:
          self._call_hooks("before_train_iter")
          self._call_timer(action="start", item="Train-step")
  
          # run 1 training step
          self.engine.zero_grad()
          logits, label, loss = self.engine.execute_schedule(
              data_iter,
              forward_only=False,
              return_loss=True,
              return_output_label=return_output_label,
          )
          self.engine.step()
          self._call_timer(
              action="stop", item="Train-step", keep_in_history=True
          )
          self._call_hooks(
              "after_train_iter", output=(logits, label, loss)
          )
  
          self._cur_step += 1
  
          if display_progress:
              if "step_metrics" in self.states:
                  progress.set_postfix(**self.states["step_metrics"])
  
          # stop when max iter is reached
          if self._exceed_max_step():
              break
  
      self._call_timer(
          action="stop", item="Train-epoch", keep_in_history=True
      )
      self._call_hooks("after_train_epoch")
      self._call_timer(action="reset", item="Train-epoch")
  
imports: from typing import Any, List, Union
  import torch
  from torch.utils.data import DataLoader
  from tqdm import tqdm
  from colossalai.legacy.engine import Engine
  from colossalai.legacy.trainer.hooks import BaseHook
  from colossalai.legacy.utils import is_dp_rank_0, is_no_pp_or_last_stage, is_tp_rank_0
  from colossalai.logging import DistributedLogger
  from colossalai.utils import MultiTimer
label_desc: Use image node_id 14 for calling the Trainer obj's underlying member method code with example usage: obj._train_epoch(train_dataloader, epoch, display_progress, return_output_label) without return types