code: def _check_freq(obj):
      """Coerce obj to a pandas frequency offset for the ForecastingHorizon.
  
      Parameters
      ----------
      obj : pd.Index, pd.Period, pandas offset, or None
  
      Returns
      -------
      pd offset
  
      Raises
      ------
      TypeError if the type assumption on obj is not met
      """
      if isinstance(obj, pd.offsets.BaseOffset):
          return obj
      elif hasattr(obj, "cutoff"):
          return _check_freq(obj.cutoff)
      elif isinstance(obj, (pd.Period, pd.Index)):
          return _extract_freq_from_cutoff(obj)
      elif isinstance(obj, str) or obj is None:
          return to_offset(obj)
      else:
          return None
  
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 3 for calling a global function with example usage: _check_freq(obj) and returns: obj, _check_freq, _extract_freq_from_cutoff, to_offset, None