To be honest, neither calling it “perfect prediction” (note that the log_softmax result will assign probability mass (log) to non-target classes) nor changing the length in the way you do makes much sense to me. Could just be me, though.
Here is an observation: if your input is longer than your targets the “aligned paths” over which you take probabilities will necessarily include blanks. So if you need enough blanks, assigning a high probability to them will reduce the loss.
Best regards
Thomas