code: def fetch_df_by_index(
      df: pd.DataFrame,
      selector: Union[pd.Timestamp, slice, str, list, pd.Index],
      level: Union[str, int],
      fetch_orig=True,
  ) -> pd.DataFrame:
      """
      fetch data from `data` with `selector` and `level`
  
      selector are assumed to be well processed.
      `fetch_df_by_index` is only responsible for get the right level
  
      Parameters
      ----------
      selector : Union[pd.Timestamp, slice, str, list]
          selector
      level : Union[int, str]
          the level to use the selector
  
      Returns
      -------
      Data of the given index.
      """
      # level = None -> use selector directly
      if level is None or isinstance(selector, pd.MultiIndex):
          return df.loc(axis=0)[selector]
      # Try to get the right index
      idx_slc = (selector, slice(None, None))
      if get_level_index(df, level) == 1:
          idx_slc = idx_slc[1], idx_slc[0]
      if fetch_orig:
          for slc in idx_slc:
              if slc != slice(None, None):
                  return df.loc[pd.IndexSlice[idx_slc],]  # noqa: E231
          else:  # pylint: disable=W0120
              return df
      else:
          return df.loc[pd.IndexSlice[idx_slc],]
  
file_path: qlib/qlib/data/dataset/utils.py
imports: from __future__ import annotations
  import pandas
  from typing import Union, List, TYPE_CHECKING
  from qlib.utils import init_instance_by_config
label_desc: Use image node_id 2 for calling a global function with example usage: fetch_df_by_index(df, selector, level, fetch_orig) and returns: df, df, df, df