def pad_shape_right_with_ones(x, ndims):
if not (isinstance(ndims, int) and ndims >= <NUM_LIT:0>):<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>.format(ndims))<EOL><DEDENT>if ndims == <NUM_LIT:0>:<EOL><INDENT>return x<EOL><DEDENT>x = tf.convert_to_tensor(value=x)<EOL>original_shape = x.shape<EOL>new_shape = distribution_util.pad(<EOL>tf.shape(input=x), axis=<NUM_LIT:0>, back=True, value=<NUM_LIT:1>, count=ndims)<EOL>x = tf.reshape(x, new_shape)<EOL>x.set_shape(original_shape.concatenate([<NUM_LIT:1>]*ndims))<EOL>return x<EOL>
Maybe add `ndims` ones to `x.shape` on the right.

    If `ndims` is zero, this is a no-op; otherwise, we will create and return a
    new `Tensor` whose shape is that of `x` with `ndims` ones concatenated on the
    right side. If the shape of `x` is known statically, the shape of the return
    value will be as well.

    Args:
      x: The `Tensor` we'll return a reshaping of.
      ndims: Python `integer` number of ones to pad onto `x.shape`.
    Returns:
      If `ndims` is zero, `x`; otherwise, a `Tensor` whose shape is that of `x`
      with `ndims` ones concatenated on the right side. If possible, returns a
      `Tensor` whose shape is known statically.
    Raises:
      ValueError: if `ndims` is not a Python `integer` greater than or equal to
      zero.