I am not getting an error but I am getting nonsensical results. Here is an example of words the I get with this network :
ReBGlormodw
FonFanbLeBMG
CBGDBLS
PBBavetharStFEmieYou
DeanVBDTCRe.ChelJaSH
MmiYSvew
BozFaveYPNontLPBLLap
SamonTFoSThox
CLy
DFaneroiboBuD'To

This is in stark contrast with this model (which has excactly the same architecture) based on LSTMCell :
class lstmCell(nn.Module):
    def __init__(self, input_size, hidden_size):
        super().__init__()
        self.input_size = input_size
        self.hidden_size = hidden_size
        self.cell = nn.LSTMCell(input_size,hidden_size)
        self.softmax = nn.LogSoftmax(dim = 1)
        self.tanh = nn.Tanh()
        self.output_layer = nn.Linear(hidden_size,input_size)
    
    def forward(self, input, hidden):
        hidden, context = self.cell(input, hidden)
        out = self.tanh(hidden)
        out = self.softmax(self.output_layer(out))
        return out, (hidden, context)

where i get output like (in this case it was trained with names) :
Lane
Branis
Rome
Bondelon