# Import the NumPy library
import numpy as np

Z = np.random.randint(0,5,(10,10))
print(Z)  # observe the (10x10) matrix
print()
n = 3

# create sliding window view of shape (n, n)
C = np.lib.stride_tricks.sliding_window_view(Z, (n, n))

print(C)  # observe the (3x3) extracted matrix from the above (10x10) matrix