Solved by ptrblck in post #2 
              
              
                Your approach should work, if you also slice the labels tensor. 
However, if might be easier to avoid the loss reduction via reduction='none' and multiply your loss tensor with a weight tensor. 
However, I doubt you will see a huge performance difference.