code: def overlay(
      gray,
      red=None,
      green=None,
      blue=None,
      if_gray_dtype_not_uint8="stretch",
  ):
      """
      Create an image which is greyscale, but with possible boolean overlays.
  
      Parameters
      ----------
      gray: ndarray of type np.uint8
          Should be a greyscale image of type np.uint8
  
      red,green,blue : ndarray, optional
          boolean arrays
  
      if_gray_dtype_not_uint8 : str, optional
          What to do if ``gray`` is not of type ``np.uint8``, must be one of
              'stretch' (default): the function ``stretch`` is called.
              'error' : in this case, an error is raised
  
      Returns
      -------
      overlaid : ndarray
          Colour image
      """
      _check_2(gray, "overlay")
      if gray.dtype != np.uint8:
          if if_gray_dtype_not_uint8 == "stretch":
              gray = stretch(gray)
          else:
              raise ValueError(
                  "mahotas.overlay: first argument should be of dtype np.uint8"
              )
  
      def _v(ch):
          if ch is None:
              return gray
          ch = ch.astype(bool, copy=False)
          ch = 255 * ch
          return np.maximum(gray, ch)
  
      r = _v(red)
      g = _v(green)
      b = _v(blue)
      return np.dstack([r, g, b]).astype(gray.dtype, copy=False)
  
imports: from __future__ import division
  import numpy
  from .internal import _check_2
label_desc: Use image node_id 4 for calling a global function with example usage: overlay(gray, red, green, blue, if_gray_dtype_not_uint8) and returns: np, np, gray