def l1_loss(pred, target):
    """
    L1 Loss.

    Args:
        pred (:obj:`torch.Tensor`): The predictions.
        target (:obj:`torch.Tensor`): The learning targets.

    Returns:
        :obj:`torch.Tensor`: The loss tensor.
    """
    if target.numel() == 0:
        return pred.sum() * 0

    assert pred.size() == target.size()
    loss = (pred - target).abs()

    return loss