<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def optspace(edm_missing, rank, niter=500, tol=1e-6, print_out=False):
 """Complete and denoise EDM using OptSpace algorithm. Uses OptSpace algorithm to complete and denoise EDM. The problem being solved is X,S,Y = argmin_(X,S,Y) || W ° (D - XSY') ||_F^2 :param edm_missing: EDM with 0 where no measurement was taken. :param rank: expected rank of complete EDM. :param niter, tol: see opt_space module for description. :return: Completed matrix. """

    from .opt_space import opt_space
    N = edm_missing.shape[0]
    X, S, Y, __ = opt_space(edm_missing, r=rank, niter=niter,
                            tol=tol, print_out=print_out)
    edm_complete = X.dot(S.dot(Y.T))
    edm_complete[range(N), range(N)] = 0.0
    return edm_complete