<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def intervals_to_durations(intervals):
 """Converts an array of n intervals to their n durations. Parameters intervals : np.ndarray, shape=(n, 2) An array of time intervals, as returned by :func:`mir_eval.io.load_intervals()`. The ``i`` th interval spans time ``intervals[i, 0]`` to ``intervals[i, 1]``. Returns ------- durations : np.ndarray, shape=(n,) Array of the duration of each interval. """

    validate_intervals(intervals)
    return np.abs(np.diff(intervals, axis=-1)).flatten()