code: def _right_pad(x, final_rank):
      """Pads the shape of x to the right to be of rank final_rank.
  
      Expands the dims of `x` to the right such that its rank is equal to
      final_rank. For example, if `x` is of shape [1, 5, 7, 2] and `final_rank` is
      7, we return padded_x, which is of shape [1, 5, 7, 2, 1, 1, 1].
  
      Args:
        x: The tensor whose shape is to be padded.
        final_rank: Scalar int32 `Tensor` or Python `int`. The desired rank of x.
  
      Returns:
        padded_x: A tensor of rank final_rank.
      """
      padded_shape = ps.concat(
          [
              ps.shape(x),
              ps.ones(final_rank - ps.rank(x), dtype=tf.int32),
          ],
          axis=0,
      )
      static_padded_shape = None
      if tensorshape_util.is_fully_defined(x.shape) and isinstance(
          final_rank, int
      ):
          static_padded_shape = tensorshape_util.as_list(x.shape)
          extra_dims = final_rank - len(static_padded_shape)
          static_padded_shape.extend([1] * extra_dims)
  
      padded_x = tf.reshape(x, static_padded_shape or padded_shape)
      return padded_x
  
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import distribute_lib
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.mcmc import kernel
  from tensorflow_probability.python.mcmc.internal import slice_sampler_utils
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow_probability.python.random import random_ops
label_desc: Use image node_id 4 for calling a global function with example usage: _right_pad(x, final_rank) and returns: padded_x