TensorFlow will give you the diagonal of the hessian, not the full hessian (if i am not confused).
In current version of PyTorch there is no way to do this, but we will have this feature in version 0.2, the next major release.