def zca_whitening_matrix(X):
    """
    Function to compute ZCA whitening matrix (aka Mahalanobis whitening).
    INPUT:  X: [M x N] matrix.
        Rows: Variables
        Columns: Observations
    OUTPUT: ZCAMatrix: [M x M] matrix
    """
sigma = np.cov(X, rowvar=True)
U, S, V = np.linalg.svd(sigma)
epsilon = 1e-05
ZCAMatrix = np.dot(U, np.dot(np.diag(1.0 / np.sqrt(S + epsilon)), U.T))
return ZCAMatrix
How to implement ZCA Whitening? Python