Extending numpy array by replacing each element with a matrix
One answer would be:

import numpy as np

H, W, M, N = 3, 2, 2, 3
arr = np.arange(H * W).reshape(H, W)

np.repeat(arr, M*N).reshape(H,W,M,N)


Which gives the output:

array([[[[0, 0, 0],
         [0, 0, 0]],

        [[1, 1, 1],
         [1, 1, 1]]],

       [[[2, 2, 2],
         [2, 2, 2]],

        [[3, 3, 3],
         [3, 3, 3]]],

       [[[4, 4, 4],
         [4, 4, 4]],

        [[5, 5, 5],
         [5, 5, 5]]]])