<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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)