code: def _multilabel_precision_recall_curve_update(
      preds: Tensor,
      target: Tensor,
      num_labels: int,
      thresholds: Optional[Tensor],
  ) -> Union[Tensor, Tuple[Tensor, Tensor]]:
      """Return the state to calculate the pr-curve with.
  
      If thresholds is `None` the direct preds and targets are used. If thresholds is not `None` we compute a multi
      threshold confusion matrix.
  
      """
      if thresholds is None:
          return preds, target
      len_t = len(thresholds)
      # num_samples x num_labels x num_thresholds
      preds_t = (
          preds.unsqueeze(-1) >= thresholds.unsqueeze(0).unsqueeze(0)
      ).long()
      unique_mapping = preds_t + 2 * target.long().unsqueeze(-1)
      unique_mapping += 4 * torch.arange(
          num_labels, device=preds.device
      ).unsqueeze(0).unsqueeze(-1)
      unique_mapping += (
          4 * num_labels * torch.arange(len_t, device=preds.device)
      )
      unique_mapping = unique_mapping[unique_mapping >= 0]
      bins = _bincount(unique_mapping, minlength=4 * num_labels * len_t)
      return bins.reshape(len_t, num_labels, 2, 2)
  
imports: from typing import List, Optional, Sequence, Tuple, Union
  import torch
  from torch import Tensor, tensor
  from torch.nn import functional
  from typing_extensions import Literal
  from torchmetrics.utilities.checks import _check_same_shape
  from torchmetrics.utilities.compute import _safe_divide, interp
  from torchmetrics.utilities.data import _bincount, _cumsum
  from torchmetrics.utilities.enums import ClassificationTask
label_desc: Use image node_id 22 for calling a global function with example usage: _multilabel_precision_recall_curve_update(preds, target, num_labels, thresholds) and returns: bins, preds,  target