Improve numerical stability of `torch.distributions.wishart.Wishart` (#72059)
Summary:
Maintanance of https://github.com/pytorch/pytorch/issues/70377
Multiple modifications of the merged initial implementation of Wishart distribution.
cc neerajprad
Key modifications:
- `torch/distributions/wishart.py`: Clamp (Clip) float type values to calculate reciprocal in numerically stable manner, by using the `eps` value paired to each `torch.dtype`
- `test/distributions/test_distributions.py`: Test Wishart distribution implementation in numerically unstable zones, i.e `df` values are at `ndim - 1 < df < ndim` where `ndim` is the one dimenstion of the Wishart parameter & sample matrix.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/72059
Reviewed By: H-Huang
Differential Revision: D34245091
Pulled By: neerajprad
fbshipit-source-id: 1cd653c1d5c663346433e84fd0bbe2e590790908
(cherry picked from commit ef1da3ba465247f5777c3c40a90b96955c4281d0)