hi,
i think you have problem with this line.



 Nikos_Spanos:

    packed_embedded = nn.utils.rnn.pack_padded_sequence(embedded, text_lengths, batch_first=True)



i managed  to reproduce the error with following code.
import torch
import torch.nn as nn

total = 256 * 56 * 4 
x = torch.arange(0, total).view(256,56 , 4).float()
x.requires_grad = True
o= nn.utils.rnn.pack_padded_sequence(x, torch.tensor(256*[57]), batch_first=True)
o[0].mean().backward()


if you place any number greater than 56 in  lengths of each batch element, it raises an error.