def _get_msge_with_gradient_func(shape, p):
    """Select which function to use for MSGE calculation (over- or
    underdetermined).
    """
    t, m, l = shape

    n = (l - p) * t
    underdetermined = n < m * p

    if underdetermined:
        return _msge_with_gradient_underdetermined
    else:
        return _msge_with_gradient_overdetermined