Without having the functional code at hand here a fast reply: I think i squeezed the masked there because the shape of the mask was something like  [Batch_size, height, width, 1]. Try
print(mask.shape)

to see exact shape. Someone wiser than me might eplain why and how the mask got a fourth entry with 1.
As a remark, the dataloader works as it should in m project.