class_docstr: Tester class for text.
  
  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 for text metrics should subclass from this and implement
  a new method called `test_metric_name` where the method `self.run_metric_test` is called inside.
docstr: Core method that should be used for testing functions. Call this inside testing method.
  
  Args:
      preds: torch tensor with predictions
      targets: torch tensor with targets
      metric_functional: metric class that should be tested
      reference_metric: callable function that is used for comparison
      metric_args: dict with additional arguments used for class initialization
      fragment_kwargs: whether tensors in kwargs should be divided as `preds` and `targets` among processes
      key: The key passed onto the `_assert_allclose` to compare the respective metric from the Dict output
          against the ref_metric.
      kwargs_update: Additional keyword arguments that will be passed with preds and
          targets when running update on the metric.
docstr_tok: ["Core","method","that","should","be","used","for","testing","functions",".","Call","this","inside","testing","method",".","Args",":","preds",":","torch","tensor","with","predictions","targets",":","torch","tensor","with","targets","metric_functional",":","metric","class","that","should","be","tested","reference_metric",":","callable","function","that","is","used","for","comparison","metric_args",":","dict","with","additional","arguments","used","for","class","initialization","fragment_kwargs",":","whether","tensors","in","kwargs","should","be","divided","as","`","preds","`","and","`","targets","`","among","processes","key",":","The","key","passed","onto","the","`","_assert_allclose","`","to","compare","the","respective","metric","from","the","Dict","output","against","the","ref_metric",".","kwargs_update",":","Additional","keyword","arguments","that","will","be","passed","with","preds","and","targets","when","running","update","on","the","metric","."]
code: def run_functional_metric_test(
      self,
      preds: TEXT_METRIC_INPUT,
      targets: TEXT_METRIC_INPUT,
      metric_functional: Callable,
      reference_metric: Callable,
      metric_args: Optional[dict] = None,
      fragment_kwargs: bool = False,
      key: Optional[str] = None,
      **kwargs_update: Any,
  ):
      """Core method that should be used for testing functions. Call this inside testing method.
  
      Args:
          preds: torch tensor with predictions
          targets: torch tensor with targets
          metric_functional: metric class that should be tested
          reference_metric: callable function that is used for comparison
          metric_args: dict with additional arguments used for class initialization
          fragment_kwargs: whether tensors in kwargs should be divided as `preds` and `targets` among processes
          key: The key passed onto the `_assert_allclose` to compare the respective metric from the Dict output
              against the ref_metric.
          kwargs_update: Additional keyword arguments that will be passed with preds and
              targets when running update on the metric.
  
      """
      device = (
          "cuda"
          if (
              torch.cuda.is_available()
              and torch.cuda.device_count() > 0
          )
          else "cpu"
      )
  
      _functional_test(
          preds=preds,
          targets=targets,
          metric_functional=metric_functional,
          ref_metric=reference_metric,
          metric_args=metric_args,
          atol=self.atol,
          device=device,
          fragment_kwargs=fragment_kwargs,
          key=key,
          **kwargs_update,
      )
  
imports: import pickle
  import sys
  from functools import partial, wraps
  from typing import Any, Callable, Dict, Optional, Sequence, Union
  import numpy
  import pytest
  import torch
  from torch import Tensor
  from torchmetrics import Metric
  from unittests import NUM_PROCESSES
  from unittests.helpers.testers import MetricTester, _assert_allclose, _assert_requires_grad, _assert_tensor
label_desc: Use image node_id 1 for calling the TextTester obj's underlying member method code with example usage: obj.run_functional_metric_test(preds, targets, metric_functional, reference_metric, metric_args, fragment_kwargs, key) without return types