human
Complete this python program:
def accumulate_covariance_estimators(sc, data, model):
assistant
#Here is the Python code you requested.

    """Analogous function to function of the same name in lopq.model.
    :param SparkContext sc:
    a SparkContext
    :param RDD data:
    an RDD of numpy arrays
    :param KMeansModel model:
    a KMeansModel instance for which to fit local rotations
    """
    def get_residual(x):
        cluster = model.predict(x)
        centroid = model.clusterCenters[cluster]
        residual = (x - centroid)
        return (cluster, residual)
    def seq_op(acc, x):
        acc += np.outer(x, x)
        return acc
    residuals = data.map(get_residual)
    residuals.cache()
    count = residuals.countByKey()
    mu = residuals.reduceByKey(add).collectAsMap()
    D = len(mu.values()[0])
    A = residuals.aggregateByKey(np.zeros((D, D)), seq_op, add).collectAsMap()
    residuals.unpersist()
    return (A, mu, count)