def METHOD_NAME(
    split_data: SplitData, recommender, criterion: Metric, k: int,
) -> float:
    """
    Calculate criterion value for given parameters
    :param split_data: data to train and test model
    :param recommender: recommender model
    :param criterion: optimization metric
    :param k: length of a recommendation list
    :return: criterion value
    """
    logger = logging.getLogger("replay")
    logger.debug("Fitting model inside optimization")
    # pylint: disable=protected-access
    recommender._fit_wrap(
        split_data.train,
        split_data.user_features_train,
        split_data.item_features_train,
    )
    logger.debug("Predicting inside optimization")
    recs = recommender._predict_wrap(
        log=split_data.train,
        k=k,
        users=split_data.users,
        items=split_data.items,
        user_features=split_data.user_features_test,
        item_features=split_data.item_features_test,
    )
    logger.debug("Calculating criterion")
    criterion_value = criterion(recs, split_data.test, k)
    logger.debug("%s=%.6f", criterion, criterion_value)
    return criterion_value