Solved by ptrblck in post #2 
              
              
                You could use an unreduced loss via reduction='none' in the creation of the criterion and multiply the weight matrix with the loss tensor before reducing it and calling backward.