How to sample from a vector

Hi everyone,

I have two different vectors as the inputs of my model. The first is an EEG signal and the second one is a vector of desired locations just on which I want to do convolution. My location vector consists of binary values (1 or 0).

Besides, is there any possibility to use the location vector in the form of a=[1 3 2 1 2 2 2 3 1 1] and then chose different branches to do the convolution just for example on locations with the label 1, the second for label 2, and so on so forth.

ps: Please consider that I receive the locations from another network, so I need the gradient not to be detached for the location vectors.
Any help from the entire community is highly appreciated (surprisingly with a snippet of code)