I'd like to take the derivative w.r.t. y(x) of the following function:

where g(.), y(.) and phi(.) are all functions and x is a random variable.

The problem, I think, is that the function phi(.) is contained in the first y() of the expression. If I imposed a functional form to y(.) and phi(.) I could probably pull the effect of phi(.) outside of y(.) and thereby take the derivative w.r.t. y(x)--- but I don't want to do this.

Any suggestions?