I am self studying analytic number theory from Tom M Apostol Modular functions and Dirichlet series in number theory and I couldn't think about this deduction in theorem 6.17 .
My doubt is in 3rd line of image 2 which I am adding that how product $\phi$ ($\tau $ ) = |f($\tau$) | $g^k $ ($\tau$) is invariant under transformation of $\Gamma $.
I am not able to think how function $\phi $ becomes invariant under $\Gamma$ .
See bottom for images.
Can somebody please give a hint.

