input: Write a function to create and train a machine learning model in Python that can recognize handwritten digits from 0 to 9 using the MNIST dataset. The function should use TensorFlow and Keras to define a neural network model with an input layer, a hidden layer with Dropout, and an output layer, compile the model, preprocess the data by reshaping, normalizing, and one-hot encoding, and then fit the model on the training data.
  assert recognize_digits() is not None
  assert recognize_digits() is not None
output: def recognize_digits():
      import tensorflow as tf
      from tensorflow.keras import layers, models
      from tensorflow.keras.datasets import mnist
      from tensorflow.keras.utils import to_categorical
  
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
  
      x_train = x_train.reshape((x_train.shape[0], 28, 28, 1)).astype('float32') / 255
      x_test = x_test.reshape((x_test.shape[0], 28, 28, 1)).astype('float32') / 255
  
      y_train = to_categorical(y_train)
      y_test = to_categorical(y_test)
  
      model = models.Sequential([
          layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
          layers.MaxPooling2D((2, 2)),
          layers.Flatten(),
          layers.Dense(128, activation='relu'),
          layers.Dropout(0.5),
          layers.Dense(10, activation='softmax')
      ])
  
      model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
  
      model.fit(x_train, y_train, epochs=5, batch_size=64, validation_data=(x_test, y_test))
  
      return model