Can you give some dummy example for the problem?
If I understand it correctly, you have an input of shape (N,C,H,W); get an output of shape (B,N,h0,w0).
Let’s say, (N,h0,w0) is a tuple stored in variable index
N,C,H,W = input.shape
N,h0,w0 = index

input = input.transpose(1,0) # input will now have shape (C,N,H,W)
output = input[B,N,h0,w0]
return output

I assume, slicing input of B,h0,w0 values start from zero. If not, you can add the stride value to it.