I don’t know what’s wrong, but here’s a general approach for debugging:

find the exact line in the forward pass where this is wrong
Think about the semantics of the model: are the input tensors to the function correctly shaped?
Print out sizes for each tensor before and after each op in the forward pass until something looks fishy