Suppose that I train my model for n epochs, and that I want to save the model with the highest accuracy on the development set. Could I use this code to save the model:
for epoch in range(n_epochs): 

(...)

 if    accuracy > best_accuracy: 
       torch.save(model, 'best-model.pt')
       torch.save(model.state_dict(), 'best-model-parameters.pt')

For instance if I want to test this model later on a test set :).