code: def _gen_indices(shape, axis, xp):
      ap = xp.swapaxes(xp.empty(shape, dtype=np.int64), axis, -1)
      ap[...] = xp.arange(shape[axis]).reshape(
          (1,) * (ap.ndim - 1) + (-1,)
      )
      return xp.swapaxes(ap, -1, axis)
  
imports: import itertools
  import numpy
  from ...None import opcodes
  from ...config import options
  from ...core import ExecutableTuple, recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import FieldTypes, KeyField, Int64Field, Int32Field, BoolField, StringField, ListField
  from ...utils import ceildiv, flatten
  from ..array_utils import as_same_device, device
  from ..core import TensorOrder
  from ..datasource import tensor
  from ..operands import TensorOperand, TensorOperandMixin
  from ..utils import validate_axis, validate_order
  from .sort import _validate_sort_psrs_kinds
label_desc: Use image node_id 1 for calling a global function with example usage: _gen_indices(shape, axis, xp) and returns: xp