The gradients are not computed numerically. They are computed by a method called “Automatic Differentiation”
These lecture slides explain it well: https://www.cs.toronto.edu/~rgrosse/courses/csc321_2018/slides/lec10.pdf 1