Compositional generalization by factorizing alignment and translation