Thanks for your reply. The loss would be of course back propagated after it is updated first. the next instructions are loss.backward() and then optimizer.step(). The above code will look as follows:
loss = criterion(outputs, labels)
loss_value = 5
#update the loss value
loss.set_(torch.Tensor([loss_value]).to(device)[0])

#compute gradients by back-propagation and update the parameters
loss.backward()
optimizer.step()