code: def relativize_data(
      data: Data,
      status_quo_name: str = "status_quo",
      as_percent: bool = False,
      include_sq: bool = False,
      bias_correction: bool = True,
      control_as_constant: bool = False,
  ) -> Data:
      """Relativize a data object w.r.t. a status_quo arm.
  
      Args:
          data: The data object to be relativized.
          status_quo_name: The name of the status_quo arm.
          as_percent: If True, return results as percentage change.
          include_sq: Include status quo in final df.
          bias_correction: Whether to apply bias correction when computing relativized
              metric values. Uses a second-order Taylor expansion for approximating
              the means and standard errors or the ratios, see
              ax.utils.stats.statstools.relativize for more details.
          control_as_constant: If true, control is treated as a constant.
              bias_correction is ignored when this is true.
  
      Returns:
          The new data object with the relativized metrics (excluding the
              status_quo arm)
  
      """
      df = data.df.copy()
      grp_cols = list(
          {"trial_index", "metric_name", "random_split"}.intersection(
              df.columns.values
          )
      )
  
      grouped_df = df.groupby(grp_cols)
      dfs = []
      for grp in grouped_df.groups.keys():
          subgroup_df = grouped_df.get_group(grp)
          is_sq = subgroup_df["arm_name"] == status_quo_name
          sq_mean, sq_sem = subgroup_df[is_sq][
              ["mean", "sem"]
          ].values.flatten()
  
          # rm status quo from final df to relativize
          if not include_sq:
              subgroup_df = subgroup_df[~is_sq]
          means_rel, sems_rel = relativize(
              means_t=subgroup_df["mean"].values,
              sems_t=subgroup_df["sem"].values,
              mean_c=sq_mean,
              sem_c=sq_sem,
              as_percent=as_percent,
              bias_correction=bias_correction,
              control_as_constant=control_as_constant,
          )
          dfs.append(
              pd.concat(
                  [
                      subgroup_df.drop(["mean", "sem"], axis=1),
                      pd.DataFrame(
                          np.array([means_rel, sems_rel]).T,
                          columns=["mean", "sem"],
                          index=subgroup_df.index,
                      ),
                  ],
                  axis=1,
              )
          )
      df_rel = pd.concat(dfs, axis=0)
      if include_sq:
          df_rel.loc[df_rel["arm_name"] == status_quo_name, "sem"] = 0.0
      return Data(df_rel)
  
file_path: Ax/ax/utils/stats/statstools.py
imports: from logging import Logger
  from typing import List, Tuple, Union
  import numpy
  import pandas
  from ax.core.data import Data
  from ax.utils.common.logger import get_logger
label_desc: Use image node_id 8 for calling a global function with example usage: relativize_data(data, status_quo_name, as_percent, include_sq, bias_correction, control_as_constant) and returns: Data