class_docstr: Test class for all metrics.
  
  Class used for efficiently run a lot of parametrized tests in DDP mode. Makes sure that DDP is only setup once and
  that pool of processes are used for all tests. All tests should subclass from this and implement a new method called
  ``test_metric_name`` where the method ``self.run_metric_test`` is called inside.
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
docstr_tok: ["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"]
code: def run_differentiability_test(
      preds: Tensor,
      target: Tensor,
      metric_module: Metric,
      metric_functional: Optional[Callable] = None,
      metric_args: Optional[dict] = 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
  
      """
      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])
  
          # 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 pickle
  import sys
  from copy import deepcopy
  from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  import pytest
  import torch
  from lightning_utilities import apply_to_collection
  from torch import Tensor, tensor
  from torchmetrics import Metric
  from torchmetrics.utilities.data import _flatten
  from unittests import NUM_PROCESSES
label_desc: Use image node_id 5 for calling the MetricTester obj's underlying member method code with example usage: obj.run_differentiability_test(preds, target, metric_module, metric_functional, metric_args) without return types