How to check input size is a multiple of some integer

I ma currently using something like this to assert that the spatial dimensions of my input tensor is a multiple of 32. My spatial dimensions can be 2D or 3D

shape = x.shape[2:]  # Do not care about N and C dims.
for s in shape:
    assert s % 32 == 0

This looks and feels quite ugly and un-pythonic. I was wondering if there is a canonical way to do this?

Ok, I figured it out. I needed to convert it to a tensor first.

shape = torch.tensor(x.shape[2:])
assert torch.sum(shape  % 32) == 0