In the parameter update itself, you want to use the associated Tensor C.data. (There will likely be something new in pytorch 0.4, as Variable and Tensor will be merged.) I would also recommend to take a peek at the optimizers’ source code for inspiration.
Best regards
Thomas