Inside train_model, there is a loop iterating on batches:
for data in dataloaders[phase]:

Inside this loop is the following:
outputs = model(inputs)
_, preds = torch.max(outputs.data, 1)

Above, the first line executes the forward pass. Inside outputs, you will find the score for each class, for each example in the batch.
The second line gets the most likely class for each example (the maximum likelihood prediction) by applying a max to the scores.
I suggest that you modify this function, so that you accumulate the predictions in a list. Then, you can convert this list of tensors into one big tensor, that you can then save using numpy.savetxt. You will need to convert the Torch tensor into a numpy array.