Learning Distributions over Permutations and Rankings with Factorized Representations