code: def ratio(
      func,
      y_true,
      y_pred=None,
      prot_attr=None,
      priv_group=1,
      sample_weight=None,
      zero_division="warn",
      **kwargs,
  ):
      """Compute the ratio between unprivileged and privileged subsets for an
      arbitrary metric.
  
      Note: The optimal value of a ratio is 1. To make it a scorer, one must
      take the minimum of the ratio and its inverse.
  
      Unprivileged group is taken to be the inverse of the privileged group.
  
      Args:
          func (function): A metric function from :mod:`sklearn.metrics` or
              :mod:`aif360.sklearn.metrics`.
          y_true (pandas.Series): Outcome vector with protected attributes as
              index.
          y_pred (array-like, optional): Estimated outcomes.
          prot_attr (array-like, keyword-only): Protected attribute(s). If
              ``None``, all protected attributes in y are used.
          priv_group (scalar, optional): The label of the privileged group.
          sample_weight (array-like, optional): Sample weights passed through to
              func.
          zero_division ('warn', 0 or 1): Sets the value to return when there is a
              zero division. If set to “warn”, this acts as 0, but warnings are
              also raised.
          **kwargs: Additional keyword args to be passed through to func.
  
      Returns:
          scalar: Ratio of metric values for unprivileged and privileged groups.
      """
      _check_zero_division(zero_division)
      groups, _ = check_groups(y_true, prot_attr)
      idx = groups == priv_group
      unpriv = [y[~idx] for y in (y_true, y_pred) if y is not None]
      priv = [y[idx] for y in (y_true, y_pred) if y is not None]
      if sample_weight is not None:
          sample_weight = np.asarray(sample_weight)
          numerator = func(
              *unpriv, sample_weight=sample_weight[~idx], **kwargs
          )
          denominator = func(
              *priv, sample_weight=sample_weight[idx], **kwargs
          )
      else:
          numerator = func(*unpriv, **kwargs)
          denominator = func(*priv, **kwargs)
  
      if func == base_rate:
          modifier = "positive privileged"
      elif func == selection_rate:
          modifier = "predicted privileged"
      else:
          modifier = f"value for {func.__name__} on privileged"
      return _prf_divide(
          np.array([numerator]),
          np.array([denominator]),
          "ratio",
          modifier,
          None,
          ("ratio",),
          zero_division,
      ).item()
  
imports: from itertools import permutations
  from typing import Union
  import warnings
  import numpy
  import pandas
  from scipy.special import rel_entr
  from sklearn.metrics import make_scorer, recall_score, precision_score
  from sklearn.metrics import multilabel_confusion_matrix
  from sklearn.metrics._classification import _prf_divide, _check_zero_division
  from sklearn.neighbors import NearestNeighbors
  from sklearn.utils import check_X_y
  from aif360.metrics import ot_metric
  from aif360.sklearn.utils import check_inputs, check_groups
  from aif360.detectors.mdss.ScoringFunctions import BerkJones, Bernoulli
  from aif360.detectors.mdss.MDSS import MDSS
label_desc: Use image node_id 2 for calling a global function with example usage: ratio(func, y_true, y_pred, prot_attr, priv_group, sample_weight, zero_division) and returns: _prf_divide