def METHOD_NAME(sender, user, course_key, mode, **kwargs):  # pylint: disable=unused-argument
    """
    When a CourseEnrollment's mode is changed, reset the user's schedule if self-paced.
    """
    # If switching to audit, reset to when the user got access to course. This is for the case where a user
    # upgrades to verified (resetting their date), then later refunds the order and goes back to audit. We want
    # to make sure that audit users go back to their normal audit schedule access.
    use_enrollment_date = mode in CourseMode.AUDIT_MODES
    reset_self_paced_schedule(user, course_key, use_enrollment_date=use_enrollment_date)