code: def test_missing_sensitive_feature_combinations(metric_fn):
      target = metrics.MetricFrame(
          metrics=metric_fn,
          y_true=y_t,
          y_pred=y_p,
          sensitive_features=np.stack([g_A, g_B], axis=1),
      )
  
      # Make sure our missing combination is in an expected place
      overall = metric_fn(y_t, y_p)
      direct_eval = []
      for idx in target.by_group.index:
          mask_A = g_A == idx[0]
          mask_B = g_B == idx[1]
          mask = np.logical_and(mask_A, mask_B)
          if idx == ("bb", "x"):
              assert sum(mask) == 0, "idx={0}".format(idx)
          else:
              assert sum(mask) != 0, "idx={0}".format(idx)
              nxt = metric_fn(y_t[mask], y_p[mask])
              direct_eval.append(nxt)
      assert len(direct_eval) == 5
  
      # Check we have expected values
      assert np.isnan(target.by_group[("bb", "x")])
      assert target.group_min() == min(direct_eval)
      assert target.group_max() == max(direct_eval)
      assert target.difference(method="between_groups") == max(
          direct_eval
      ) - min(direct_eval)
      assert target.difference(method="to_overall") == max(
          [abs(x - overall) for x in direct_eval]
      )
      assert target.ratio(method="between_groups") == min(
          direct_eval
      ) / max(direct_eval)
      assert target.ratio(method="to_overall") == min(
          [x / overall for x in direct_eval]
          + [overall / x for x in direct_eval]
      )
  
imports: import numpy
  import pytest
  import sklearn.metrics
  import fairlearn.metrics
  from .data_for_test import g_1, group_gen, y_p, y_t
label_desc: Use image node_id 1 for calling a global function with example usage: test_missing_sensitive_feature_combinations(metric_fn) without return types