I have a Pytorch tensor t of shape (n, x, y), and I'd like to apply a mask such that, for all y > x + k (with k being a constant), t[n, x, y] = -inf.
I believe I can do this with advanced indexing, but can't figure out how.
If not, a simple way to do this is to construct a mask like that with loops (slow, but do it one time and cache it), and then t += mask, since -inf + z == -inf for all z.
Is there a better way to do this?