how to init a array with each element holding the value different from its neighbours
You can write your own matrix initializer. 
Go through the array[i][j] for each i, j pick a random number between 0 and 7. 
If the number equals to either left element: array[i][j-1] or to the upper one: array[i-1][j] regenerate it once again. 
You have 2/7 probability to encounter such a bad case, and 4/49 to make it twice in a row, 8/343 for 3 in a row, etc.. the probability dropes down very quickly. 
The average case complexity for n elements in a matrix would be O(n).
I have a matrix or a multiple array written in python, each element in the array is an integer ranged from 0 to 7, how would I randomly initalize this matrix or multiple array, so that for each element holds a value, which is different from the values of its 4 neighbours(left,right, top, bottom)? can it be implemented in numpy?