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?