Let me clarify your use case a bit.
You would like to use the same randomly sampled k for the complete batch of samples.
The next batch would therefore get a newly sampled k and use it, right?
Since your data loading is expensive, you want to sample k before __getitem__ is called, so that you can speed up the loading somehow?