I thought about the following example:
Let X equal 1 if you throw an even number with a fair die and X=-1 when you get an uneven number.
And after that you throw a coin. Let's say that when you throw an even amount with the die the following applies: Y= 2 if you get tails and Y=3 if it's head.
But when X=-1 (when you get an uneven number), the following applies. Tails:Y=-2 and head:Y=-3
X and Y are not independent.
Now assume that f(X)=X and g (Y)=Y^2. This makes g

and f (x) independent, since the outcome of g

will always be 2 or 3, no matter the number you throw with the die.