A Flexible Latent Space Model for Multilayer Networks