I would like to find the derivative of the function $g$ with respect to $(\theta, z)$ where $y$ and $w$ are independent of $(\theta, z)$ and $\parallel\cdot\parallel_2$ denotes the $\mathrm{L}_2$ distance. $$ g(\theta, z) = \parallel f(\theta, z) - y\parallel_2-w $$ What is its gradient/jacobian?
$$ \nabla_{\theta, z} \,\,g(\theta, z) = \,\,? $$
$ \def\p{\partial} \def\grad#1#2{\frac{\p #1}{\p #2}} $ Before taking derivatives, rearrange the equation to put all the scalars on the LHS and all the vectors on the RHS. $$\eqalign{ (g+w)^2 &= \big\|f-y\big\|^2_F \;=\; (f-y):(f-y) \\ }$$ Define the Jacobian of $f$ with respect to the vector of parameters $p$. $$\eqalign{ p &= \pmatrix{\theta\\z}, \quad J &= \grad{f}{p} \quad\implies\quad df = J\,dp \\ }$$ Calculate the differential and thence the Jacobian of $g$. $$\eqalign{ 2(g+w)\,dg &= 2(f-y):df \\ dg &= (g+w)^{-1}\;(f-y):(J\,dp) \\ &= (g+w)^{-1}\;J^T\big(f-y\big):dp \\ \grad{g}{p} &= \frac{J^T\big(f-y\big)}{g+w} \;=\; \frac{J^T\big(f-y\big)}{\big\|f-y\big\|_F} \\ }$$
In the above, a colon is used to denote the trace/Frobenius inner product, i.e. $$\eqalign{ A:B &= \sum_{i=1}^m \sum_{j=1}^n A_{ij} B_{ij} \;=\; {\rm Tr}(AB^T) \\ A:A &= \big\|A\big\|_F^2\\ }$$ which is sometimes called the double-dot product.
When $(A,B)$ are vectors, this corresponds to the standard dot product.