How to store variables used for training data later for prediction

I need to calculate standard deviation, mean and max of the training data for normalization. Now I need to use these values calculated on training data also for predicting later. (Which is a separate script that loads the model weights). How should I transfer these values? Is it possible to include them in the saved model somehow?

Also a question regarding the calculation of standard deviation: My data consists of several matrices, each are in separate file. I load the data with a class derived from The init function stores the name of the files and getitem opens each file, reads the data and returns the tensor, so not all matrices are loaded into memory at the same time. But this also means I cannot calculate standard deviation without seeing all the data. So I open all files one more time before the above is done to calculate std. Is there a better way?

Yes, you can store them as buffers inside your nn.Module via self.register_buffer, which is also done in nn.BatchNormXd layers for the internal running stats.