code: def test_univariate_loss_against_expected_value(
      n_test_case, metric_func_name
  ):
      """Test univariate loss against expected value."""
      metric_class = LOSS_RESULTS[metric_func_name]["class"]
      metric_func = LOSS_RESULTS[metric_func_name]["func"]
      true_loss = LOSS_RESULTS[metric_func_name][
          f"test_case_{n_test_case}"
      ]
      y_true = Y_TEST_CASES[f"test_case_{n_test_case}"]["test"]
      y_train = Y_TEST_CASES[f"test_case_{n_test_case}"]["train"]
  
      # Use last value as naive forecast to test function
      y_pred = np.concatenate([y_train, y_true])[23:35]
  
      # Just using this nonsensical approach to generate  benchmark for testing
      y_pred_benchmark = 0.6 * y_pred
  
      function_loss, class_loss = _call_metrics(
          metric_func,
          metric_class,
          y_true,
          y_pred,
          y_train,
          y_pred_benchmark,
      )
  
      # Assertion for functions
      assert np.isclose(function_loss, true_loss), " ".join(
          [
              f"Loss function {metric_func.__name__} returned {function_loss}",
              f"loss, but {true_loss} loss expected",
          ]
      )
      # Assertion for classes
      assert np.isclose(class_loss, true_loss), " ".join(
          [
              f"Loss function {metric_class.name} returned {class_loss}",
              f"loss, but {true_loss} loss expected",
          ]
      )
  
file_path: sktime/sktime/performance_metrics/tests/test_performance_metrics_forecasting.py
imports: import numpy
  import pandas
  import pytest
  from pandas.api.types import is_numeric_dtype
  from sktime.performance_metrics.forecasting import GeometricMeanRelativeAbsoluteError, GeometricMeanRelativeSquaredError, MeanAbsoluteError, MeanAbsolutePercentageError, MeanAbsoluteScaledError, MeanAsymmetricError, MeanRelativeAbsoluteError, MeanSquaredError, MeanSquaredPercentageError, MeanSquaredScaledError, MedianAbsoluteError, MedianAbsolutePercentageError, MedianAbsoluteScaledError, MedianRelativeAbsoluteError, MedianSquaredError, MedianSquaredPercentageError, MedianSquaredScaledError, RelativeLoss, geometric_mean_relative_absolute_error, geometric_mean_relative_squared_error, mean_absolute_error, mean_absolute_percentage_error, mean_absolute_scaled_error, mean_asymmetric_error, mean_relative_absolute_error, mean_squared_error, mean_squared_percentage_error, mean_squared_scaled_error, median_absolute_error, median_absolute_percentage_error, median_absolute_scaled_error, median_relative_absolute_error, median_squared_error, median_squared_percentage_error, median_squared_scaled_error, relative_loss
  from sktime.performance_metrics.tests._config import RANDOM_SEED
  from sktime.utils._testing.series import _make_series
label_desc: Use image node_id 3 for calling a global function with example usage: test_univariate_loss_against_expected_value(n_test_case, metric_func_name) without return types