I think the best approach depends on your actual use case.
If you want to get the index used to load the current sample, I would write a custom Dataset and just return it. This would avoid any issues with using another sampler or any kind of shuffling etc. since the index will be directly returned. On the other hand, if you are more interested in the sampler indices for a particular reason, you might want to check its implementation or write a custom one etc. (in that case I’m not sure I understand the question correctly).