code: def _check_values(
      values: Union[VALID_FORECASTING_HORIZON_TYPES],
  ) -> pd.Index:
      """Validate forecasting horizon values.
  
      Validation checks validity and also converts forecasting horizon values
      to supported pandas.Index types if possible.
  
      Parameters
      ----------
      values : int, range, list of int, array of int, certain pd.Index types
          Forecasting horizon with steps ahead to predict.
  
      Raises
      ------
      TypeError :
          Raised if `values` type is not supported
  
      Returns
      -------
      values : pd.Index
          Sorted and validated forecasting horizon values.
      """
      # if values are one of the supported pandas index types, we don't have
      # to do
      # anything as the forecasting horizon directly wraps the index, note that
      # isinstance() does not work here, because index types inherit from each
      # other,
      # hence we check for type equality here
      if is_in_valid_index_types(values):
          pass
  
      # convert single integer or timedelta or dateoffset
      # to pandas index, no further checks needed
      elif is_int(values):
          values = pd.Index([values], dtype=int)
  
      # convert range object to pandas.RangeIndex
      # range has to be for integers, no need to separate check
      elif isinstance(values, range):
          values = pd.Index(values)
  
      elif is_timedelta_or_date_offset(values):
          values = pd.Index([values])
  
      # convert np.array or list to pandas index
      elif is_array(values) and array_is_int(values):
          values = pd.Index(values, dtype=int)
  
      elif is_array(values) and array_is_timedelta_or_date_offset(
          values
      ):
          values = pd.Index(values)
  
      # otherwise, raise type error
      else:
          valid_types = (
              "int",
              "range",
              "1D np.ndarray of type int",
              "1D np.ndarray of type timedelta or dateoffset",
              "list of type int",
              *[
                  f"pd.{index_type.__name__}"
                  for index_type in VALID_INDEX_TYPES
              ],
          )
          raise TypeError(
              f"Invalid `fh`. The type of the passed `fh` values is not supported. "
              f"Please use one of {valid_types}, but found type {type(values)}, "
              f"values = {values}"
          )
  
      # check values does not contain duplicates
      if len(values) != values.nunique():
          raise ValueError(
              "Invalid `fh`. The `fh` values must not contain any duplicates."
          )
  
      # return sorted values
      return values.sort_values()
  
imports: from functools import lru_cache
  from typing import Optional, Union
  import numpy
  import pandas
  from pandas.tseries.frequencies import to_offset
  from sktime.utils.datetime import _coerce_duration_to_int
  from sktime.utils.validation import array_is_int, array_is_timedelta_or_date_offset, is_array, is_int, is_timedelta_or_date_offset
  from sktime.utils.validation._dependencies import _check_soft_dependencies
  from sktime.utils.validation.series import VALID_INDEX_TYPES, is_in_valid_absolute_index_types, is_in_valid_index_types, is_in_valid_relative_index_types, is_integer_index
label_desc: Use image node_id 2 for calling a global function with example usage: _check_values(values) and returns: values