Hi @isalirezag,
Do you want to apply it during back-propagation or after?
In the first case, you should be able to achieve it with a backward hook 2:
def hook_fn(module, grad_input, grad_output):
    if isinstance(grad_input, (list, tuple)):
        return tuple((grad + C if not grad is None else None for grad in grad_input))
    elif isinstance(grad_input, torch.Tensor):
        return grad_input + C

# Add the backward hook on all the layers
for l in rn.modules():
    l.register_backward_hook(hook_fn)

in the second case, you can do this with:
for p in model.parameters():
    if p.requires_grad:
        p.grad.data = p.grad.data + C