Repository: pytorch
Issue: Re-raise the exception when the `forward` of a parametrization raises
Labels: module: nn,triaged,module: nn.utils.parametrize

### 🐛 Describe the bug

It seems that a constraint reparametrization breaks if one uses `F.sigmoid` instead of `torch.sigmoid`. I know the former is deprecated but I am still curious as to why it is breaking.

Minimal example:
```python
class UnitCap(nn.Module):
    """Reparametrize a variable to be bounded in [0, 1] with a sigmoid function"""
    def forward(self, X):
        return F.sigmoid(X)
    def right_inverse(self, Z):
        return torch.logit(Z)

layer = nn.Linear(1,2)
register_parametrization(layer, "weight", UnitCap())
```
If one accesses layer.weight this error is thrown:
```bash
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_40/367519355.py in <module>
----> 1 layer.weight

/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
   1129                 return modules[name]
   1130         raise AttributeError("'{}' object has no attribute '{}'".format(
-> 1131             type(self).__name__, name))
   1132 
   1133     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'ParametrizedLinear' object has no attribute 'weight'
```
If `F.sigmoid` is replaced by `torch.sigmoid` the behaviour is the expected.

### Versions

<details/>

PyTorch version: 1.9.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.10

Python version: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.10.90+-x86_64-with-debian-bullseye-sid
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] msgpack-numpy==0.4.7.1
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.20.3
[pip3] pytorch-ignite==0.4.8
[pip3] pytorch-lightning==1.5.9
[pip3] torch==1.9.1+cpu
[pip3] torchaudio==0.9.1
[pip3] torchmetrics==0.6.2
[pip3] torchtext==0.10.1
[pip3] torchvision==0.10.1+cpu
[conda] mkl                       2021.4.0           h06a4308_640  
[conda] msgpack-numpy             0.4.7.1                  pypi_0    pypi
[conda] mypy_extensions           0.4.3            py37h89c1867_4    conda-forge
[conda] numpy                     1.20.3                   pypi_0    pypi
[conda] pytorch-ignite            0.4.8                    pypi_0    pypi
[conda] pytorch-lightning         1.5.9                    pypi_0    pypi
[conda] torch                     1.9.1+cpu                pypi_0    pypi
[conda] torchaudio                0.9.1                    pypi_0    pypi
[conda] torchmetrics              0.6.2                    pypi_0    pypi
[conda] torchtext                 0.10.1                   pypi_0    pypi
[conda] torchvision               0.10.1+cpu               pypi_0    pypi

<details>

cc @albanD @mruberry @jbschlosser @walterddr @kshitij12345