input: Write a function to generate a Machine Learning model in Python that can recognize handwritten digits from 0 to 9 using TensorFlow and Keras. The function should compile the model with 'categorical_crossentropy' loss, 'adam' optimizer, and 'accuracy' metric, and then fit the model on the MNIST dataset for 5 epochs with a batch size of 128. The function should return the trained model. If the input data is not preprocessed correctly or the model is not compiled properly, the function should return None.
  
  assert generate_digit_recognition_model() is not None
  assert type(generate_digit_recognition_model()) == Model
  assert generate_digit_recognition_model().evaluate(X_test.reshape(10000, 784), to_categorical(y_test, num_classes=10))[1] > 0.9
output: def generate_digit_recognition_model():
      import tensorflow as tf
      from tensorflow.keras.datasets import mnist
      from tensorflow.keras.utils import to_categorical
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Dense
  
      (X_train, y_train), (X_test, y_test) = mnist.load_data()
      X_train = X_train.reshape(60000, 784).astype('float32') / 255
      X_test = X_test.reshape(10000, 784).astype('float32') / 255
      y_train = to_categorical(y_train, num_classes=10)
      y_test = to_categorical(y_test, num_classes=10)
  
      model = Sequential([
          Dense(128, activation='relu', input_shape=(784,)),
          Dense(64, activation='relu'),
          Dense(10, activation='softmax')
      ])
  
      model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
      model.fit(X_train, y_train, epochs=5, batch_size=128, verbose=0)
      
      return model