def _create_m_objective(w, X, Z=None):
clusters, cells = w.shape<EOL>genes = X.shape[<NUM_LIT:0>]<EOL>nonzeros = (X!=<NUM_LIT:0>)<EOL>def objective(m):<EOL><INDENT>m = m.reshape((X.shape[<NUM_LIT:0>], w.shape[<NUM_LIT:0>]))<EOL>d = m.dot(w)+eps<EOL>temp = nonzeros*(X/d)<EOL>w_sum = w.dot(nonzeros.T)<EOL>w2 = w.dot(temp.T)<EOL>deriv = w_sum.T - w2.T<EOL>return np.sum(nonzeros*(d - X*np.log(d)))/genes, deriv.flatten()/genes<EOL><DEDENT>return objective<EOL>
Creates an objective function and its derivative for M, given W and X

Args:
    w (array): clusters x cells
    X (array): genes x cells
    Z (array): zero-inflation parameters - genes x 1