code: def _maybe_validate_rightmost_transposed_ndims(
      initial_rightmost_transposed_ndims,
      rightmost_transposed_ndims,
      validate_args,
      name=None,
  ):
      """Checks that `rightmost_transposed_ndims` is valid."""
      with tf.name_scope(
          name or "maybe_validate_rightmost_transposed_ndims"
      ):
          assertions = []
  
          if (
              tensorshape_util.rank(rightmost_transposed_ndims.shape)
              is not None
          ):
              if (
                  tensorshape_util.rank(
                      rightmost_transposed_ndims.shape
                  )
                  != 0
              ):
                  raise ValueError(
                      "`rightmost_transposed_ndims` must be a scalar, "
                      "saw rank: {}.".format(
                          tensorshape_util.rank(
                              rightmost_transposed_ndims.shape
                          )
                      )
                  )
          elif validate_args:
              assertions += [
                  assert_util.assert_rank(
                      rightmost_transposed_ndims, 0
                  ),
                  assert_util.assert_equal(
                      rightmost_transposed_ndims,
                      initial_rightmost_transposed_ndims,
                      message="`rightmost_transposed_ndims` must not change "
                      "from the value set when the `Transpose` "
                      "bijector was constructed.",
                  ),
              ]
  
          rightmost_transposed_ndims_ = tf.get_static_value(
              rightmost_transposed_ndims
          )
          msg = "`rightmost_transposed_ndims` must be non-negative."
          if rightmost_transposed_ndims_ is not None:
              if rightmost_transposed_ndims_ < 0:
                  raise ValueError(
                      msg[:-1]
                      + ", saw: {}.".format(rightmost_transposed_ndims_)
                  )
          elif validate_args:
              assertions += [
                  assert_util.assert_non_negative(
                      rightmost_transposed_ndims, message=msg
                  )
              ]
  
          return assertions
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 1 for calling a global function with example usage: _maybe_validate_rightmost_transposed_ndims(initial_rightmost_transposed_ndims, rightmost_transposed_ndims, validate_args, name) and returns: assertions