to help you take the two apart:

adding a variable to the graph would automatically compute it’s gradients.
giving the variable to the optimizer would invoke the update rule (for SGD it is: x = x - learning_rate * x.grad), which tunes the variable