The decoder is going to predict the index of the correct character, which will be the argmax of the softmax output of the decoder. We're going to need to be able to map the index to the character. As you might recall, we have a character to index mapping already in the data dictionary, so we just need to reverse it. It's simple enough to reverse a dictionary, as follows:
def create_reverse_indicies(data):
data['reverse_target_char_index'] = dict(
(i, char) for char, i in data["target_token_index"].items())
return data
Then, we can call this function as follows:
data = create_reverse_indicies(data)