code: def calculate_ratio(sub_confusion_matrix_metrics, privileged):
      """
      Calculates ratio of metrics - divides all by privileged
      Does not allow for zeros in ratios, instead puts NaN
      """
      assert isinstance(
          sub_confusion_matrix_metrics, SubgroupConfusionMatrixMetrics
      )
      df = sub_confusion_matrix_metrics.to_horizontal_DataFrame()
  
      privileged_index = np.where(df.index.values == privileged)[0][0]
      df_ratio = df / df.iloc[privileged_index, :]
      df_ratio = df_ratio.to_numpy()
      df_ratio[df_ratio == 0] = np.nan
      df_ratio[np.isinf(df_ratio)] = np.nan
      df_out = pd.DataFrame(
          df_ratio, index=df.index.values, columns=df.columns
      )
      return df_out
  
imports: from copy import deepcopy
  import numpy
  import pandas
  from .None import checks
  from ...None import _global_checks
  from ..._explainer import helper
  from ...model_explanations._model_performance import utils
label_desc: Use image node_id 2 for calling a global function with example usage: calculate_ratio(sub_confusion_matrix_metrics, privileged) and returns: df_out