Wrote train function for multinomial