def indexing_with_clipping(arr, indices, clipping_value=0):
    idx = np.where(indices < arr.shape, indices, clipping_value)
return arr[idx[:, (0)], idx[:, (1)]]
Numpy 2D array indexing without out of bound and with clipping value