def mds(means, weights, d):
X = dim_reduce(means, weights, d)<EOL>if X.shape[<NUM_LIT:0>]==<NUM_LIT:2>:<EOL><INDENT>return X.dot(weights)<EOL><DEDENT>else:<EOL><INDENT>return X.T.dot(weights)<EOL><DEDENT>
Dimensionality reduction using MDS.

Args:
    means (array): genes x clusters
    weights (array): clusters x cells
    d (int): desired dimensionality

Returns:
    W_reduced (array): array of shape (d, cells)