Second-harmonic generation and origin of polar configuration in KTaO3:Li