input: Write a function to construct a neural network model in Python using Keras to correctly classify the MNIST data set. The function should return the compiled Keras model. The input layer should have a shape of (784,), the hidden layer should have 128 units with 'relu' activation, and the output layer should have 10 units with 'softmax' activation. The model should be compiled using the 'adam' optimizer, 'sparse_categorical_crossentropy' loss, and 'accuracy' metric.
  assert model_mnist() == model, "Constructed model should match the predefined model structure."
  assert model_mnist().optimizer.get_config()['name'] == 'adam', "Optimizer should be 'adam'."
  assert model_mnist().loss == 'sparse_categorical_crossentropy', "Loss should be 'sparse_categorical_crossentropy'."
  assert model_mnist().metrics[0] == 'accuracy', "Metric should be 'accuracy'."
output: def model_mnist():
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Dense
      
      model = Sequential([
          Dense(128, activation='relu', input_shape=(784,)),
          Dense(10, activation='softmax')
      ])
      
      model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
      
      return model