import torch
from typing import Dict


def parse_margin_ranking_loss(p_out: torch.Tensor,
                              n_out: torch.Tensor,
                              target: torch.Tensor) -> Dict[str, torch.Tensor]:
    """
    Parse positive outputs, negative outputs and target to a dictionary as a kwargs embedder for nn.MarginRankingLoss
    
    Args:
        p_out (T), shape = (B, 1): predicted scores of positive samples
        n_out (T)), shape = (B, N Neg): predicted scores of negative samples
        target (T), shape = (B, N Neg): tensors of ones created by torch.ones_like(n_out)
    
    Returns:
        Dict[str, T]: dictionary to be passed to nn.MarginRankingLoss
    
    Key-Values:
        input1: p_out, shape = (B, 1)
        input2: n_out, shape = (B, N Neg)
        target: target, shape = (B, N Neg)
    """
    return {'input1': p_out, 'input2': n_out, 'target': target}