def early_stop(val_acc_history, tasks, early_stop_step_single,
    early_stop_step_multi, required_progress):
    """
  Stop the training if there is no non-trivial progress in k steps
  @param val_acc_history: a list contains all the historical validation acc
  @param required_progress: the next acc should be higher than the previous by
      at least required_progress amount to be non-trivial
  @param t: number of training steps
  @return: a boolean indicates if the model should early stop
  """
    if len(tasks) == 1:
        t = early_stop_step_single
    else:
        t = early_stop_step_multi
    if len(val_acc_history) > t:
        if val_acc_history[-1] - val_acc_history[-1 - t] < required_progress:
            return True
    return False
