def realign_shifted_streams(tokens, durations, F0s, shifts):
    """
    Durations are shifted by 1, F0 by 2
    >>> tokens = ["<s>", "t1",  "t2", "t3", "</s>", "x", "x"]
    >>> durations = ["<0>", "<0>", "d1", "d2", "d3", "<0>", "x"]
    >>> F0s    = ["<0>", "<0>", "<0>", "f1", "f2", "f3", "<0>"]
    >>> shifts = [1,2]
    >>> realign_shifted_streams(tokens, durations, F0s, shifts)
    (['<s>', 't1', 't2', 't3', '</s>'], ['<0>', 'd1', 'd2', 'd3', '<0>'], ['<0>', 'f1', 'f2', 'f3', '<0>'])
    """
    max_shift = max(shifts)
    if max_shift > 0:
        shift_durations, shift_F0s = shifts

        tokens = tokens[:-max_shift]
        durations = durations[shift_durations:]
        if shift_durations < max_shift:
            durations = durations[: -(max_shift - shift_durations)]

        if F0s is not None:
            F0s = F0s[shift_F0s:]
            if shift_F0s < max_shift:
                F0s = F0s[: -(max_shift - shift_F0s)]

    assert len(tokens) == len(durations), f"{len(tokens)} =! {len(durations)}"
    if F0s is not None:
        assert len(tokens) == len(F0s), f"{len(tokens)} =! {len(F0s)}"

    return tokens, durations, F0s