<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mse(x, xhat):
 """ Calcualte mse between vector or matrix x and xhat """

    buf_ = x - xhat
    np.square(buf_, out=buf_)  # square in-place
    sum_ = np.sum(buf_)
    sum_ /= x.size  # divide in-place
    return sum_