Lorentz invariance of gravitational Lagrangians in the space of reference frames