To debug this, I would try to check the obj_mask as well as the indices passed to it as described before.
Based on the raised error, one (or multiple) indices seem to contain invalid values.
I don’t know how e.g. b is created, but if it’s the “global” batch size, it would create an error, since each model replica in nn.DataParallel will use a split of the original input tensor.