Tensorial and bipartite block models for link prediction in layered networks and temporal networks