input: Write a python function to average all images in a given directory and save the result to an output directory.
  assert os.path.exists('output_dir/average_image.png')==True
  assert os.path.getsize('output_dir/average_image.png')>0
output: def average_images(input_dir, output_dir):
      from PIL import Image
      import numpy as np
      import os
  
      images = []
      
      for filename in os.listdir(input_dir):
          if filename.endswith('.png') or filename.endswith('.jpg') or filename.endswith('.jpeg'):
              img_path = os.path.join(input_dir, filename)
              images.append(np.array(Image.open(img_path), dtype=np.float32))
  
      average_image_array = np.mean(images, axis=0).astype(np.uint8)
      
      average_image = Image.fromarray(average_image_array)
      if not os.path.exists(output_dir):
          os.makedirs(output_dir)
      average_image.save(os.path.join(output_dir, 'average_image.png'))