code: def intensity(image):
      '''Calculates the average intensity of the pixels in an image.
      Accepts both RGB and grayscale images.
  
      :param image: numpy.ndarray
      :returns: image intensity
      :rtype: float
      '''
      if len(image.shape) > 2:
          # Convert to grayscale
          image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) / 255
      elif issubclass(image.dtype.type, np.integer):
          image /= 255
      return float(np.sum(image) / np.prod(image.shape)f intensity(image):
      '''Calculates the average intensity of the pixels in an image.
      Accepts both RGB and grayscale images.
  
      :param image: numpy.ndarray
      :returns: image intensity
      :rtype: float
      '''
      if len(image.shape) > 2:
          # Convert to grayscale
          image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) / 255
      elif issubclass(image.dtype.type, np.integer):
          image /= 255
      return float(np.sum(image) / np.prod(image.shape))
docs: Calculates the average intensity of the pixels in an image.
      Accepts both RGB and grayscale images.
  
      :param image: numpy.ndarray
      :returns: image intensity
      :rtype: float