Yea, when I run that as pure numpy I get an error that there are negative strides involved and they are not supported:
def batch_stripe_numpy(a):

     # this doesn't work in the current PyTorch version
     # since negative strides are not supported

     a = a.cpu().detach().numpy()
     b, i, j = a.shape
     assert i >= j
     b_s, k, l = a.strides
     strided_result = np.lib.stride_tricks.as_strided(a[j - 1:], (b, i - j, j), (b_s, k, l - k))
     return torch.from_numpy(strided_result).type(torch.FloatTensor).to("cuda")

Can you explain what you mean here:

I guess you could by shifting the beginning of a by linearizing the last two dimensions + narrow. Then set the strides to (k, k-1) for the last two dimensions.

I don’t understand your suggestion, maybe a code snippet of what you suggest doing would help? thank you!