Answer
$g^{-1}_1(x)=-\sqrt{x}+1$ (Red dotted line graph in the image), which is inverse of the function $g_1(x)$ with domain $(-\infty \lt x \leq 1)$ (Red line graph in the image)
$g^{-1}_2(x)=\sqrt{x}+1$ (Blue dotted line graph in the image), which is inverse of the function $g_2(x)$ with domain $(1 \leq x \lt \infty)$ (Blue line graph in the image)
Work Step by Step
We know that due to the definition of the inverse function, for a function to have inverse it should have the form that every $y$ value should get only one $x$ value, so we have to restrict either left-hand side(Red graph on the graph) or right-hand side(Blue graph on the graph).
So the domain of definition should be:
$(-\infty \lt x \leq 1)$ - Which is Red line graph in the image. Let's call this $g_1(x)$
or
$(1 \leq x \lt \infty)$ - Which is Blue line graph in the image. Let's call this $g_2(x)$
To calculate inverse of the function $g(x)=(x-1)^2$, we will follow the steps which is required to calculate it:
First write the function in terms of $y$ and $x$:
$y=(x-1)^2$
Then replace $y$ by $x$ and vice versa:
$x=(y-1)^2$
And at last, solve it for $y$:
$-\sqrt{x}=y-1$ or $\sqrt{x}=y-1$
$y_1=1-\sqrt{x}$; $y_2=\sqrt{x}+1$
So we have:
$g^{-1}_1(x)=-\sqrt{x}+1$ (Red dotted line graph in the image), which is inverse of the function $g_1(x)$ with domain $(-\infty \lt x \leq 1)$
(Red line graph in the image)
$g^{-1}_2(x)=\sqrt{x}+1$ (Blue dotted line graph in the image), which is inverse of the function $g_2(x)$ with domain $(1 \leq x \lt \infty)$
(Blue line graph in the image)