An implementation of Multi-grain LDA