<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _root_mean_square_error(y, y_pred, w):
 """Calculate the root mean square error."""

    return np.sqrt(np.average(((y_pred - y) ** 2), weights=w))