How to plot error vs training size learning curves


I’m seeing a lot of people plotting the training and validation error value vs epoch but both and Andrew Ng talk about plotting the error vs the size of the training set.

scikit-learn provides a nice function called learning_curve() which plots the error curves vs training set size. How can we do the same in pytorch? Is there a convenience class/function that does this?