code: def transform_feature_balance_measures(
      dfs: Dict[str, pd.DataFrame]
  ) -> Dict[str, Dict[str, Any]]:
      """
      Transform the dict of <positive label, feature balance measures DataFrame>
      pairs into a dictionary acceptable by the RAI dashboard.
  
      :param dfs: A dict of <positive label, measure DataFrame> pairs.
      :type dfs: Dict[str, pd.DataFrame]
      :return: A dictionary of feature balance measures.
      :rtype: Dict[str, Dict[str, Any]]
      """
      all_measures: Dict[str, Dict[str, Any]] = {}
  
      try:
          for pos_label, df in dfs.items():
              measures: Dict[str, Dict[str, Any]] = {}
              rows: List[Any] = df.reset_index(drop=True).to_dict(
                  orient="records"
              )
  
              # Transform { "FeatureName": "Col1", "MeasureA": 0.5, ... } to
              # { "Col1": { "MeasureA": 0.5, ... } }
              # which allows us to treat FeatureNames as the keys of the dict
              for row in rows:
                  feature_name: str = row.pop(
                      Constants.FEATURE_NAME.value
                  )
  
                  if feature_name not in measures:
                      measures[feature_name] = []
  
                  measures[feature_name].append(row)
  
              all_measures[pos_label] = measures
      except Exception as e:
          # Warning instead of error so that other measures can be computed
          warnings.warn(
              f"Failed to transform feature measures due to {e!r}."
          )
  
      return all_measures
  
file_path: responsible-ai-toolbox/responsibleai/responsibleai/databalanceanalysis/data_balance_utils.py
imports: import warnings
  from typing import Any, Dict, List
  import pandas
  from responsibleai.databalanceanalysis.constants import Constants
label_desc: Use image node_id 3 for calling a global function with example usage: transform_feature_balance_measures(dfs) and returns: all_measures