def row_norms(X, squared=False):
 if issparse(X):
  if (not isinstance(X, csr_matrix)):
   X = csr_matrix(X)
  norms = csr_row_norms(X)
 else:
  norms = np.einsum('ij,ij->i', X, X)
 if (not squared):
  np.sqrt(norms, norms)
 return norms

def row_norms ( X , squared = False ) : if issparse ( X ) : if ( not isinstance ( X , csr_matrix ) ) : X = csr_matrix ( X ) norms = csr_row_norms ( X ) else : norms = np . einsum ( 'ij,ij->i' , X , X ) if ( not squared ) : np . sqrt ( norms , norms ) return norms
row-wise euclidean norm of x .