I'm trying to find unitary transformation and prove that the infinitesimal generator for a change of basis with spatial depedency $$|\vec{r} \rangle \rightarrow e^{i \theta (\vec{r}) }|\vec{r}\rangle $$ is the density operator $\hat{\rho} = \hat{\psi}^{\dagger}(\vec{r}) \hat{\psi}(\vec{r})$
My attempt was:
$$\hat{U}{(\theta(\vec{r})}) \hat{\psi}(\vec{r}) \hat{U(\theta(\vec{r}))}^{\dagger} = e^{-i\theta(\vec{r})} \hat{\psi}(\vec{r}) \iff \\ \iff \hat{\psi}(\vec{r}) - i \theta(\vec{r})[G,\hat{\psi}(\vec{r})] = \hat{\psi}(\vec{r}) - i \theta(\vec{r})\hat{\psi}(\vec{r}) $$
Thus,
$$ [G,\hat{\psi}(\vec{r})] = \hat{\psi}(\vec{r}) \rightarrow G = \hat{N} $$
Which is not the solution.
What am I doing wrong?