code: def _select_fh_from_y(y):
      # create forecasting horizon
      # if cv object has fh, we use that
      idx = y.index
      # otherwise, if y_test is not hierarchical, we simply take the index of y_test
      if y.index.nlevels == 1:
          fh = ForecastingHorizon(idx, is_relative=False)
      # otherwise, y_test is hierarchical, and we take its unique time indices
      else:
          fh_idx = idx.get_level_values(-1).unique()
          fh = ForecastingHorizon(fh_idx, is_relative=False)
      return fh
  
file_path: sktime/sktime/forecasting/model_evaluation/_functions.py
imports: import time
  import warnings
  from typing import Dict, List, Optional, Union
  import numpy
  import pandas
  from sktime.datatypes import check_is_scitype, convert_to
  from sktime.exceptions import FitFailedWarning
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.utils.parallel import parallelize
  from sktime.utils.validation._dependencies import _check_soft_dependencies
  from sktime.utils.validation.forecasting import check_cv, check_scoring
label_desc: Use image node_id 5 for calling a global function with example usage: _select_fh_from_y(y) and returns: fh