import tensorflow as tf

        rightmost_transposed_ndims = tf.convert_to_tensor(
            value=rightmost_transposed_ndims,
            dtype=np.int32,
            name='rightmost_transposed_ndims')
        rightmost_transposed_ndims_ = tf.get_static_value(
            rightmost_transposed_ndims)
        with tf.control_dependencies(_maybe_validate_rightmost_transposed_ndims(
            rightmost_transposed_ndims, validate_args)):
          rightmost_transposed_ndims = tf.identity(rightmost_transposed_ndims)
        perm = tf.range(
            start=rightmost_transposed_ndims - 1,
            limit=-1,
            delta=-1,
            name='perm')
      else:  # perm is not None:
        perm = tf.convert_to_tensor(value=perm, dtype=np.int32, name='perm')
