Imported from https://github.com/Networks-Learning/nevae