class_docstr: Compute `Y = g(X) = transpose_rightmost_dims(X, rightmost_perm)`.
  
  This bijector is semantically similar to `tf.transpose` except that it
  transposes only the rightmost "event" dimensions. That is, unlike
  `tf.transpose` the `perm` argument is itself a permutation of
  `tf.range(rightmost_transposed_ndims)` rather than `tf.range(tf.rank(x))`,
  i.e., users specify the (rightmost) dimensions to permute, not all dimensions.
  
  The actual (forward) transformation is:
  
  ```python
  def forward(x, perm):
    sample_batch_ndims = tf.rank(x) - tf.size(perm)
    perm = tf.concat([
        tf.range(sample_batch_ndims),
        sample_batch_ndims + perm,
    ], axis=0)
    return tf.transpose(x, perm)
  ```
  
  #### Examples
  
  ```python
  tfp.bijectors.Transpose(perm=[1, 0]).forward(
      [
        [[1, 2],
         [3, 4]],
        [[5, 6],
         [7, 8]],
      ])
  # ==>
  #  [
  #    [[1, 3],
  #     [2, 4]],
  #    [[5, 7],
  #     [6, 8]],
  #  ]
  
  # Using `rightmost_transposed_ndims=2` means this bijector has the same
  # semantics as `tf.matrix_transpose`.
  tfp.bijectors.Transpose(rightmost_transposed_ndims=2).inverse(
      [
        [[1, 3],
         [2, 4]],
        [[5, 7],
         [6, 8]],
      ])
  # ==>
  #  [
  #    [[1, 2],
  #     [3, 4]],
  #    [[5, 6],
  #     [7, 8]],
  #  ]
  ```
class_docstr_tok: ["Compute","`","Y","=","g","(","X",")","=","transpose_rightmost_dims","(","X",",","rightmost_perm",")","`",".","This","bijector","is","semantically","similar","to","`","tf.transpose","`","except","that","it","transposes","only","the","rightmost","``","event","''","dimensions",".","That","is",",","unlike","`","tf.transpose","`","the","`","perm","`","argument","is","itself","a","permutation","of","`","tf.range","(","rightmost_transposed_ndims",")","`","rather","than","`","tf.range","(","tf.rank","(","x",")",")","`",",","i.e.",",","users","specify","the","(","rightmost",")","dimensions","to","permute",",","not","all","dimensions",".","The","actual","(","forward",")","transformation","is",":","``","`","python","def","forward","(","x",",","perm",")",":","sample_batch_ndims","=","tf.rank","(","x",")","-","tf.size","(","perm",")","perm","=","tf.concat","(","[","tf.range","(","sample_batch_ndims",")",",","sample_batch_ndims","+","perm",",","]",",","axis=0",")","return","tf.transpose","(","x",",","perm",")","``","`","#","#","#","#","Examples","``","`","python","tfp.bijectors.Transpose","(","perm=","[","1",",","0","]",")",".forward","(","[","[","[","1",",","2","]",",","[","3",",","4","]","]",",","[","[","5",",","6","]",",","[","7",",","8","]","]",",","]",")","#","==",">","#","[","#","[","[","1",",","3","]",",","#","[","2",",","4","]","]",",","#","[","[","5",",","7","]",",","#","[","6",",","8","]","]",",","#","]","#","Using","`","rightmost_transposed_ndims=2","`","means","this","bijector","has","the","same","#","semantics","as","`","tf.matrix_transpose","`",".","tfp.bijectors.Transpose","(","rightmost_transposed_ndims=2",")",".inverse","(","[","[","[","1",",","3","]",",","[","2",",","4","]","]",",","[","[","5",",","7","]",",","[","6",",","8","]","]",",","]",")","#","==",">","#","[","#","[","[","1",",","2","]",",","#","[","3",",","4","]","]",",","#","[","[","5",",","6","]",",","#","[","7",",","8","]","]",",","#","]","``","`"]
docstr: Instantiates the `Transpose` bijector.
  
  Args:
    perm: Positive `int32` vector-shaped `Tensor` representing permutation of
      rightmost dims (for forward transformation).  Note that the `0`th index
      represents the first of the rightmost dims and the largest value must be
      `rightmost_transposed_ndims - 1` and corresponds to `tf.rank(x) - 1`.
      Only one of `perm` and `rightmost_transposed_ndims` can (and must) be
      specified. The number of elements in a permutation must have a value
      that can be determined statically.
      Default value:
      `tf.range(start=rightmost_transposed_ndims, limit=-1, delta=-1)`.
    rightmost_transposed_ndims: Positive `int32` scalar-shaped `Tensor`
      representing the number of rightmost dimensions to permute.
      Only one of `perm` and `rightmost_transposed_ndims` can (and must) be
      specified. If `rightmost_transposed_ndims` is specified, the rightmost
      dims are reversed. This argument must have a value that can be
      determined statically.
      Default value: `tf.size(perm)`.
    validate_args: Python `bool` indicating whether arguments should be
      checked for correctness.
    name: Python `str` name given to ops managed by this object.
  
  Raises:
    ValueError: if both or neither `perm` and `rightmost_transposed_ndims` are
      specified.
    NotImplementedError: if `rightmost_transposed_ndims` is not known prior to
      graph execution.
