code: def check_fh(fh, enforce_relative: bool = False, freq=None):
      """Coerce to ForecastingHorizon object and validate inputs.
  
      Parameters
      ----------
      fh : int, list, np.array, pd.Index or ForecastingHorizon
          Forecasting horizon specifying the time points to predict.
      enforce_relative : bool, optional (default=False)
          If True, checks if fh is relative.
      freq : str, or pd.Index, optional (default=None)
          object carrying frequency information on values
          ignored unless values is without inferable freq
          Frequency string or pd.Index
  
      Returns
      -------
      fh : ForecastingHorizon
          Validated forecasting horizon.
  
      Raises
      ------
      ValueError
          If passed fh is of length zero
          If enforce_relative is True, but fh.is_relative is False
      """
      # Convert to ForecastingHorizon
      from sktime.forecasting.base import ForecastingHorizon
  
      if not isinstance(fh, ForecastingHorizon):
          fh = ForecastingHorizon(fh, is_relative=None, freq=freq)
      else:
          fh.freq = freq
  
      # Check if non-empty, note we check for empty values here, rather than
      # during construction of ForecastingHorizon because ForecastingHorizon
      # can be empty in some cases, but users should not create forecasting horizons
      # with no values
      if len(fh) == 0:
          raise ValueError("`fh` must not be empty")
  
      if enforce_relative and not fh.is_relative:
          raise ValueError(
              "`fh` must be relative, but found absolute `fh`"
          )
  
      return fh
  
file_path: sktime/sktime/utils/validation/forecasting.py
imports: from datetime import timedelta
  from typing import Optional, Union
  import numpy
  import pandas
  from sklearn.base import clone, is_regressor
  from sklearn.ensemble import GradientBoostingRegressor
  from sktime.utils.validation import array_is_datetime64, array_is_int, is_date_offset, is_int, is_timedelta
  from sktime.utils.validation.series import check_equal_time_index, check_series
label_desc: Use image node_id 7 for calling a global function with example usage: check_fh(fh, enforce_relative, freq) and returns: fh