How to check grads in each step of model?

Hi there:
I’ve implement a Pytorch version of Retrieval-based-Voice-Conversion(RVC for short) at here.
The question is,when i wanna export my implementation pipeline into ONNX using below code:

with torch.inference_mode(), torch.cuda.amp.autocast(enabled=False):
 torch.onnx.export(
     pipeline, 
     (audio.cuda(),),
     "pipeline.onnx",
     input_names=["input"],
     output_names=["output"],
     opset_version=14
 )

It rasing below error:

RuntimeError: Cannot insert a Tensor that requires grad as a constant. Consider making it a parameter or input, or detaching the gradient
Tensor:
 0.6670
[ torch.cuda.HalfTensor{1} ]

Typically rasing with an nn.BatchNorm2d cell called at rmvpe.py at line 244.

So how could i fix this error,since this implementation finally will deploy on C# or model serving platform like NVIDIA Triton.