input: def train_cat_dog_model(directory: str, target_size: tuple[int, int] = (64, 64), batch_size: int = 32, epochs: int = 5) -> Sequential:
      """ Train a CNN model using Keras to distinguish between cats and dogs.
      The dataset should be in a directory where each class has its own subdirectory.
      >>> model = train_cat_dog_model(directory='/path/to/dataset')
      >>> isinstance(model, keras.models.Sequential)
      True
      """
      
      # Create the neural network model
      model = Sequential()
  
      # Input layer
      model.add(Conv2D(32, (3, 3), input_shape=(target_size[0], target_size[1], 3), activation='relu'))
  
      # Hidden layers
      model.add(MaxPooling2D(pool_size=(2, 2)))
      model.add(Dropout(0.3))
      model.add(Conv2D(64, (3, 3), activation='relu'))
      model.add(MaxPooling2D(pool_size=(2, 2)))
      model.add(Dropout(0.3))
      model.add(Conv2D(64, (3, 3), activation='relu'))
      model.add(MaxPooling2D(pool_size=(2, 2)))
      model.add(Dropout(0.3))
  
      # Output layer
      model.add(Flatten())
      model.add(Dense(units=128, activation='relu'))
      model.add(Dense(units=1, activation='sigmoid'))
  
      # Compile the model
      model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  
      # Create data generator
      datagen = ImageDataGenerator(rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True)
  
      # Fit the model
      train_generator = datagen.flow_from_directory(directory=directory, target_size=target_size, color_mode='rgb', class_mode='binary', batch_size=batch_size)
      model.fit(train_generator, steps_per_epoch=800 // batch_size, epochs=epochs)
      
      return model
output:     # Save the model
      model.save('cat_dog_model.h5')