code: def multilabel_jaccard_index(
      preds: Tensor,
      target: Tensor,
      num_labels: int,
      threshold: float = 0.5,
      average: Optional[
          Literal["micro", "macro", "weighted", "none"]
      ] = "macro",
      ignore_index: Optional[int] = None,
      validate_args: bool = True,
  ) -> Tensor:
      r"""Calculate the Jaccard index for multilabel tasks.
  
      The `Jaccard index`_ (also known as the intersetion over union or jaccard similarity coefficient) is an statistic
      that can be used to determine the similarity and diversity of a sample set. It is defined as the size of the
      intersection divided by the union of the sample sets:
  
      .. math:: J(A,B) = \frac{|A\cap B|}{|A\cup B|}
  
      Accepts the following input tensors:
  
      - ``preds`` (int or float tensor): ``(N, C, ...)``. If preds is a floating point tensor with values outside
        [0,1] range we consider the input to be logits and will auto apply sigmoid per element. Additionally,
        we convert to int tensor with thresholding using the value in ``threshold``.
      - ``target`` (int tensor): ``(N, C, ...)``
  
      Additional dimension ``...`` will be flattened into the batch dimension.
  
      Args:
          preds: Tensor with predictions
          target: Tensor with true labels
          num_labels: Integer specifying the number of labels
          threshold: Threshold for transforming probability to binary (0,1) predictions
          average:
              Defines the reduction that is applied over labels. Should be one of the following:
  
              - ``micro``: Sum statistics over all labels
              - ``macro``: Calculate statistics for each label and average them
              - ``weighted``: calculates statistics for each label and computes weighted average using their support
              - ``"none"`` or ``None``: calculates statistic for each label and applies no reduction
  
          ignore_index:
              Specifies a target value that is ignored and does not contribute to the metric calculation
          validate_args: bool indicating if input arguments and tensors should be validated for correctness.
              Set to ``False`` for faster computations.
          kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
      Example (preds is int tensor):
          >>> from torch import tensor
          >>> from torchmetrics.functional.classification import multilabel_jaccard_index
          >>> target = tensor([[0, 1, 0], [1, 0, 1]])
          >>> preds = tensor([[0, 0, 1], [1, 0, 1]])
          >>> multilabel_jaccard_index(preds, target, num_labels=3)
          tensor(0.5000)
  
      Example (preds is float tensor):
          >>> from torchmetrics.functional.classification import multilabel_jaccard_index
          >>> target = tensor([[0, 1, 0], [1, 0, 1]])
          >>> preds = tensor([[0.11, 0.22, 0.84], [0.73, 0.33, 0.92]])
          >>> multilabel_jaccard_index(preds, target, num_labels=3)
          tensor(0.5000)
  
      """
      if validate_args:
          _multilabel_jaccard_index_arg_validation(
              num_labels, threshold, ignore_index
          )
          _multilabel_confusion_matrix_tensor_validation(
              preds, target, num_labels, ignore_index
          )
      preds, target = _multilabel_confusion_matrix_format(
          preds, target, num_labels, threshold, ignore_index
      )
      confmat = _multilabel_confusion_matrix_update(
          preds, target, num_labels
      )
      return _jaccard_index_reduce(
          confmat, average=average, ignore_index=ignore_index
      )
  
file_path: torchmetrics/src/torchmetrics/functional/classification/jaccard.py
imports: from typing import Optional
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.classification.confusion_matrix import _binary_confusion_matrix_arg_validation, _binary_confusion_matrix_format, _binary_confusion_matrix_tensor_validation, _binary_confusion_matrix_update, _multiclass_confusion_matrix_arg_validation, _multiclass_confusion_matrix_format, _multiclass_confusion_matrix_tensor_validation, _multiclass_confusion_matrix_update, _multilabel_confusion_matrix_arg_validation, _multilabel_confusion_matrix_format, _multilabel_confusion_matrix_tensor_validation, _multilabel_confusion_matrix_update
  from torchmetrics.utilities.compute import _safe_divide
  from torchmetrics.utilities.enums import ClassificationTask
label_desc: Use image node_id 6 for calling a global function with example usage: multilabel_jaccard_index(preds, target, num_labels, threshold, average, ignore_index, validate_args) and returns: _jaccard_index_reduce