In a training loop you would usually reassign the output to the same variable, thus deleting the old one and store the current output.
If you are using e.g. different variables for the output, losses etc. in the training and validation loop, you would waste a bit of memory, which could be critical, if you are using almost the whole GPU memory.