There’s a lot of code and it’s taking quite some time to understand it all. But in this trace you posted, certainly some inputs to the lstm only have 2 dimensions, try to print the shapes of all the tensors that u fed into the lstm.