class_docstr: Permutes the rightmost dimension of a `Tensor`.
  
  ```python
  reverse = tfp.bijectors.Permute(permutation=[2, 1, 0])
  
  reverse.forward([-1., 0., 1.])
  # ==> [1., 0., -1]
  
  reverse.inverse([1., 0., -1])
  # ==> [-1., 0., 1.]
  
  reverse.forward_log_det_jacobian(any_value)
  # ==> 0.
  
  reverse.inverse_log_det_jacobian(any_value)
  # ==> 0.
  ```
  
  Warning: `tf.estimator` may repeatedly build the graph thus
  `Permute(np.random.permutation(event_size)).astype('int32'))` is not a
  reliable parameterization (nor would it be even if using `tf.constant`). A
  safe alternative is to use `tf.get_variable` to achieve "init once" behavior,
  i.e.,
  
  ```python
  def init_once(x, name):
    return tf.get_variable(name, initializer=x, trainable=False)
  
  Permute(permutation=init_once(
      np.random.permutation(event_size).astype('int32'),
      name='permutation'))
  ```
class_docstr_tok: ["Permutes","the","rightmost","dimension","of","a","`","Tensor","`",".","``","`","python","reverse","=","tfp.bijectors.Permute","(","permutation=","[","2",",","1",",","0","]",")","reverse.forward","(","[","-1.",",","0.",",","1",".","]",")","#","==",">","[","1.",",","0.",",","-1","]","reverse.inverse","(","[","1.",",","0.",",","-1","]",")","#","==",">","[","-1.",",","0.",",","1",".","]","reverse.forward_log_det_jacobian","(","any_value",")","#","==",">","0.","reverse.inverse_log_det_jacobian","(","any_value",")","#","==",">","0",".","``","`","Warning",":","`","tf.estimator","`","may","repeatedly","build","the","graph","thus","`","Permute","(","np.random.permutation","(","event_size",")",")",".astype","(","'int32","'",")",")","`","is","not","a","reliable","parameterization","(","nor","would","it","be","even","if","using","`","tf.constant","`",")",".","A","safe","alternative","is","to","use","`","tf.get_variable","`","to","achieve","``","init","once","''","behavior",",","i.e.",",","``","`","python","def","init_once","(","x",",","name",")",":","return","tf.get_variable","(","name",",","initializer=x",",","trainable=False",")","Permute","(","permutation=init_once","(","np.random.permutation","(","event_size",")",".astype","(","'int32","'",")",",","name='permutation","'",")",")","``","`"]
docstr: Creates the `Permute` bijector.
  
  Args:
    permutation: An `int`-like vector-shaped `Tensor` representing the
      permutation to apply to the `axis` dimension of the transformed
      `Tensor`.
    axis: Scalar `int` `Tensor` representing the dimension over which to
      `tf.gather`. `axis` must be relative to the end (reading left to right)
      thus must be negative.
      Default value: `-1` (i.e., right-most).
    validate_args: Python `bool` indicating whether arguments should be
      checked for correctness.
    name: Python `str`, name given to ops managed by this object.
  
  Raises:
    TypeError: if `not dtype_util.is_integer(permutation.dtype)`.
    ValueError: if `permutation` does not contain exactly one of each of
      `{0, 1, ..., d}`.
    NotImplementedError: if `axis` is not known prior to graph execution.
    NotImplementedError: if `axis` is not negative.
docstr_tok: ["Creates","the","`","Permute","`","bijector",".","Args",":","permutation",":","An","`","int","`","-like","vector-shaped","`","Tensor","`","representing","the","permutation","to","apply","to","the","`","axis","`","dimension","of","the","transformed","`","Tensor","`",".","axis",":","Scalar","`","int","`","`","Tensor","`","representing","the","dimension","over","which","to","`","tf.gather","`",".","`","axis","`","must","be","relative","to","the","end","(","reading","left","to","right",")","thus","must","be","negative",".","Default","value",":","`","-1","`","(","i.e.",",","right-most",")",".","validate_args",":","Python","`","bool","`","indicating","whether","arguments","should","be","checked","for","correctness",".","name",":","Python","`","str","`",",","name","given","to","ops","managed","by","this","object",".","Raises",":","TypeError",":","if","`","not","dtype_util.is_integer","(","permutation.dtype",")","`",".","ValueError",":","if","`","permutation","`","does","not","contain","exactly","one","of","each","of","`","{","0",",","1",",","...",",","d","}","`",".","NotImplementedError",":","if","`","axis","`","is","not","known","prior","to","graph","execution",".","NotImplementedError",":","if","`","axis","`","is","not","negative","."]
code: def __init__(
      self, permutation, axis=-1, validate_args=False, name=None
  ):
      """Creates the `Permute` bijector.
  
      Args:
        permutation: An `int`-like vector-shaped `Tensor` representing the
          permutation to apply to the `axis` dimension of the transformed
          `Tensor`.
        axis: Scalar `int` `Tensor` representing the dimension over which to
          `tf.gather`. `axis` must be relative to the end (reading left to right)
          thus must be negative.
          Default value: `-1` (i.e., right-most).
        validate_args: Python `bool` indicating whether arguments should be
          checked for correctness.
        name: Python `str`, name given to ops managed by this object.
  
      Raises:
        TypeError: if `not dtype_util.is_integer(permutation.dtype)`.
        ValueError: if `permutation` does not contain exactly one of each of
          `{0, 1, ..., d}`.
        NotImplementedError: if `axis` is not known prior to graph execution.
        NotImplementedError: if `axis` is not negative.
      """
      parameters = dict(locals())
      with tf.name_scope(name or "permute") as name:
          axis = tensor_util.convert_nonref_to_tensor(
              axis, name="axis", as_shape_tensor=True
          )
          if not dtype_util.is_integer(axis.dtype):
              raise TypeError(
                  "axis.dtype ({}) should be `int`-like.".format(
                      dtype_util.name(axis.dtype)
                  )
              )
          axis_ = tf.get_static_value(axis)
          if axis_ is None:
              raise NotImplementedError(
                  "`axis` must be known prior to graph " "execution."
              )
          elif axis_ >= 0:
              raise NotImplementedError(
                  "`axis` must be relative the rightmost "
                  "dimension, i.e., negative."
              )
          forward_min_event_ndims = int(np.abs(axis_))
          self._axis = axis
  
          permutation = tensor_util.convert_nonref_to_tensor(
              permutation, name="permutation"
          )
          if not dtype_util.is_integer(permutation.dtype):
              raise TypeError(
                  "permutation.dtype ({}) should be `int`-like.".format(
                      dtype_util.name(permutation.dtype)
                  )
              )
          self._permutation = permutation
  
          super(Permute, self).__init__(
              forward_min_event_ndims=forward_min_event_ndims,
              is_constant_jacobian=True,
              validate_args=validate_args,
              parameters=parameters,
              name=name,
          )
  
file_path: probability/tensorflow_probability/python/bijectors/permute.py
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 dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  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 Permute object from inherited base classes: bijector with example: obj = Permute(permutation, axis, validate_args, name)