mask.shape should be equal to mask_img.shape. I don't mind changing the name here but I think I may be missing your point.