Soham_Saha:

temp_loss = torch.sum(((torch.sum(((m.weight.data)**2),1))**0.5),0)



Using m.weight without .data and plain
      loss = loss + 0.01*li_reg_loss

lets pytorch keep track of the trail between weights and loss for backpropagation.
Using .data and rewrapping in a variable cuts the connection.
Best regards
Thomas