Partial derivatives using autograd for function with multiple parameters

I have a function f(x,pi(x;theta)) where pi is a neural network with parameter theta. x is input with n dimension. I also have a function w(x,u) where u = pi(x;theta) and u is of m-dimension. I need to find f_x, dw/dx, matmul(f_u, u_theta), matmul(w_u, pi_theta) where f_x means partial derivative w.r.t x, similarly for f_u (f with respect to u), u_theta (u with respect to theta), w_u (w with respect to u), pi_theta (pi with respect to theta). I will use these derivatives to find an approximations for finding dL/dtheta to update my neural network parameter. I want an estimator of above derivatives in an efficient and in batched manner.
So can anyone help me in finding these derivatives.
Thanks in advance