code: def transpose(a, axes=None):
      """
      Permute the dimensions of a tensor.
  
      Parameters
      ----------
      a : array_like
          Input tensor.
      axes : list of ints, optional
          By default, reverse the dimensions, otherwise permute the axes
          according to the values given.
  
      Returns
      -------
      p : Tensor
          `a` with its axes permuted.  A view is returned whenever
          possible.
  
      See Also
      --------
      moveaxis
      argsort
  
      Notes
      -----
      Use `transpose(a, argsort(axes))` to invert the transposition of tensors
      when using the `axes` keyword argument.
  
      Transposing a 1-D array returns an unchanged view of the original tensor.
  
      Examples
      --------
      >>> import mars.tensor as mt
  
      >>> x = mt.arange(4).reshape((2,2))
      >>> x.execute()
      array([[0, 1],
             [2, 3]])
  
      >>> mt.transpose(x).execute()
      array([[0, 2],
             [1, 3]])
  
      >>> x = mt.ones((1, 2, 3))
      >>> mt.transpose(x, (1, 0, 2)).shape
      (2, 1, 3)
  
      """
      a = astensor(a)
      if axes:
          if len(axes) != a.ndim:
              raise ValueError("axes don't match tensor")
  
      if not axes:
          axes = list(range(a.ndim))[::-1]
      else:
          axes = list(axes)
      op = TensorTranspose(axes, dtype=a.dtype, sparse=a.issparse())
      return op(a)
  
imports: import numpy
  from ...None import opcodes
  from ...serialization.serializables import FieldTypes, KeyField, ListField
  from ..operands import TensorHasInput, TensorOperandMixin
  from ..datasource import tensor
  from ..array_utils import as_same_device, device
  from ..utils import reverse_order
  from ..core import TensorOrder
label_desc: Use image node_id 2 for calling a global function with example usage: transpose(a, axes) and returns: op