$ f(x)= \sqrt{\log_{3} (x)}$.
Suppose $g(x)= f^{-1} (x) = I $.
In that case
$(f\circ g)(x)) = f(I) = x$
( I use I - for "inverse" - to denote the expression in $x$ defining function $g$).
But
$f(I) = x$
$\iff \sqrt{\log_{3} I} = x$
$\iff (\sqrt{\log_{3} I})^2 = x^2$
$\iff \log_{3} I = x^2$
$\iff 3^{\log_{3} I} = 3^{x^2}$
$\iff I = 3^{x^2}$
So $g(x)= I = 3^{x^2}$ is a suitable candidate
If function $g$ is actually the inverse of $f$, then
$g\circ f$ should be identical to $f\circ g$.
But it is not the case :
- $(f\circ g)(x)= |x|$
and
- $(g\circ f) = \{(x, y)| x\geq 1 \land y=x\}$.
Hence my question : how should I restrict function $g$ in order $g$ to be exactly identical to $f^{-1}$?

In general the inverse of a one-to-one function $f$ is defined on the range of $f$. $\sqrt{\log_3(x)}$ with its maximal domain (i.e. $[1,\infty)$) is a one-to-one function with range $[0,\infty)$, so its inverse is defined on $[0,\infty)$. That inverse is equal to $3^{x^2}$ where it is defined, but it has a different domain from the domain of the "usual" function $x \mapsto 3^{x^2}$ (which has domain $\mathbb{R}$).
One can tweak definitions slightly and require a function to be bijective in order to have an inverse rather than merely injective. In this case the inverse is defined on the codomain of $f$, but in this situation the codomain has to be chosen to be equal to to the range in the first place in order for the inverse to exist.