def mrr(
    outputs: torch.Tensor, targets: torch.Tensor, topk: List[int]
) -> List[torch.Tensor]:
    """
    Calculate the Mean Reciprocal Rank (MRR)
    score given model outputs and targets
    Data aggregated in batches.

    The MRR@k is the mean overall batch of the
    reciprocal rank, that is the rank of the highest
    ranked relevant item, if any in the top *k*, 0 otherwise.
    https://en.wikipedia.org/wiki/Mean_reciprocal_rank

    Args:
        outputs:
            Tensor weith predicted score
            size: [batch_size, slate_length]
            model outputs, logits
        targets:
            Binary tensor with ground truth.
            1 means the item is relevant
            and 0 if it's not relevant
            size: [batch_szie, slate_length]
            ground truth, labels
        topk:
            Parameter fro evaluation on top-k items

    Returns:
        MRR score

    Example:

    .. code-block:: python

        import torch
        from catalyst import metrics
        metrics.mrr(
            outputs=torch.Tensor([
                [4.0, 2.0, 3.0, 1.0],
                [1.0, 2.0, 3.0, 4.0],
            ]),
            targets=torch.Tensor([
                [0, 0, 1.0, 1.0],
                [0, 0, 1.0, 1.0],
            ]),
            topk=[1, 3],
        )
        # [tensor(0.5000), tensor(0.7500)]
    """
    results = []
    for k in topk:
        results.append(torch.mean(reciprocal_rank(outputs, targets, k)))

    return results

    Calculate the Mean Reciprocal Rank (MRR)
    score given model outputs and targets
    Data aggregated in batches.

    The MRR@k is the mean overall batch of the
    reciprocal rank, that is the rank of the highest
    ranked relevant item, if any in the top *k*, 0 otherwise.
    https://en.wikipedia.org/wiki/Mean_reciprocal_rank

    Args:
        outputs:
            Tensor weith predicted score
            size: [batch_size, slate_length]
            model outputs, logits
        targets:
            Binary tensor with ground truth.
            1 means the item is relevant
            and 0 if it's not relevant
            size: [batch_szie, slate_length]
            ground truth, labels
        topk:
            Parameter fro evaluation on top-k items

    Returns:
        MRR score

    Example:

    .. code-block:: python

        import torch
        from catalyst import metrics
        metrics.mrr(
            outputs=torch.Tensor([
                [4.0, 2.0, 3.0, 1.0],
                [1.0, 2.0, 3.0, 4.0],
            ]),
            targets=torch.Tensor([
                [0, 0, 1.0, 1.0],
                [0, 0, 1.0, 1.0],
            ]),
            topk=[1, 3],
        )
        # [tensor(0.5000), tensor(0.7500)]
    
catalyst/metrics/functional/_mrr.py