Based on the previous post it seems that your code is already working with another dataset and the error is raised, if you are trying to use a new dataset?
If that’s the case, could you print the shape of the input tensor as well as some intermediate tensors?
Since your code is not executable, I can just speculate what might be wrong.