code: def test_invalid_rank(self, rank):
      x = tf.ones([1] * rank)
      # pylint: disable=g-error-prone-assert-raises
      with self.assertRaisesRegex(
          ValueError, "must have rank %d" % (rank + 1)
      ):
          utils.assert_rank(x, rank + 1)
  
      with self.assertRaisesRegex(
          ValueError, "must have rank %d" % (rank - 1)
      ):
          utils.assert_rank(x, rank - 1)
  
      with self.assertRaisesRegex(
          ValueError, "must have rank >= %d" % (rank + 1)
      ):
          utils.assert_minimum_rank(x, rank + 1)
  
imports: from absl.testing import parameterized
  import numpy
  from sonnet.src import initializers
  from sonnet.src import test_utils
  from sonnet.src import utils
  import tensorflow
label_desc: Use image node_id 2 for calling the AssertRankTest obj's underlying member method code with example usage: obj.test_invalid_rank(rank) without return types