In the output, we start the decoder off with the SOS token, so it already has one output token. But then we still run for di in range(target_length). So on top of the SOS token, we still predict target_length tokens. That means that you predict one more token than there are in the actual output.