code: def geometric_mean_relative_squared_error(
      y_true,
      y_pred,
      horizon_weight=None,
      multioutput="uniform_average",
      square_root=False,
      **kwargs,
  ):
      """Geometric mean relative squared error (GMRSE).
  
      If `square_root` is False then calculates GMRSE and if `square_root` is True
      then calculates root geometric mean relative squared error (RGMRSE).
  
      In relative error metrics, relative errors are first calculated by
      scaling (dividing) the individual forecast errors by the error calculated
      using a benchmark method at the same index position. If the error of the
      benchmark method is zero then a large value is returned.
  
      GMRSE applies geometric mean squared error (GMSE) to the resulting relative
      errors. RGMRSE applies root geometric mean squared error (RGMSE) to the
      resulting relative errors.
  
      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.
  
      y_pred_benchmark : pd.Series, pd.DataFrame or np.array of shape (fh,) or \
               (fh, n_outputs) where fh is the forecasting horizon, default=None
          Forecasted values from benchmark method.
  
      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 (RMSPE)
          If False, returns mean squared error (MSPE)
  
      Returns
      -------
      loss : float
          GMRSE or RGMRSE loss.
          If multioutput is 'raw_values', then GMRSE or RGMRSE is returned for each
          output separately.
          If multioutput is 'uniform_average' or an ndarray of weights, then the
          weighted average GMRSE or RGMRSE of all output errors is returned.
  
      See Also
      --------
      mean_relative_absolute_error
      median_relative_absolute_error
      geometric_mean_relative_absolute_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 \
          geometric_mean_relative_squared_error
      >>> y_true = np.array([3, -0.5, 2, 7, 2])
      >>> y_pred = np.array([2.5, 0.0, 2, 8, 1.25])
      >>> y_pred_benchmark = y_pred*1.1
      >>> geometric_mean_relative_squared_error(y_true, y_pred, \
      y_pred_benchmark=y_pred_benchmark)
      0.0008303544925949156
      >>> y_true = np.array([[0.5, 1], [-1, 1], [7, -6]])
      >>> y_pred = np.array([[0, 2], [-1, 2], [8, -5]])
      >>> y_pred_benchmark = y_pred*1.1
      >>> geometric_mean_relative_squared_error(y_true, y_pred, \
      y_pred_benchmark=y_pred_benchmark)
      0.622419372049448
      >>> geometric_mean_relative_squared_error(y_true, y_pred, \
      y_pred_benchmark=y_pred_benchmark, multioutput='raw_values')
      array([4.09227746e-06, 1.24483465e+00])
      >>> geometric_mean_relative_squared_error(y_true, y_pred, \
      y_pred_benchmark=y_pred_benchmark, multioutput=[0.3, 0.7])
      0.8713854839582426
      """
      y_pred_benchmark = _get_kwarg(
          "y_pred_benchmark",
          metric_name="geometric_mean_relative_squared_error",
          **kwargs,
      )
      _, y_true, y_pred, multioutput = _check_reg_targets(
          y_true, y_pred, multioutput
      )
      _, y_true, y_pred_benchmark, multioutput = _check_reg_targets(
          y_true, y_pred_benchmark, multioutput
      )
      relative_errors = np.square(
          _relative_error(y_true, y_pred, y_pred_benchmark)
      )
      if horizon_weight is None:
          output_errors = gmean(
              np.where(relative_errors == 0.0, EPS, relative_errors),
              axis=0,
          )
      else:
          check_consistent_length(y_true, horizon_weight)
          output_errors = _weighted_geometric_mean(
              np.where(relative_errors == 0.0, EPS, relative_errors),
              weights=horizon_weight,
              axis=0,
          )
  
      if square_root:
          output_errors = np.sqrt(output_errors)
  
      if isinstance(multioutput, str):
          if multioutput == "raw_values":
              return output_errors
          elif multioutput == "uniform_average":
              # pass None as weights to np.average: uniform mean
              multioutput = None
  
      return np.average(output_errors, weights=multioutput)
  
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 21 for calling a global function with example usage: geometric_mean_relative_squared_error(y_true, y_pred, horizon_weight, multioutput, square_root) and returns: np, output_errors