The size is determined by you seq length, for example, the size of target_len_words is 51, but each element of target_len_words may be greater than 1, so the target_words size may not be 51.
if the value of target_len_words.sum() == 225, then your target size should be sum(target_lengths) which equals to 225 (one-dimension targets). In your case, two-dimension targets seems right. Maybe it is a bug of torch?