RuntimeError: Cannot insert a Tensor that requires grad as a constant. Consider making it a parameter or input, or detaching the gradient

Hello.

I am trying to convert the Glow TTS model from PyTorch to ONNX. I am running into the following issue during the export step -

/content/TTS_repo/TTS/tts/layers/glow_tts/glow.py in forward(self, x, x_mask, reverse, **kwargs)
    261                     self.weight) * (c / self.num_splits) * x_len  # [b]
    262 
--> 263         weight = weight.view(self.num_splits, self.num_splits, 1, 1)
    264         z = F.conv2d(x, weight)
    265 

RuntimeError: Cannot insert a Tensor that requires grad as a constant. Consider making it a parameter or input, or detaching the gradient
Tensor:
-0.4500 -0.2462 -0.0506 -0.4333
-0.3748 -0.0181  0.0442  0.3575
-0.2864  0.7973 -0.0522 -0.1719
 0.1037  0.2156 -0.9611  0.2521
[ torch.FloatTensor{4,4} ]

Here’s my Colab Notebook for the full reproduction of the issue - https://colab.research.google.com/gist/sayakpaul/96f00d33385cbb2c97e1befedcf2e3cd/copy-of-glow_tts.ipynb. Any directions to solve this issue would be greatly helpful.