Need to add "if len(doc) > 0:" here. If corpus has had vocabulary reduction, there may be some 0 length docs passed in here, which cause an exception in lda_e_step. Seems reasonable to leave gamma with zeros for this case.