code: def _permutation_on_axis(ar, axis, rs, xp):
      try:
          return rs.permutation(ar, axis=axis)
      except TypeError:
          # numpy starts to support axis from 1.18
          if axis == 0:
              return rs.permutation(ar)
          indices = xp.arange(ar.shape[axis])
          rs.shuffle(indices)
          slc = (slice(None),) * axis + (indices,)
          return ar[slc]
  
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 1 for calling a global function with example usage: _permutation_on_axis(ar, axis, rs, xp) and returns: rs, ar, rs