parameters: (a, name="batch_matrix_transpose")
docstring: Transposes last two dimensions of batch matrix `a`.
  
    For example:
  
    ```python
    # Matrix with no batch dimension.
    # 'x' is [[1 2 3]
    #         [4 5 6]]
    tf.batch_matrixtranspose(x) ==> [[1 4]
                                     [2 5]
                                     [3 6]]
  
    # Matrix with two batch dimensions.
    # x.shape is [1, 2, 3, 4]
    # tf.batch_matrix_transpose(x) is shape [1, 2, 4, 3]
    ```
  
    Args:
      a: A `Tensor` with `rank >= 2`.
      name: A name for the operation (optional).
  
    Returns:
      A transposed batch matrix `Tensor`.
  
    Raises:
      ValueError:  If `a` is determined statically to have `rank < 2`.
docstring_summary: Transposes last two dimensions of batch matrix `a`.
docstring_tokens: Transposes last two dimensions of batch matrix a .
function: def batch_matrix_transpose(a, name="batch_matrix_transpose"):
    """Transposes last two dimensions of batch matrix `a`.
  
    For example:
  
    ```python
    # Matrix with no batch dimension.
    # 'x' is [[1 2 3]
    #         [4 5 6]]
    tf.batch_matrixtranspose(x) ==> [[1 4]
                                     [2 5]
                                     [3 6]]
  
    # Matrix with two batch dimensions.
    # x.shape is [1, 2, 3, 4]
    # tf.batch_matrix_transpose(x) is shape [1, 2, 4, 3]
    ```
  
    Args:
      a: A `Tensor` with `rank >= 2`.
      name: A name for the operation (optional).
  
    Returns:
      A transposed batch matrix `Tensor`.
  
    Raises:
      ValueError:  If `a` is determined statically to have `rank < 2`.
    """
    with ops.op_scope([a], name):
      a = ops.convert_to_tensor(a, name="a")
  
      # If we know the number of dimensions (statically), we can do two things:
      # 1. Check that `a` is a (batch) matrix.
      # 2. Use a python list for perm.  This preserves static shape information
      #    and avoids extra computations.
      a_shape = a.get_shape()
      ndims = a_shape.ndims
      if ndims is not None:
        if ndims < 2:
          raise ValueError(
              "Argument 'a' should be a (batch) matrix, with rank >= 2.  Found: "
              "%s" % a_shape)
        perm = list(range(ndims - 2)) + [ndims - 1] + [ndims - 2]
      else:
        a_rank = rank(a)
        perm = concat(
            0, (gen_math_ops._range(0, a_rank - 2, 1), [a_rank - 1, a_rank - 2]))
  
      return transpose(a, perm=perm)
function_tokens: def batch_matrix_transpose ( a , name = "batch_matrix_transpose" ) : with ops . op_scope ( [ a ] , name ) : a = ops . convert_to_tensor ( a , name = "a" ) # If we know the number of dimensions (statically), we can do two things: # 1. Check that `a` is a (batch) matrix. # 2. Use a python list for perm.  This preserves static shape information #    and avoids extra computations. a_shape = a . get_shape ( ) ndims = a_shape . ndims if ndims is not None : if ndims < 2 : raise ValueError ( "Argument 'a' should be a (batch) matrix, with rank >= 2.  Found: " "%s" % a_shape ) perm = list ( range ( ndims - 2 ) ) + [ ndims - 1 ] + [ ndims - 2 ] else : a_rank = rank ( a ) perm = concat ( 0 , ( gen_math_ops . _range ( 0 , a_rank - 2 , 1 ) , [ a_rank - 1 , a_rank - 2 ] ) ) return transpose ( a , perm = perm )