code: def cramers_v(
      preds: Tensor,
      target: Tensor,
      bias_correction: bool = True,
      nan_strategy: Literal["replace", "drop"] = "replace",
      nan_replace_value: Optional[float] = 0.0,
  ) -> Tensor:
      r"""Compute `Cramer's V`_ statistic measuring the association between two categorical (nominal) data series.
  
      .. math::
          V = \sqrt{\frac{\chi^2 / n}{\min(r - 1, k - 1)}}
  
      where
  
      .. math::
          \chi^2 = \sum_{i,j} \ frac{\left(n_{ij} - \frac{n_{i.} n_{.j}}{n}\right)^2}{\frac{n_{i.} n_{.j}}{n}}
  
      where :math:`n_{ij}` denotes the number of times the values :math:`(A_i, B_j)` are observed with :math:`A_i, B_j`
      represent frequencies of values in ``preds`` and ``target``, respectively.
  
      Cramer's V is a symmetric coefficient, i.e. :math:`V(preds, target) = V(target, preds)`.
  
      The output values lies in [0, 1] with 1 meaning the perfect association.
  
      Args:
          preds: 1D or 2D tensor of categorical (nominal) data
              - 1D shape: (batch_size,)
              - 2D shape: (batch_size, num_classes)
          target: 1D or 2D tensor of categorical (nominal) data
              - 1D shape: (batch_size,)
              - 2D shape: (batch_size, num_classes)
          bias_correction: Indication of whether to use bias correction.
          nan_strategy: Indication of whether to replace or drop ``NaN`` values
          nan_replace_value: Value to replace ``NaN``s when ``nan_strategy = 'replace'``
  
      Returns:
          Cramer's V statistic
  
      Example:
          >>> from torchmetrics.functional.nominal import cramers_v
          >>> _ = torch.manual_seed(42)
          >>> preds = torch.randint(0, 4, (100,))
          >>> target = torch.round(preds + torch.randn(100)).clamp(0, 4)
          >>> cramers_v(preds, target)
          tensor(0.5284)
  
      """
      _nominal_input_validation(nan_strategy, nan_replace_value)
      num_classes = len(torch.cat([preds, target]).unique())
      confmat = _cramers_v_update(
          preds, target, num_classes, nan_strategy, nan_replace_value
      )
      return _cramers_v_compute(confmat, bias_correction)
  
file_path: torchmetrics/src/torchmetrics/functional/nominal/cramers.py
imports: import itertools
  from typing import Optional
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.classification.confusion_matrix import _multiclass_confusion_matrix_update
  from torchmetrics.functional.nominal.utils import _compute_bias_corrected_values, _compute_chi_squared, _drop_empty_rows_and_cols, _handle_nan_in_data, _nominal_input_validation, _unable_to_use_bias_correction_warning
label_desc: Use image node_id 3 for calling a global function with example usage: cramers_v(preds, target, bias_correction, nan_strategy, nan_replace_value) and returns: _cramers_v_compute