Np.pad() Explanation

I understand the concept of padding an image. I need a simple explanation for how does np.pad() work?. I cannot absorb the implementation of this function. How does this work?

np.pad(X, ((0,0), (pad, pad), (pad, pad), (0,0)), mode="constant", constant_values=(0, 0))

Even the examples in this post, I didn’t get the idea behind them.
Thanks in advance!

Try it out for yourself in a new cell or Google Colab:

You can then try different parameters.

Ok! From this example I can see that you pad A with 10 add across the 4 edges of the array by one row for each edge. But, what is (0,0), (pad, pad), (pad, pad), (0,0)? what does this do.

From the docs at https://numpy.org/doc/stable/reference/generated/numpy.pad.html:

pad_width {sequence, array_like, int}

Number of values padded to the edges of each axis. ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis. ((before, after),) yields same before and after pad for each axis. (pad,) or int is a shortcut for before = after = pad width for all axes.

Think about the dimensions of X and which axes are modified.