Nonstationary panel models with latent group structures and cross-section dependence