code: def permutation(random_state, x, axis=0, chunk_size=None):
      r"""
      Randomly permute a sequence, or return a permuted range.
  
      Parameters
      ----------
      x : int or array_like
          If `x` is an integer, randomly permute ``mt.arange(x)``.
          If `x` is an array, make a copy and shuffle the elements
          randomly.
      axis : int, optional
          The axis which `x` is shuffled along. Default is 0.
      chunk_size : : int or tuple of int or tuple of ints, optional
          Desired chunk size on each dimension
      Returns
      -------
      out : Tensor
          Permuted sequence or tensor range.
      Examples
      --------
      >>> import mars.tensor as mt
      >>> rng = mt.random.RandomState()
      >>> rng.permutation(10).execute()
      array([1, 2, 3, 7, 9, 8, 0, 6, 4, 5]) # random
      >>> rng.permutation([1, 4, 9, 12, 15]).execute()
      array([ 9,  4, 12,  1, 15]) # random
      >>> arr = mt.arange(9).reshape((3, 3))
      >>> rng.permutation(arr).execute()
      array([[3, 4, 5], # random
             [6, 7, 8],
             [0, 1, 2]])
      >>> rng.permutation("abc")
      Traceback (most recent call last):
          ...
      numpy.AxisError: x must be an integer or at least 1-dimensional
      """
      if isinstance(x, (Integral, np.integer)):
          from ..datasource import arange
  
          x = arange(x, chunk_size=chunk_size)
      else:
          x = astensor(x, chunk_size=chunk_size)
          if x.ndim < 1:
              raise np.AxisError(
                  "x must be an integer or at least 1-dimensional"
              )
  
      axis = validate_axis(x.ndim, axis)
      seed = gen_random_seeds(1, random_state.to_numpy())[0]
      op = TensorPermutation(
          seed=seed, axis=axis, dtype=x.dtype, gpu=x.op.gpu
      )
      return op(x)
  
imports: import itertools
  from numbers import Integral
  import numpy
  from ...None import opcodes
  from ...core.operand import OperandStage
  from ...serialization.serializables import KeyField, Int32Field
  from ..operands import TensorOperandMixin, TensorShuffleProxy
  from ..utils import gen_random_seeds, validate_axis
  from ..datasource import tensor
  from ..array_utils import as_same_device, device
  from .core import TensorRandomMapReduceOperand
label_desc: Use image node_id 2 for calling a global function with example usage: permutation(random_state, x, axis, chunk_size) and returns: op