input: Write a function that collates a machine learning model in Python that distinguishes between cats and dogs using a dataset of 800 images of cats and dogs. The function should return the compiled and trained model.
  assert collate_cat_dog_model().history['accuracy'][-1] > 0.85
  assert collate_cat_dog_model().history['val_accuracy'][-1] > 0.8
output: 
  def collate_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, validation_split=0.2)
  
      train_generator = train_datagen.flow_from_directory(
          'path_to_dataset',
          target_size=(150, 150),
          batch_size=32,
          class_mode='binary',
          subset='training'
      )
  
      validation_generator = train_datagen.flow_from_directory(
          'path_to_dataset',
          target_size=(150, 150),
          batch_size=32,
          class_mode='binary',
          subset='validation'
      )
  
      history = model.fit(
          train_generator,
          steps_per_epoch=train_generator.samples // train_generator.batch_size,
          validation_data=validation_generator,
          validation_steps=validation_generator.samples // validation_generator.batch_size,
          epochs=15
      )
  
      return model
  