input: Write a python function to detect faces in an image using Haar cascades and save the image with rectangles drawn around detected faces.
  assert detect_faces_and_save('Sample_image.jpg', 'haarcascade_frontal_face.xml', 'face_detect.jpg') == 'face_detect.jpg'
  assert detect_faces_and_save('sample2.jpg', 'haarcascade_frontal_face.xml', 'output2.jpg') == 'output2.jpg'
  assert detect_faces_and_save('no_faces.jpg', 'haarcascade_frontal_face.xml', 'no_faces_output.jpg') == 'no_faces_output.jpg'
output: import cv2
  
  def detect_faces_and_save(input_image_path, cascade_path, output_image_path):
      # Load the Haar cascade
      face_cascade = cv2.CascadeClassifier(cascade_path)
      
      # Read the image
      img = cv2.imread(input_image_path)
      
      # Convert to grayscale
      gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
      
      # Detect faces
      faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
      
      # Draw rectangles around faces
      for (x, y, w, h) in faces:
          cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
      
      # Save the output image
      cv2.imwrite(output_image_path, img)
      
      return output_image_path