input: def train_mnist_nn(learning_rate: float, training_epochs: int, batch_size: int, display_step: int) -> float:
      """Train a multilayer perceptron neural network for classifying hand-written digits from the MNIST dataset.
      The function returns the accuracy of the model on the test dataset.
      
      >>> train_mnist_nn(0.001, 15, 100, 1)
      0.952
      """
output:     import tensorflow as tf
      import numpy as np
      from tensorflow.keras.datasets import mnist
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Dense, Flatten
      from tensorflow.keras.utils import to_categorical
  
      # Load and preprocess the MNIST dataset
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
      x_train, x_test = x_train / 255.0, x_test / 255.0
      y_train = to_categorical(y_train, 10)
      y_test = to_categorical(y_test, 10)
  
      # Build the model
      model = Sequential([
          Flatten(input_shape=(28, 28)),
          Dense(128, activation='relu'),
          Dense(10, activation='softmax')
      ])
  
      # Compile the model
      model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=learning_rate),
                    loss='categorical_crossentropy',
                    metrics=['accuracy'])
  
      # Train the model
      model.fit(x_train, y_train, epochs=training_epochs, batch_size=batch_size,
                validation_data=(x_test, y_test), verbose=0,
                callbacks=[tf.keras.callbacks.LambdaCallback(on_epoch_end=lambda epoch, logs: print(f'Epoch {epoch+1}/{training_epochs}, Loss: {logs["loss"]:.4f}, Accuracy: {logs["accuracy"]:.4f}') if (epoch+1) % display_step == 0 else None)])
  
      # Evaluate the model
      test_loss, test_accuracy = model.evaluate(x_test, y_test, verbose=0)
  
      return test_accuracy