Imported from https://github.com/ronghanghu/n2nmn