Combine mask and selection by dimension

I currently have a lot of code that looks like:

tensor[mask, :][..., i]

because apparently, I can’t mix masks and selection by dimensions. tensor[mask, i] complains about dimensions not working out, but the mask has the shape of the tensor up to the last dimension.

Any better way to achieve what I want to do?

Is mask a uint8 or bool tensor?
If so, could you post a small example of what you would like to achieve?