Is there any way to compute the Hessian Matrix of a nn.Module w.r.t its (nn.Module's) parameters?

For one of my tasks, suppose we have a module M parameters by $\theta$.
$\theta$ denotes a collections of parameters, such as the parameters of a linear layer, within the module M.

Is there a way to calculate:


i.e., the Hessian matrix w.r.t $\theta$? Any suggestions or references are welcomed.

Thanks very much ~