input: Write a function to create and train a machine learning model using Keras that distinguishes between cats and dogs from a given dataset of 800 images. The function should return the trained model. If the dataset path provided is invalid, the function should return `None`.
  assert create_and_train_model("/path/to/dataset", "/path/to/test_dataset") is not None
  assert create_and_train_model("/invalid/path", "/path/to/test_dataset") == None
output: def create_and_train_model(dataset_path, test_dataset_path):
      import os
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
      from tensorflow.keras.preprocessing.image import ImageDataGenerator
  
      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', loss='binary_crossentropy', metrics=['accuracy'])
  
      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 model