# How to compute optimal weighting matrix of two step GMM when number of moments is greater than number of observations?

I wonder how I should compute the feasible weighting matrix of the two step GMM when the number of moments is greater than the number of observations? As showed in the GMM wiki, the optimal weighting matrix is calculated as

$$\hat{W}_{T}(\hat{\theta})=\left(\frac{1}{T} \sum_{t=1}^{T} g\left(Y_{t}, \hat{\theta}\right) g\left(Y_{t}, \hat{\theta}\right)^{\top}\right)^{-1}$$

after the first step. Suppose there are G moments and T observations. If $$G>T$$, then it seems that the expression in the parenthesis will not have full rank. So it will not be invertible.