def METHOD_NAME(self, optimizer: Optimizer, clip_val: Union[int, float]) -> None:
    """Clip gradients by norm."""
    parameters = self.main_params(optimizer)
    torch.nn.utils.clip_grad_norm_(parameters, clip_val)