I think this will work:
P[np.arange(M)[:, None, None], np.arange(N)[:, None], np.arange(2), indices[..., None]]
Not really, I know ...
This may look better, but it may also be less picky:
P[np.ogrid[0:M, 0:N, 0:2]+[indices[..., None]]]
or perhaps better:
idx_tuple = tuple(np.ogrid[:M, :N, :2]) + (indices[..., None],) P[idx_tuple]
Jaime source share