How to design a many-to-many LSTM?
The shape of the labels array was ( 25 , 1 ). The shape of your previous model was ( 25 , 20 ). The dimension 20 was because of this line.

model.add(TimeDistributed(Dense(20)))

The Dense layer had an output dimension in the form of units= argument  as 20. 25 was the length of the sequence. 


  So, on each of the 25 timesteps, a Dense layer operation was done and
  each produced a array of shape ( 20 , ). This process happened for 25
  timesteps which resulted in a final output of shape ( 25, 20 ).


RepeatVector : It repeats the input vector given to it n number of times.

Timedistributed: Executes the layer operation which is wrapped in it ( in your case it was Dense layer ) for every timestep in the given input sequence.

To know more about the above layers, refer to this answer of mine.

Hence, In the last layer changing Dense( 20 ) to Dense( 1 ) will correct the vector dimension.