code: def multi_index_df_to_component_dfs(multi_index_df, rid="rid", cid="cid"):
      rids = list(multi_index_df.index.get_level_values(rid))
      cids = list(multi_index_df.columns.get_level_values(cid))
      if isinstance(multi_index_df.index, pd.MultiIndex):
          if len(multi_index_df.index.names) > 1:
              mi_df_index = multi_index_df.index.droplevel(rid)
              rhds = list(mi_df_index.names)
              row_metadata = np.array([mi_df_index.get_level_values(level).values for level in list(rhds)]).T
          else:
              rhds = []
              row_metadata = []
      else:
          rhds = []
          row_metadata = []
      if isinstance(multi_index_df.columns, pd.MultiIndex):
          if len(multi_index_df.columns.names) > 1:
              mi_df_columns = multi_index_df.columns.droplevel(cid)
              chds = list(mi_df_columns.names)
              col_metadata = np.array([mi_df_columns.get_level_values(level).values for level in list(chds)]).T
          else:
              chds = []
              col_metadata = []
      else:
          chds = []
          col_metadata = []
      row_metadata_df = pd.DataFrame.from_records(row_metadata, index=pd.Index(rids, name="rid"), columns=pd.Index(rhds, name="rhd"))
      col_metadata_df = pd.DataFrame.from_records(col_metadata, index=pd.Index(cids, name="cid"), columns=pd.Index(chds, name="chd"))
      data_df = pd.DataFrame(multi_index_df.values, index=pd.Index(rids, name="rid"), columns=pd.Index(cids, name="cid"))
      return data_df, row_metadata_df, col_metadata_df