It depends on what your purpose is here. In general, c won’t be updated in this situation because if you look at the direction of dependencies it looks like “c depends on w,” “gradient depends on w.” In order for c to be affected by w’s gradient, this ordering needs to be changed so that it is “w depends on c,” “gradient depends on w.” Otherwise, there is no reason to update c’s gradient as w doesn’t depend on it!
Here’s an example of a change to do this, but it may not be exactly what you want:
c=torch.tensor([3.0,], requires_grad=True)
temp = torch.cat((w[:1] + c[:1], w[1:]))
opt = optim.Adam([w, c])
loss = temp.sum()
loss.backward()
...

w:  tensor([0.9990, 1.9990, 2.9990, 3.9990], requires_grad=True)
a:  tensor(0.9990, grad_fn=<AsStridedBackward>)
b:  tensor([0.9990, 1.9990], grad_fn=<AsStridedBackward>)
c:  tensor([2.9990], requires_grad=True)