input: Write a function to create a neural network model using TensorFlow and Python for classifying hand-written digits from the MNIST dataset. The function should train the model and return the accuracy on the test dataset. If the input is a valid dataset, the function should return the accuracy as a float. If the dataset is invalid or empty, the function should return -1.0.
  assert mnist_classifier() > 0.9
  assert mnist_classifier() == -1.0 if dataset is invalid
output: def mnist_classifier():
      import tensorflow as tf
      from tensorflow.keras import layers, models
      from tensorflow.keras.datasets import mnist
      from tensorflow.keras.utils import to_categorical
  
      try:
          (x_train, y_train), (x_test, y_test) = mnist.load_data()
      except Exception as e:
          return -1.0
  
      if len(x_train) == 0 or len(x_test) == 0:
          return -1.0
  
      x_train = x_train.reshape((60000, 28, 28, 1)).astype('float32') / 255
      x_test = x_test.reshape((10000, 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.Conv2D(64, (3, 3), activation='relu'),
          layers.MaxPooling2D((2, 2)),
          layers.Conv2D(64, (3, 3), activation='relu'),
          layers.Flatten(),
          layers.Dense(64, activation='relu'),
          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, verbose=0)
  
      test_loss, test_acc = model.evaluate(x_test, y_test, verbose=0)
      return test_acc