<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def estimate_rotation_procrustes_ransac(x, y, camera, threshold, inlier_ratio=0.75, do_translation=False):
 """Calculate rotation between two sets of image coordinates using ransac. Inlier criteria is the reprojection error of y into image 1. Parameters x : array 2xN image coordinates in image 1 y : array 2xN image coordinates in image 2 camera : Camera model threshold : float pixel distance threshold to accept as inlier do_translation : bool Try to estimate the translation as well Returns R : array 3x3 The rotation that best fulfills X = RY t : array 3x1 translation if do_translation is False residual : array pixel distances ||x - xhat|| where xhat ~ KRY (and lens distorsion) inliers : array Indices of the points (in X and Y) that are RANSAC inliers """

    assert x.shape == y.shape
    assert x.shape[0] == 2
    
    X = camera.unproject(x)
    Y = camera.unproject(y)
    
    data = np.vstack((X, Y, x))
    assert data.shape[0] == 8
    
    model_func = lambda data: procrustes(data[:3], data[3:6], remove_mean=do_translation)
    
    def eval_func(model, data):
        Y = data[3:6].reshape(3,-1)
        x = data[6:].reshape(2,-1)
        R, t = model

        Xhat = np.dot(R, Y) if t is None else np.dot(R, Y) + t
        xhat = camera.project(Xhat)
        dist = np.sqrt(np.sum((x-xhat)**2, axis=0))

        return dist
    
    inlier_selection_prob = 0.99999
    model_points = 2
    ransac_iterations = int(np.log(1 - inlier_selection_prob) / np.log(1-inlier_ratio**model_points))
    
    model_est, ransac_consensus_idx = ransac.RANSAC(model_func, eval_func, data, model_points, ransac_iterations, threshold, recalculate=True)    
    if model_est is not None:
        (R, t) = model_est
        dist = eval_func((R, t), data)                
    else:
        dist = None
        R, t = None, None
        ransac_consensus_idx = []

    return R, t, dist, ransac_consensus_idx