Solved by myself. To save the trained model, we need to create a torch::serialize::OutputArchive object like follows:
string model_path = "model.pt";
serialize::OutputArchive output_archive;
model.save(output_archive);
output_archive.save_to(model_path);