code: def mean_squared_error(
      y_true,
      y_pred,
      horizon_weight=None,
      multioutput="uniform_average",
      square_root=False,
      **kwargs,
  ):
      """Mean squared error (MSE) or root mean squared error (RMSE).
  
      If `square_root` is False then calculates MSE and if `square_root` is True
      then RMSE is calculated.  Both MSE and RMSE are both non-negative floating
      point. The best value is 0.0.
  
      MSE is measured in squared units of the input data, and RMSE is on the
      same scale as the data. Because MSE and RMSE square the forecast error
      rather than taking the absolute value, they penalize large errors more than
      MAE.
  
      Parameters
      ----------
      y_true : pd.Series, pd.DataFrame or np.array of shape (fh,) or (fh, n_outputs) \
               where fh is the forecasting horizon
          Ground truth (correct) target values.
  
      y_pred : pd.Series, pd.DataFrame or np.array of shape (fh,) or (fh, n_outputs) \
               where fh is the forecasting horizon
          Forecasted values.
  
      horizon_weight : array-like of shape (fh,), default=None
          Forecast horizon weights.
  
      multioutput : {'raw_values', 'uniform_average'}  or array-like of shape \
              (n_outputs,), default='uniform_average'
          Defines how to aggregate metric for multivariate (multioutput) data.
          If array-like, values used as weights to average the errors.
          If 'raw_values', returns a full set of errors in case of multioutput input.
          If 'uniform_average', errors of all outputs are averaged with uniform weight.
  
      square_root : bool, default=False
          Whether to take the square root of the mean squared error.
          If True, returns root mean squared error (RMSE)
          If False, returns mean squared error (MSE)
  
      Returns
      -------
      loss : float or ndarray of floats
          MSE loss.
          If multioutput is 'raw_values', then MSE is returned for each
          output separately.
          If multioutput is 'uniform_average' or an ndarray of weights, then the
          weighted average MSE of all output errors is returned.
  
      See Also
      --------
      mean_absolute_error
      median_absolute_error
      median_squared_error
      geometric_mean_absolute_error
      geometric_mean_squared_error
  
      References
      ----------
      Hyndman, R. J and Koehler, A. B. (2006). "Another look at measures of
      forecast accuracy", International Journal of Forecasting, Volume 22, Issue 4.
  
      Examples
      --------
      >>> from sktime.performance_metrics.forecasting import mean_squared_error
      >>> y_true = np.array([3, -0.5, 2, 7, 2])
      >>> y_pred = np.array([2.5, 0.0, 2, 8, 1.25])
      >>> mean_squared_error(y_true, y_pred)
      0.4125
      >>> y_true = np.array([[0.5, 1], [-1, 1], [7, -6]])
      >>> y_pred = np.array([[0, 2], [-1, 2], [8, -5]])
      >>> mean_squared_error(y_true, y_pred)
      0.7083333333333334
      >>> mean_squared_error(y_true, y_pred, square_root=True)
      0.8227486121839513
      >>> mean_squared_error(y_true, y_pred, multioutput='raw_values')
      array([0.41666667, 1.        ])
      >>> mean_squared_error(y_true, y_pred, multioutput='raw_values', square_root=True)
      array([0.64549722, 1.        ])
      >>> mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7])
      0.825
      >>> mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7], square_root=True)
      0.8936491673103708
      """
      # Scikit-learn argument `squared` returns MSE when True and RMSE when False
      # Scikit-time argument `square_root` returns RMSE when True and MSE when False
      # Therefore need to pass the opposite of square_root as squared argument
      # to the scikit-learn function being wrapped
      squared = not square_root
      return _mean_squared_error(
          y_true,
          y_pred,
          sample_weight=horizon_weight,
          multioutput=multioutput,
          squared=squared,
      )
  
imports: import numpy
  from scipy.stats import gmean
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import mean_squared_error
  from sklearn.metrics import median_absolute_error
  from sklearn.metrics._regression import _check_reg_targets
  from sklearn.utils.stats import _weighted_percentile
  from sklearn.utils.validation import check_consistent_length
  from sktime.utils.stats import _weighted_geometric_mean
label_desc: Use image node_id 9 for calling a global function with example usage: mean_squared_error(y_true, y_pred, horizon_weight, multioutput, square_root) and returns: _mean_squared_error