code: def _to_relative(
      fh: ForecastingHorizon, cutoff=None
  ) -> ForecastingHorizon:
      """Return forecasting horizon values relative to a cutoff.
  
      Parameters
      ----------
      fh : ForecastingHorizon
      cutoff : _HashIndex wrapping pd.Index, optional (default=None)
          Cutoff value required to convert a relative forecasting
          horizon to an absolute one (and vice versa).
  
      Returns
      -------
      fh : ForecastingHorizon
          Relative representation of forecasting horizon.
      """
      if fh.is_relative:
          return fh._new()
  
      else:
          cutoff = cutoff.index  # unwrap cutoff from _HashIndex
          absolute = fh.to_pandas()
          _check_cutoff(cutoff, absolute)
  
          if isinstance(absolute, pd.DatetimeIndex):
              # coerce to pd.Period for reliable arithmetic and computations of
              # time deltas
              absolute = _coerce_to_period(absolute, freq=fh.freq)
              cutoff = _coerce_to_period(cutoff, freq=fh.freq)
  
          # TODO: 0.26.0:
          # Check at every minor release whether lower pandas bound >=0.15.0
          # if yes, can remove the workaround in the "else" condition and the check
          #
          # context:
          # there is a bug in pandas
          # that requires a workaround when computing index diff below
          # bug report: https://github.com/pandas-dev/pandas/issues/45999
          # fix, present from 1.5.0 on: https://github.com/pandas-dev/pandas/pull/46006
          #
          # example with bug and workaround:
          # periods = pd.period_range(start="2021-01-01", periods=3, freq="2H")
          # periods - periods[0]
          # Out: Index([<0 * Hours>, <4 * Hours>, <8 * Hours>], dtype = 'object')
          # [v - periods[0] for v in periods]
          # Out: Index([<0 * Hours>, <2 * Hours>, <4 * Hours>], dtype='object')
          #
          # Below checks pandas version
          # "if" branch has code that is expected to work
          # "else" has the workaround for versions strictly lower than pandas 1.5.0
          pandas_version_with_bugfix = _check_soft_dependencies(
              "pandas>=1.5.0", severity="none"
          )
          if pandas_version_with_bugfix:
              relative = absolute - cutoff
          else:
              relative = pd.Index(
                  [date - cutoff[0] for date in absolute]
              )
  
          # Coerce durations (time deltas) into integer values for given frequency
          if isinstance(absolute, (pd.PeriodIndex, pd.DatetimeIndex)):
              relative = _coerce_duration_to_int(relative, freq=fh.freq)
  
          return fh._new(relative, is_relative=True, freq=fh.freq)
  
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 5 for calling a global function with example usage: _to_relative(fh, cutoff) and returns: fh, fh