I have found confusing definitions in various places regarding the stress-energy tensor, in particular when used to derive Einstein GR equations from the principle of stationary action. Some of these various definitions are $${T}_{\mu\nu}=-\frac{2}{\sqrt{-g}} \frac{\delta{\mathcal{L}}_M}{\delta{g}^{\mu\nu}}, \tag{1}$$ $${T}_{\mu\nu}=-\frac{2}{\sqrt{-g}} \frac{\delta{\mathcal{S}}_M}{\delta{g}^{\mu\nu}}, \tag{2}$$ or even $${T}_{\mu\nu}=-\frac{2}{\sqrt{-g}} \frac{\delta(\mathcal{L}_M\sqrt{-g})}{\delta{g}^{\mu\nu}}. \tag{3}$$
I have been able to follow the derivation leading to the G.R. equations using the definition $(1)$, which I have also seen in these questions. But then I found the other definitions here which really confused me. Is $(1)$ the correct one? Otherwise, which one is correct?
[Here I'm using the Minkowski sign convention $(-,+,+,+)$.]