def _test_common_make_dtw_function(distance_mode, normalize, dtw_functions):
    """
    Used during testing to construct (if needed) the DTW function for the requested distance mode.

    :param distance_mode: A string used to lookup the requested DTW function (typically either 'cosine' or 'euclidean').
    :param normalize: Whether DTW distances should be length normalized.
    :param dtw_functions: The dictionary of DTW function constructors to use to get the requested DTW function
                          implementation.
    :return: The requested DTW function implementation.
    """

    assert isinstance(distance_mode, str)
    assert isinstance(normalize, bool)
    assert isinstance(dtw_functions, dict)
    assert len(dtw_functions) > 0
    assert distance_mode in dtw_functions
    return dtw_functions[distance_mode]()