The Generalized Multiset Sampler: Theory And Its Application