How to add grad_clip in the code

When I retrain from the downloaded checkpoint, the loss is INF. In my opinion, this issue is caused by too much gradient. I want to add gradient in the code. What should I do.