docstr_tok: ["Instantiates","the","`","Transpose","`","bijector",".","Args",":","perm",":","Positive","`","int32","`","vector-shaped","`","Tensor","`","representing","permutation","of","rightmost","dims","(","for","forward","transformation",")",".","Note","that","the","`","0","`","th","index","represents","the","first","of","the","rightmost","dims","and","the","largest","value","must","be","`","rightmost_transposed_ndims","-","1","`","and","corresponds","to","`","tf.rank","(","x",")","-","1","`",".","Only","one","of","`","perm","`","and","`","rightmost_transposed_ndims","`","can","(","and","must",")","be","specified",".","The","number","of","elements","in","a","permutation","must","have","a","value","that","can","be","determined","statically",".","Default","value",":","`","tf.range","(","start=rightmost_transposed_ndims",",","limit=-1",",","delta=-1",")","`",".","rightmost_transposed_ndims",":","Positive","`","int32","`","scalar-shaped","`","Tensor","`","representing","the","number","of","rightmost","dimensions","to","permute",".","Only","one","of","`","perm","`","and","`","rightmost_transposed_ndims","`","can","(","and","must",")","be","specified",".","If","`","rightmost_transposed_ndims","`","is","specified",",","the","rightmost","dims","are","reversed",".","This","argument","must","have","a","value","that","can","be","determined","statically",".","Default","value",":","`","tf.size","(","perm",")","`",".","validate_args",":","Python","`","bool","`","indicating","whether","arguments","should","be","checked","for","correctness",".","name",":","Python","`","str","`","name","given","to","ops","managed","by","this","object",".","Raises",":","ValueError",":","if","both","or","neither","`","perm","`","and","`","rightmost_transposed_ndims","`","are","specified",".","NotImplementedError",":","if","`","rightmost_transposed_ndims","`","is","not","known","prior","to","graph","execution","."]
code: def __init__(
      self,
      perm=None,
      rightmost_transposed_ndims=None,
      validate_args=False,
      name="transpose",
  ):
      """Instantiates the `Transpose` bijector.
  
      Args:
        perm: Positive `int32` vector-shaped `Tensor` representing permutation of
          rightmost dims (for forward transformation).  Note that the `0`th index
          represents the first of the rightmost dims and the largest value must be
          `rightmost_transposed_ndims - 1` and corresponds to `tf.rank(x) - 1`.
          Only one of `perm` and `rightmost_transposed_ndims` can (and must) be
          specified. The number of elements in a permutation must have a value
          that can be determined statically.
          Default value:
          `tf.range(start=rightmost_transposed_ndims, limit=-1, delta=-1)`.
        rightmost_transposed_ndims: Positive `int32` scalar-shaped `Tensor`
          representing the number of rightmost dimensions to permute.
          Only one of `perm` and `rightmost_transposed_ndims` can (and must) be
          specified. If `rightmost_transposed_ndims` is specified, the rightmost
          dims are reversed. This argument must have a value that can be
          determined statically.
          Default value: `tf.size(perm)`.
        validate_args: Python `bool` indicating whether arguments should be
          checked for correctness.
        name: Python `str` name given to ops managed by this object.
  
      Raises:
        ValueError: if both or neither `perm` and `rightmost_transposed_ndims` are
          specified.
        NotImplementedError: if `rightmost_transposed_ndims` is not known prior to
          graph execution.
      """
      parameters = dict(locals())
      with tf.name_scope(name) as name:
          # We need to determine `forward_min_event_ndims` statically, which
          # requires that we know `rightmost_transposed_ndims` statically.
          # So the corresponding assertions go here rather than in
          # `_parameter_control_dependencies`
          if (rightmost_transposed_ndims is None) == (perm is None):
              raise ValueError(
                  "Must specify exactly one of "
                  "`rightmost_transposed_ndims` and `perm`."
              )
          if rightmost_transposed_ndims is not None:
              rightmost_transposed_ndims = (
                  tensor_util.convert_nonref_to_tensor(
                      rightmost_transposed_ndims,
                      dtype_hint=np.int32,
                      as_shape_tensor=True,
                  )
              )
              if not dtype_util.is_integer(
                  rightmost_transposed_ndims.dtype
              ):
                  raise TypeError(
                      "`rightmost_transposed_ndims` must be integer type."
                  )
              rightmost_transposed_ndims_ = tf.get_static_value(
                  rightmost_transposed_ndims
              )
              if rightmost_transposed_ndims_ is None:
                  raise NotImplementedError(
                      "`rightmost_transposed_ndims` must be "
                      "known prior to graph execution."
                  )
              msg = "`rightmost_transposed_ndims` must be non-negative."
              if rightmost_transposed_ndims_ < 0:
                  raise ValueError(
                      msg[:-1]
                      + ", saw: {}.".format(rightmost_transposed_ndims_)
                  )
  
          else:  # perm is not None:
              perm = tensor_util.convert_nonref_to_tensor(
                  perm,
                  dtype_hint=np.int32,
                  name="perm",
                  as_shape_tensor=True,
              )
              rightmost_transposed_ndims_ = tf.get_static_value(
                  ps.size(perm)
              )
  
          # TODO(b/110828604): If bijector base class ever supports dynamic
          # `min_event_ndims`, then this class already works dynamically and the
          # following five lines can be removed. In this case, we may have to
          # deprecate doing work in the constructor to avoid graph cycles when
          # `validate_args==True`.
          if rightmost_transposed_ndims_ is None:
              raise NotImplementedError(
                  "`rightmost_transposed_ndims` must be "
                  "known prior to graph execution."
              )
          else:
              rightmost_transposed_ndims_ = int(
                  rightmost_transposed_ndims_
              )
  
          self._perm = perm
          self._rightmost_transposed_ndims = rightmost_transposed_ndims
          self._initial_rightmost_transposed_ndims = (
              rightmost_transposed_ndims_
          )
          super(Transpose, self).__init__(
              forward_min_event_ndims=rightmost_transposed_ndims_,
              is_constant_jacobian=True,
              validate_args=validate_args,
              parameters=parameters,
              name=name,
          )
  
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 to create a new Transpose object from inherited base classes: bijector with example: obj = Transpose(perm, rightmost_transposed_ndims, validate_args, name)