input: Write a function to create and train a machine learning model in Python that distiguishes between cats and dogs using a dataset of 800 images. Use Keras and TensorFlow for model creation and training. The function should return the trained model. If an error occurs during the process, the function should handle it and return an error message.
  assert train_cats_dogs_model(dataset_path="/path/to/dataset", epochs=5, steps_per_epoch=800)==(the instance of the trained model)
  assert train_cats_dogs_model(dataset_path="/invalid/path", epochs=5, steps_per_epoch=800)=="Error occurred: [Error message]"
output: try:
      from tensorflow.keras.models import Sequential
      from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
      from tensorflow.keras.preprocessing.image import ImageDataGenerator
      import os
  
      def train_cats_dogs_model(dataset_path, epochs, steps_per_epoch):
          if not os.path.exists(dataset_path):
              return "Error occurred: Dataset path does not exist"
          
          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_path,
              target_size=(150, 150),
              batch_size=32,
              class_mode='binary'
          )
  
          model.fit(
              train_generator,
              epochs=epochs,
              steps_per_epoch=steps_per_epoch
          )
  
          return model
  except Exception as e:
      return f"Error occurred: {str(e)}"