input: Write a function to create an AI program that recognizes handwritten letters and digits using Python. The program should load the MNIST dataset, preprocess the data, create a convolutional neural network model using Keras, compile the model, train it, and then evaluate its performance. The function should return the trained model and print out the evaluation results.
  
  def recognize_handwritten_letters_digits():
      # imports
      import tensorflow as tf
      from tensorflow import keras
  
      # load the MNIST dataset
      mnist = keras.datasets.mnist
      # Split the dataset into training and testing sets
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
      # Preprocess the data
      x_train, x_test = x_train / 255.0, x_test / 255.0
  
      # create a model
      model = keras.Sequential()
      # add a convolution layer
      model.add(keras.layers.Conv2D(28, kernel_size=(3,3), input_shape=(28, 28, 1)))
      # add a max pooling layer
      model.add(keras.layers.MaxPool2D(pool_size=(2, 2)))
      # add a flatten layer
      model.add(keras.layers.Flatten())
      # add a dense layer
      model.add(keras.layers.Dense(128, activation='relu'))
      # add an output layer
      model.add(keras.layers.Dense(10, activation='softmax'))
  
      # compile the model
      model.compile(optimizer='adam', 
      loss='sparse_categorical_crossentropy',
      metrics=['accuracy'])
  
      # train the model
      model.fit(x_train, y_train, epochs=5)
  
      # evaluate the model
      model.evaluate(x_test, y_test)
  
      return model
  
  assert type(recognize_handwritten_letters_digits())==type(keras.models.Sequential())
  assert recognize_handwritten_letters_digits().predict(x_test).shape==(10000, 10)
  assert recognize_handwritten_letters_digits().optimizer.get_config()['name']=="adam"
output: 
  def recognize_handwritten_letters_digits():
      import tensorflow as tf
      from tensorflow import keras
  
      mnist = keras.datasets.mnist
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
      x_train, x_test = x_train / 255.0, x_test / 255.0
      x_train = x_train[..., tf.newaxis]
      x_test = x_test[..., tf.newaxis]
  
      model = keras.Sequential([
          keras.layers.Conv2D(28, kernel_size=(3,3), input_shape=(28, 28, 1)),
          keras.layers.MaxPool2D(pool_size=(2, 2)),
          keras.layers.Flatten(),
          keras.layers.Dense(128, activation='relu'),
          keras.layers.Dense(10, activation='softmax')
      ])
  
      model.compile(optimizer='adam', 
                    loss='sparse_categorical_crossentropy',
                    metrics=['accuracy'])
  
      model.fit(x_train, y_train, epochs=5)
      model.evaluate(x_test, y_test)
  
      return model
  