input: Write a function to create a machine learning model in Python using Keras that distinguishes between images of cats and dogs. The function should define the neural network architecture, compile the model, and fit it to a dataset of 800 images using an ImageDataGenerator. The function should return the trained model.
  assert create_cat_dog_model().predict_generator(test_generator)[0] >= 0
  assert create_cat_dog_model().predict_generator(test_generator)[0] <= 1
  assert create_cat_dog_model().history['accuracy'][-1] >= 0
  assert create_cat_dog_model().history['accuracy'][-1] <= 1
output: def create_cat_dog_model():
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
      from tensorflow.keras.preprocessing.image import ImageDataGenerator
  
      model = Sequential([
          Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 3)),
          MaxPooling2D(2, 2),
          Conv2D(64, (3, 3), activation='relu'),
          MaxPooling2D(2, 2),
          Conv2D(128, (3, 3), activation='relu'),
          MaxPooling2D(2, 2),
          Flatten(),
          Dense(512, activation='relu'),
          Dense(1, activation='sigmoid')
      ])
  
      model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
  
      train_datagen = ImageDataGenerator(rescale=1./255)
      train_generator = train_datagen.flow_from_directory(
          'dataset/train',
          target_size=(150, 150),
          batch_size=32,
          class_mode='binary'
      )
  
      model.fit(train_generator, steps_per_epoch=25, epochs=10)
  
      return model