code: def _hamming_distance_reduce(
      tp: Tensor,
      fp: Tensor,
      tn: Tensor,
      fn: Tensor,
      average: Optional[
          Literal["binary", "micro", "macro", "weighted", "none"]
      ],
      multidim_average: Literal["global", "samplewise"] = "global",
      multilabel: bool = False,
  ) -> Tensor:
      """Reduce classification statistics into hamming distance.
  
      Args:
          tp: number of true positives
          fp: number of false positives
          tn: number of true negatives
          fn: number of false negatives
          average:
              Defines the reduction that is applied over labels. Should be one of the following:
  
              - ``binary``: for binary reduction
              - ``micro``: sum score over all classes/labels
              - ``macro``: salculate score for each class/label and average them
              - ``weighted``: calculates score for each class/label and computes weighted average using their support
              - ``"none"`` or ``None``: calculates score for each class/label and applies no reduction
  
          multidim_average:
              Defines how additionally dimensions ``...`` should be handled. Should be one of the following:
  
              - ``global``: Additional dimensions are flatted along the batch dimension
              - ``samplewise``: Statistic will be calculated independently for each sample on the ``N`` axis.
  
          multilabel: If input is multilabel or not
  
      """
      if average == "binary":
          return 1 - _safe_divide(tp + tn, tp + fp + tn + fn)
      if average == "micro":
          tp = tp.sum(dim=0 if multidim_average == "global" else 1)
          fn = fn.sum(dim=0 if multidim_average == "global" else 1)
          if multilabel:
              fp = fp.sum(dim=0 if multidim_average == "global" else 1)
              tn = tn.sum(dim=0 if multidim_average == "global" else 1)
              return 1 - _safe_divide(tp + tn, tp + tn + fp + fn)
          return 1 - _safe_divide(tp, tp + fn)
  
      score = (
          1 - _safe_divide(tp + tn, tp + tn + fp + fn)
          if multilabel
          else 1 - _safe_divide(tp, tp + fn)
      )
      return _adjust_weights_safe_divide(
          score, average, multilabel, tp, fp, fn
      )
  
file_path: torchmetrics/src/torchmetrics/functional/classification/hamming.py
imports: from typing import Optional
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.classification.stat_scores import _binary_stat_scores_arg_validation, _binary_stat_scores_format, _binary_stat_scores_tensor_validation, _binary_stat_scores_update, _multiclass_stat_scores_arg_validation, _multiclass_stat_scores_format, _multiclass_stat_scores_tensor_validation, _multiclass_stat_scores_update, _multilabel_stat_scores_arg_validation, _multilabel_stat_scores_format, _multilabel_stat_scores_tensor_validation, _multilabel_stat_scores_update
  from torchmetrics.utilities.compute import _adjust_weights_safe_divide, _safe_divide
  from torchmetrics.utilities.enums import ClassificationTask
label_desc: Use image node_id 1 for calling a global function with example usage: _hamming_distance_reduce(tp, fp, tn, fn, average, multidim_average, multilabel) and returns: _adjust_weights_safe_divide, unknown, unknown, unknown