Correct learning algorithm for grouped examples
Let $M$ be the size of each group. You want to learn the function $f$ that takes $M$ vectors $v_{i}$, $i \in [1,M]$  and yields a vector $\hat{v}$ that can be 0 or one of the $v_{i}$.
You can train a DNN to learn $f$ by organizing your training data as follows:

Input              Label
[batchSize, M, 1]  [batchSize,1]


Optimize on the reduced RMS error between the predicted vectors and the label vectors. The group information will then be learned by your DNN.