class_docstr: Test class for `BinaryFairness` metric.
docstr: Test class implementation of metric.
code: def test_binary_fairness(self, ddp, inputs, ignore_index):
      """Test class implementation of metric."""
      preds, target, groups = inputs
      if ignore_index == -1:
          target = inject_ignore_index(target, ignore_index)
  
      self.run_class_metric_test(
          ddp=ddp,
          preds=preds,
          target=target,
          metric_class=BinaryFairness,
          reference_metric=partial(
              _fairlearn_binary, ignore_index=ignore_index
          ),
          metric_args={
              "threshold": THRESHOLD,
              "ignore_index": ignore_index,
              "num_groups": 2,
              "task": "all",
          },
          groups=groups,
          fragment_kwargs=True,
      )
  
imports: import inspect
  from functools import partial
  from typing import Any, Callable, Dict, Optional
  from unittest import mock
  import numpy
  import pandas
  import pytest
  import torch
  from fairlearn.metrics import MetricFrame, selection_rate, true_positive_rate
  from scipy.special import expit
  from torch import Tensor
  from torchmetrics import Metric
  from torchmetrics.classification.group_fairness import BinaryFairness
  from torchmetrics.functional.classification.group_fairness import binary_fairness
  from torchmetrics.utilities.imports import _PYTHON_LOWER_3_8
  from unittests import THRESHOLD
  from unittests.classification.inputs import _group_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, _assert_dtype_support, inject_ignore_index, remove_ignore_index_groups
  from unittests.helpers.testers import _assert_allclose
  from unittests.helpers.testers import _assert_requires_grad
  from unittests.helpers.testers import _assert_tensor
label_desc: Use image node_id 1 for calling the TestBinaryFairness obj's underlying member method code with example usage: obj.test_binary_fairness(ddp, inputs, ignore_index) without return types