code: def testSumRightmostNdimsPreservingShapeStaticRank(self):
      x = np.ones((5, 4, 3, 2))
      self.assertAllEqual(
          util.sum_rightmost_ndims_preserving_shape(x, ndims=2).shape,
          [5, 4],
      )
  
      x = tf1.placeholder_with_default(
          np.ones((5, 4, 3, 2)), shape=[5, 4, None, None]
      )
      if not tf.executing_eagerly():
          return
      y = util.sum_rightmost_ndims_preserving_shape(x, ndims=1)
      self.assertAllEqual((5, 4, 3), y.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 6 for calling the UtilTest obj's underlying member method code with example usage: obj.testSumRightmostNdimsPreservingShapeStaticRank() without return types