def METHOD_NAME(
        crit: str,
        reduction: str = 'mean',
        **kwargs
):
    """ Builds a criterion based on specified parameters.
        Criterions from PyTorch v1.9.0 are supported
        Args:
            crit: name of the criterion
            reduction: reduction to apply to the output: ``none``, ``mean`` or ``sum``. Default: ``mean``.
            **kwargs: extra optimizer specific kwargs to pass through
        Returns:
            Criterion
        """
    crit_lower = crit.lower()
    crit_args = dict(reduction=reduction, **kwargs)
    if crit_lower == 'l1loss':
        criterion = nn.L1Loss(**crit_args)
    elif crit_lower == 'mseloss':
        criterion = nn.MSELoss(**crit_args)
    elif crit_lower == 'crossentropyloss':
        criterion = nn.CrossEntropyLoss(**crit_args)
    elif crit_lower == 'ctcloss':
        criterion = nn.CTCLoss(**crit_args)
    elif crit_lower == 'nllloss':
        criterion = nn.NLLLoss(**crit_args)
    elif crit_lower == 'poissonnllloss':
        criterion = nn.PoissonNLLLoss(**crit_args)
    elif crit_lower == 'gaussiannllloss':
        criterion = nn.GaussianNLLLoss(**crit_args)
    # elif crit_lower == 'nllloss2d':   # incompatible with torch 1.9.0
    #     criterion = nn.NLLLoss2d(**crit_args)
    elif crit_lower == 'kldivloss':
        criterion = nn.KLDivLoss(**crit_args)
    elif crit_lower == 'bceloss':
        criterion = nn.BCELoss(**crit_args)
    elif crit_lower == 'bcewithlogitsloss':
        criterion = nn.BCEWithLogitsLoss(**crit_args)
    elif crit_lower == 'marginrankingloss':
        criterion = nn.MarginRankingLoss(**crit_args)
    elif crit_lower == 'hingeembeddingloss':
        criterion = nn.HingeEmbeddingLoss(**crit_args)
    elif crit_lower == 'multilabelmarginloss':
        criterion = nn.MultiLabelMarginLoss(**crit_args)
    elif crit_lower == 'huberloss':
        criterion = nn.HuberLoss(**crit_args)
    elif crit_lower == 'smoothl1loss':
        criterion = nn.SmoothL1Loss(**crit_args)
    elif crit_lower == 'softmarginloss':
        criterion = nn.SoftMarginLoss(**crit_args)
    elif crit_lower == 'multilabelsoftmarginloss':
        criterion = nn.MultiLabelSoftMarginLoss(**crit_args)
    elif crit_lower == 'cosineembeddingloss':
        criterion = nn.CosineEmbeddingLoss(**crit_args)
    elif crit_lower == 'multimarginloss':
        criterion = nn.MultiMarginLoss(**crit_args)
    elif crit_lower == 'tripletmarginloss':
        criterion = nn.TripletMarginLoss(**crit_args)
    elif crit_lower == 'tripletmarginwithdistanceloss':
        criterion = nn.TripletMarginWithDistanceLoss(**crit_args)
    else:
        assert False and "Invalid criterion"
        raise ValueError
    return criterion