Effects of Index Inhomogeneities on Optical Second‐Harmonic Generation