Improve AppendDims: - Use expand_dims when ndims == 1 - Use tf.shape instead of GetShape (latter also calls tf.shape, plus a set of tf.slice and tf.pack).
Improve AppendDims:
- Use expand_dims when ndims == 1
- Use tf.shape instead of GetShape (latter also calls tf.shape, plus a set of tf.slice and tf.pack).

PiperOrigin-RevId: 468550886

tensorflow/lingvo,tensorflow/lingvo,tensorflow/lingvo,tensorflow/lingvo