code: def testHigherRank(self):
      np.random.seed(7)
      with self.session() as sess:
          for n in 2, 3:
              for shape in (4,), (4, 5), (4, 5, 2):
                  partitions = np.random.randint(
                      n, size=np.prod(shape)
                  ).reshape(shape)
                  for extra_shape in (), (6,), (6, 7):
                      data = np.random.randn(*(shape + extra_shape))
                      partitions_t = constant_op.constant(
                          partitions, dtype=dtypes.int32
                      )
                      data_t = constant_op.constant(data)
                      outputs = data_flow_ops.dynamic_partition(
                          data_t, partitions_t, num_partitions=n
                      )
                      self.assertEqual(n, len(outputs))
                      outputs_val = self.evaluate(outputs)
                      for i, output in enumerate(outputs_val):
                          self.assertAllEqual(
                              output, data[partitions == i]
                          )
  
                      # Test gradients
                      outputs_grad = [
                          7 * output for output in outputs_val
                      ]
                      grads = gradients_impl.gradients(
                          outputs, [data_t, partitions_t], outputs_grad
                      )
                      self.assertEqual(
                          grads[1], None
                      )  # Partitions has no gradients
                      self.assertAllEqual(7 * data, sess.run(grads[0]))
  
imports: import unittest
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.ops import gradients_impl
  import tensorflow.python.ops.data_flow_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 7 for calling the DynamicPartitionTest obj's underlying member method code with example usage: obj.testHigherRank() without return types