docs: def create_output(out, shape, dtype, mode='w+', suffix=None):
      """Return numpy array where image data of shape and dtype can be copied.
  
      The 'out' parameter may have the following values or types:
  
      None
          An empty array of shape and dtype is created and returned.
      numpy.ndarray
          An existing writable array of compatible dtype and shape. A view of
          the same array is returned after verification.
      'memmap' or 'memmap:tempdir'
          A memory-map to an array stored in a temporary binary file on disk
          is created and returned.
      str or open file
          The file name or file object used to create a memory-map to an array
          stored in a binary file on disk. The created memory-mapped array is
          returned.
  
      """
      if out is None:
          return numpy.zeros(shape, dtype)
      if isinstance(out, str) and out[:6] == 'memmap':
          import tempfile  # noqa: delay import
          tempdir = out[7:] if len(out) > 7 else None
          if suffix is None:
              suffix = '.memmap'
          with tempfile.NamedTemporaryFile(dir=tempdir, suffix=suffix) as fh:
              return numpy.memmap(fh, shape=shape, dtype=dtype, mode=mode)
      if isinstance(out, numpy.ndarray):
          if product(shape) != product(out.shape):
              raise ValueError('incompatible output shape')
          if not numpy.can_cast(dtype, out.dtype):
              raise ValueError('incompatible output dtype')
          return out.reshape(shape)
      if isinstance(out, pathlib.Path):
          out = str(out)
      return numpy.memmap(out, shape=shape, dtype=dtype, mode=mode)