def get_multilabel_statistics(
    outputs: Tensor, targets: Tensor
) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor, int]:
    """
    Computes the number of true negative, false positive,
    false negative, true positive and support
    for a multilabel classification problem.

    Args:
        outputs: estimated targets as predicted by a model
            with shape [bs; ..., (num_classes or 1)]
        targets: ground truth (correct) target values
            with shape [bs; ..., 1]

    Returns:
        Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]: stats

    Examples:

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[0, 0, 1, 1], [0, 1, 0, 1]])
        y_true = torch.tensor([[0, 1, 0, 1], [0, 0, 1, 1]])
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 0., 0., 0.]),
        #     tensor([0., 1., 1., 0.]),
        #     tensor([0., 1., 1., 0.]),
        #     tensor([0., 0., 0., 2.]),
        #     tensor([0., 1., 1., 2.]),
        # )

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
        y_true = torch.tensor([0, 1, 2])
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 2., 2.]),
        #     tensor([0., 0., 0.]),
        #     tensor([0., 0., 0.]),
        #     tensor([1., 1., 1.]),
        #     tensor([1., 1., 1.]),
        # )

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
        y_true = torch.nn.functional.one_hot(torch.tensor([0, 1, 2]))
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 2., 2.]),
        #     tensor([0., 0., 0.]),
        #     tensor([0., 0., 0.]),
        #     tensor([1., 1., 1.]),
        #     tensor([1., 1., 1.]),
        # )

    """
    outputs, targets, _, num_classes = process_multilabel_components(
        outputs=outputs, targets=targets
    )
    assert outputs.shape == targets.shape
    num_classes = outputs.shape[-1]

    tn = torch.zeros((num_classes,), device=outputs.device)
    fp = torch.zeros((num_classes,), device=outputs.device)
    fn = torch.zeros((num_classes,), device=outputs.device)
    tp = torch.zeros((num_classes,), device=outputs.device)
    support = torch.zeros((num_classes,), device=outputs.device)

    for class_index in range(num_classes):
        class_outputs = outputs[..., class_index]
        class_targets = targets[..., class_index]
        (
            tn[class_index],
            fp[class_index],
            fn[class_index],
            tp[class_index],
            support[class_index],
        ) = get_binary_statistics(outputs=class_outputs, targets=class_targets, label=1)

    return tn, fp, fn, tp, support, num_classes

    Computes the number of true negative, false positive,
    false negative, true positive and support
    for a multilabel classification problem.

    Args:
        outputs: estimated targets as predicted by a model
            with shape [bs; ..., (num_classes or 1)]
        targets: ground truth (correct) target values
            with shape [bs; ..., 1]

    Returns:
        Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]: stats

    Examples:

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[0, 0, 1, 1], [0, 1, 0, 1]])
        y_true = torch.tensor([[0, 1, 0, 1], [0, 0, 1, 1]])
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 0., 0., 0.]),
        #     tensor([0., 1., 1., 0.]),
        #     tensor([0., 1., 1., 0.]),
        #     tensor([0., 0., 0., 2.]),
        #     tensor([0., 1., 1., 2.]),
        # )

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
        y_true = torch.tensor([0, 1, 2])
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 2., 2.]),
        #     tensor([0., 0., 0.]),
        #     tensor([0., 0., 0.]),
        #     tensor([1., 1., 1.]),
        #     tensor([1., 1., 1.]),
        # )

    .. code-block:: python

        import torch
        from catalyst import metrics
        y_pred = torch.tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
        y_true = torch.nn.functional.one_hot(torch.tensor([0, 1, 2]))
        tn, fp, fn, tp, support = metrics.get_multilabel_statistics(y_pred, y_true)
        # (
        #     tensor([2., 2., 2.]),
        #     tensor([0., 0., 0.]),
        #     tensor([0., 0., 0.]),
        #     tensor([1., 1., 1.]),
        #     tensor([1., 1., 1.]),
        # )

    
catalyst/metrics/functional/_misc.py