Imported from https://github.com/L0SG/relational-rnn-pytorch