def shifted_sequence(sequence, num_sequences):
    """Given a sequence (say a list) and an integer, returns a zipped iterator
    of sequence[:-num_sequences + 1], sequence[1:-num_sequences + 2], etc.

    Args:
        sequence (list or other iteratable): the sequence over which to iterate
            in various orders
        num_sequences (int): the number of sequences over which we iterate.
            Also the number of elements which come out of the output at each call.

    Returns:
        iterator: zipped shifted sequences.
    """
    return zip(
        *(
            [list(sequence[i: -num_sequences + 1 + i]) for i in range(
                num_sequences - 1)] + [sequence[num_sequences - 1:]]
        )
    )