Imported from https://github.com/alecokas/BiLatticeRNN-Confidence