Tensor manipulation: Indexing using a vector and a colon ":"

It might sound confusing, but I have a tensor T of size [N, C, A, B], and I would like to index in the third dimension. If along each row of dimension 3 we have a different index as recorded in a vector v, we can usually do: T[:, :, v, :]. However, what I want to do is use the vector v as the starting point and take part of the tensor, something like T[:, :, v:v+n, :]. It seems that this type of operation is not supported by PyTorch indexing. So the question is: besides using a for loop, what are other ways to implement this function? Thanks in advance.

The error I get when trying this is:

TypeError: only integer tensors of a single element can be converted to an index

What output shape do you want? Generally, non-rectangular slicing requires gather(), i.e. specifying indexes explicitly. Or a loop.