code: def testSumRightmostNdimsPreservingShapeDynamicRank(self):
      if tf.executing_eagerly():
          return
      x = tf1.placeholder_with_default(
          np.ones((5, 4, 3, 2)), shape=None
      )
      y = util.sum_rightmost_ndims_preserving_shape(x, ndims=2)
      self.assertIsNone(tensorshape_util.rank(y.shape))
      self.assertAllEqual(
          (5, 4),
          self.evaluate(
              util.sum_rightmost_ndims_preserving_shape(x, ndims=2)
          ).shape,
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math.gradient import value_and_gradient
  from tensorflow_probability.python.math.psd_kernels.internal import util
label_desc: Use image node_id 7 for calling the UtilTest obj's underlying member method code with example usage: obj.testSumRightmostNdimsPreservingShapeDynamicRank() without return types