(loss, reduction)
Reduce loss as specified.

    Args:
        loss (Tensor): Elementwise loss tensor.
        reduction (str): Options are "none", "mean" and "sum".

    Return:
        Tensor: Reduced loss tensor.
Reduce loss as specified.
Reduce loss as specified .
def reduce_loss(loss, reduction):
    """Reduce loss as specified.

    Args:
        loss (Tensor): Elementwise loss tensor.
        reduction (str): Options are "none", "mean" and "sum".

    Return:
        Tensor: Reduced loss tensor.
    """
    reduction_enum = F._Reduction.get_enum(reduction)
    # none: 0, elementwise_mean:1, sum: 2
    if reduction_enum == 0:
        return loss
    elif reduction_enum == 1:
        return loss.mean()
    elif reduction_enum == 2:
        return loss.sum()
def reduce_loss ( loss , reduction ) : reduction_enum = F . _Reduction . get_enum ( reduction ) # none: 0, elementwise_mean:1, sum: 2 if reduction_enum == 0 : return loss elif reduction_enum == 1 : return loss . mean ( ) elif reduction_enum == 2 : return loss . sum ( )