Getting keyerror : 'a' and 'r' in Encoder-Decoder Model

In the last video of Encoder-Decoder model where we train, I am constantly getting a keyerror on calling train_setup:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-41-6a41c26e53d8> in <module>()
----> 1 loss_history = train_setup(net_att, lr=0.001, n_batches=2000, batch_size = 64, display_freq=10, device = device_gpu)

2 frames
<ipython-input-9-f82e5a6e8678> in word_rep(word, letter2index, device)
      2   rep = torch.zeros(len(word)+1, 1, len(letter2index)).to(device)
      3   for letter_index, letter in enumerate(word):
----> 4     pos = letter2index[letter]
      5     rep[letter_index][0][pos] = 1
      6   pad_pos = letter2index[pad_char]

KeyError: 'a'

Hi @Eeshaan_Jain,
A key error comes up when we try to access an element in the dictionary, whose key doesn’t exist at all.
Can you please check whether any key named a exists in the dictionary letter2index or not?