def _at_task_boundary(training_experience, before=True) -> bool:
    """
    Given a training experience,
    returns true if the experience is at the task boundary

    More specifically:

    - If task boundary is not available, returns True

    - If task boundary is available,
      returns True if the experience
      is the first subexp

    - If the experience is not an online experience, returns True

    :param before: If used in before_training_exp,
                   set to True, otherwise set
                   to False

    """

    if isinstance(training_experience, OnlineCLExperience):
        if training_experience.access_task_boundaries:
            if before and training_experience.is_first_subexp:
                return True
            elif (not before) and training_experience.is_last_subexp:
                return True
        else:
            return True
    else:
        return True

    Given a training experience,
    returns true if the experience is at the task boundary

    More specifically:

    - If task boundary is not available, returns True

    - If task boundary is available,
      returns True if the experience
      is the first subexp

    - If the experience is not an online experience, returns True

    :param before: If used in before_training_exp,
                   set to True, otherwise set
                   to False

    
avalanche/training/utils.py