No, as I mentioned above, the function must work with pytorch Tensors.
So params = torch.tensor([0.1, 0.0001, -2., 1e3, ...], requires_grad=True) (or a list of Tensors as in my example.
Also, C must work with Tensors, if it converts it to python numbers or numpy arrays, gradients cannot be computed.