docs: def enforce_mask_shape(mask, shape):
      """Reduce a boolean mask to fit a given shape.
  
      Parameters
      ----------
      mask : ndarray with bool dtype
          The mask which is to be reduced
      shape : tuple of int
          Shape which broadcasts to the mask shape.
  
      Returns
      -------
          A boolean mask, collapsed along axes where the shape given has one element.
      """
      red = tuple([i for i in range(len(shape)) if shape[i] == 1])
      return mask.max(axis=red, keepdims=True)