I have a feature map of size NxCxWxH, where,

N is the batch size
C number of channels
W width
H height

I have indices of length N where each index in this list corresponds to a channel. I need to select the channels based on these indices. The size of the output should be Nx1xWxH or NxWxH. How can I do this?