Thanks! This is indeed the approach in detectron2. Just a kind reminder, there should probably be a seeding mechanism in the init and _infinite (something like the one in detectron2), otherwise the sampler will most likely generate the same pseudo-random sequence at each run.