TypeError: cannot unpack non-iterable NoneType object
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.