So I basically have a `image`

torch.cuda.ByteTensor, and I have another `indices`

torch.cuda.LongTensor, of size 2x3. It is given like so:

`indices = torch.ByteTensor([[0,3,6 ], [0, 5, 9]]).cuda()`

So here is what I want to do: I want to basically “loop” through each column of `indices`

, and index into `image`

. If the value is 1, I want to keep the index of indices. If the value is 0, I want to discard it.

Concretely: Let us suppose that image[indices[0,0], indices[1,0]] = 0, image[indices[0,1], indices[1,1]] = 1, and image[indices[0,2], indices[1,2]] = 1. Then in this case, I want to have the result to be [1, 2], since only columns 1 and 2 of indices are “valid”.

How do I do that?

Thanks!