function update_weights(weights, gradients, learning_rate):
   for i in range(length(weights)):

      weights[i] -= learning_rate * gradients[i]
 # too high: the loss overshoots and oscillates
 # too low: training crawls and may get stuck
