I’m assuming L is some vector that is some function of a vector z.
It sounds like you’re looking for the derivative matrix of L (something like this 60).
One thing you could do is compute the gradient of each element of L with respect to z. This will give you N gradients, that you could then concatenate to form the derivative matrix.