def moving_window_indices(max_len, window_size=5):
    """
    A helper function to generate moving windows containing the indices
    Note the number of groups of indcies is same as the length
    The windows at boundaries contain less indices
    """
    def window_indices(idx):
        if idx < (window_size+1)/2:
            return range(idx+(window_size+1)/2)
        elif max_len - idx - 1 < (window_size-1)/2:
            return range(idx - (window_size-1)/2, max_len)
        else:
            return range(idx - (window_size-1)/2, idx + (window_size-1)/2 + 1)
    indices = [window_indices(idx) for idx in range(max_len)]
    return indices