You get this error when you perform a multiple assignment to None (which is of NoneType). For instance:
X_train, y_train, X_test, y_test = None
TypeError: cannot unpack non-iterable NoneType object
So if you get this, the error is most likely that the right-hand part of the assignment is not what you expected (it’s nothing).
I think your X_train, y_train, X_test, y_test are defined inside your load_mnist_imagesfunction, and are thus not defined for your load_dataset function.
You should de-indent your 5 lines from X_train = ... to return X_train, ... and your code might work better then.