code: def _infer_freq_from_index(index: pd.Index) -> Optional[str]:
      """Infer frequency string from the pandas index.
  
      Parameters
      ----------
      index : pd.Index
  
      Returns
      -------
      str
          Frequency string inferred from the pandas index,
          or `None`, if inference fails.
      """
      if hasattr(index, "freqstr"):
          return index.freqstr
      else:
          try:
              return pd.infer_freq(index)
          except (TypeError, ValueError):
              return None
  
file_path: sktime/sktime/utils/datetime.py
imports: import warnings
  from functools import singledispatch
  from typing import Optional, Tuple, Union
  import numpy
  import pandas
  from sktime.datatypes import VectorizedDF
  from sktime.datatypes._utilities import get_time_index
  from sktime.utils.validation.series import check_time_index, is_integer_index
label_desc: Use image node_id 8 for calling a global function with example usage: _infer_freq_from_index(index) and returns: index, pd, None