input: Write a function to create a machine learning model in Python that distinguishes between cats and dogs using a dataset of 800 images. The function should return the trained model.
  assert create_cat_dog_classifier('/path/to/dataset')!=None
  assert create_cat_dog_classifier('/path/to/invalid/path')==None
  assert create_cat_dog_classifier('/path/to/dataset').history['accuracy'][-1]>=0.5
output: def create_cat_dog_classifier(dataset_path):
      try:
          from tensorflow.keras.preprocessing.image import ImageDataGenerator
          from tensorflow.keras.models import Sequential
          from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
          from tensorflow.keras.optimizers import Adam
          import os
  
          if not os.path.exists(dataset_path):
              return None
  
          train_datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)
  
          train_generator = train_datagen.flow_from_directory(
              dataset_path,
              target_size=(150, 150),
              batch_size=32,
              class_mode='binary',
              subset='training'
          )
  
          validation_generator = train_datagen.flow_from_directory(
              dataset_path,
              target_size=(150, 150),
              batch_size=32,
              class_mode='binary',
              subset='validation'
          )
  
          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(learning_rate=0.001), loss='binary_crossentropy', metrics=['accuracy'])
  
          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=10
          )
  
          return history
      except Exception as e:
          return None