def process_recsys_components(
    outputs: torch.Tensor, targets: torch.Tensor
) -> torch.Tensor:
    """
    General pre-processing for calculation recsys metrics

    Args:
        outputs (torch.Tensor):
            Tensor with predicted scores
            size: [batch_size, slate_length]
            model outputs, logits
        targets (torch.Tensor):
            Binary tensor with ground truth.
            1 means the item is relevant
            for the user and 0 not relevant
            size: [batch_szie, slate_length]
            ground truth, labels

    Returns:
        targets_sorted_by_outputs (torch.Tensor):
            targets tensor sorted by outputs
    """
    check_consistent_length(outputs, targets)
    outputs_order = torch.argsort(outputs, descending=True, dim=-1)
    targets_sorted_by_outputs = torch.gather(targets, dim=-1, index=outputs_order)
    return targets_sorted_by_outputs

    General pre-processing for calculation recsys metrics

    Args:
        outputs (torch.Tensor):
            Tensor with predicted scores
            size: [batch_size, slate_length]
            model outputs, logits
        targets (torch.Tensor):
            Binary tensor with ground truth.
            1 means the item is relevant
            for the user and 0 not relevant
            size: [batch_szie, slate_length]
            ground truth, labels

    Returns:
        targets_sorted_by_outputs (torch.Tensor):
            targets tensor sorted by outputs
    
catalyst/metrics/functional/_misc.py