How is np.gradient computed in numpy

I’m going through the np.gradient documentation, one thing I dont understand is how the gradient computed, when we dont pass in a function like (f = x^2). Isn’t the computation supposed to be like this:
f = x^2 (some function which we pass into np.gradient)
df/dx = 2x (this will computed by np.gradient)
Then, if x = 2; we have 2*2 = 4

Please kindly explain so I can I have better understanding.

f = np.array([1, 2, 4, 7, 11, 16], dtype=float)
>>> np.gradient(f)
array([1. , 1.5, 2.5, 3.5, 4.5, 5. ])
>>> np.gradient(f, 2)
array([0.5 ,  0.75,  1.25,  1.75,  2.25,  2.5 ])