input: Write a python function to create a neural network model using TensorFlow and Keras with specified layers, compile it, and fit it on the given data.
  assert model.summary() is not None
  assert model.history is not None
output: def create_and_train_model(X_train, y_train, input_shape, epochs=10):
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Dense, Flatten
      from tensorflow.keras.optimizers import Adam
  
      # Create the model
      model = Sequential([
          Flatten(input_shape=input_shape),
          Dense(128, activation='relu'),
          Dense(64, activation='relu'),
          Dense(10, activation='softmax')
      ])
  
      # Compile the model
      model.compile(optimizer=Adam(), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
  
      # Fit the model
      history = model.fit(X_train, y_train, epochs=epochs)
  
      return model, history