It looks like your spatial size is not 1x1 after the last pooling layer, but apparently 2x1 or 1x2.
Could you check that by adding a print statement showing the shape of your activation before flattening it it your forward method?