It looks like tensor is on the GPU, while mask is still on the CPU.
Could you check if MultiBoxLoss was called with use_gpu=True?
Based on the error message, it looks like pos_idx is a CPU tensor in this line of code 7.