I am not entirely convinced that it is good to use this function here instead of writing the ``if`` and defining the function only in ``learning_curve``, but I guess it is a matter of style and I don't have a strong opinion.