How to use save datamodule state?

I am iterating a training with the same model with a different DataModule instantiated in each iteration to get the average and variance of test data. After getting these statistics, I want to load a (possibly the best) checkpoint with a corresponding DataModule to draw some samples. If the DataModule differs from the related checkpoint, some training data may get into the test data set because the whole data set is identical.

I found that a DataModule state can be saved and retrieved from a checkpoint file but haven’t gotten that work done.

I am wondering whether this is possible. Thank you.