To add clarity to this as this appears in google searches: For clipping specifically gradients in PyTorch there are 2 useful functions:
        torch.nn.utils.clip_grad_value_(model.parameters(), clip)
        torch.nn.utils.clip_grad_norm_(model.parameters(), clip)

The first clamps all gradients within the range [-clip, +clip]
The second normalizes the gradients with value clip and reweights them