Imported from https://github.com/fidler-lab/polyrnn-pp-pytorch