On the Partition Function and Random Maximum A-Posteriori Perturbations