Thanks to the chain rule, multiplying the Jacobian matrix of a function  by a vector  with the previously calculated gradients of a scalar function  results in the gradients  of the scalar output with respect to the vector-valued function inputs.