class_docstr: Tester class for `BinaryFairness` metrich overriding some defaults.
docstr: Test if a metric is differentiable or not.
  
  Args:
      preds: torch tensor with predictions
      target: torch tensor with targets
      metric_module: the metric module to test
      metric_functional: functional version of the metric
      metric_args: dict with additional arguments used for class initialization
      groups: Tensor with group identifiers. The group identifiers should be ``0, 1, ..., (num_groups - 1)``.
code: def run_differentiability_test(
      preds: Tensor,
      target: Tensor,
      metric_module: Metric,
      metric_functional: Optional[Callable] = None,
      metric_args: Optional[dict] = None,
      groups: Optional[Tensor] = None,
  ) -> None:
      """Test if a metric is differentiable or not.
  
      Args:
          preds: torch tensor with predictions
          target: torch tensor with targets
          metric_module: the metric module to test
          metric_functional: functional version of the metric
          metric_args: dict with additional arguments used for class initialization
          groups: Tensor with group identifiers. The group identifiers should be ``0, 1, ..., (num_groups - 1)``.
  
      """
      metric_args = metric_args or {}
      # only floating point tensors can require grad
      metric = metric_module(**metric_args)
      if preds.is_floating_point():
          preds.requires_grad = True
          out = metric(
              preds[0, :2],
              target[0, :2],
              groups[0, :2] if groups is not None else None,
          )
  
          # Check if requires_grad matches is_differentiable attribute
          _assert_requires_grad(metric, out)
  
          if metric.is_differentiable and metric_functional is not None:
              # check for numerical correctness
              assert torch.autograd.gradcheck(
                  partial(metric_functional, **metric_args),
                  (preds[0, :2].double(), target[0, :2]),
              )
  
          # reset as else it will carry over to other tests
          preds.requires_grad = False
  
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 BinaryFairnessTester obj's underlying member method code with example usage: obj.run_differentiability_test(preds, target, metric_module, metric_functional, metric_args, groups) without return types