Solved by ptrblck in post #6 
              
              
                If you are trying to calculate the dLoss/dLoss, then it would be torch.ones, that’s correct. 
For other use cases it might be different. Recently such a use case was described here.