def _assert_ndims_statically(x,<EOL>expect_ndims=None,<EOL>expect_ndims_at_least=None,<EOL>expect_static=False):
ndims = x.shape.ndims<EOL>if ndims is None:<EOL><INDENT>if expect_static:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(x))<EOL><DEDENT>return<EOL><DEDENT>if expect_ndims is not None and ndims != expect_ndims:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(expect_ndims, ndims))<EOL><DEDENT>if expect_ndims_at_least is not None and ndims < expect_ndims_at_least:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(<EOL>expect_ndims_at_least, ndims))<EOL><DEDENT>
Assert that Tensor x has expected number of dimensions.