code: def metis_perm(g, k):
      r"""Return nodes permutation according to ``'metis'`` algorithm.
  
      For internal use.
  
      Parameters
      ----------
      g : DGLGraph
          The homogeneous graph.
      k: int
          The partition parts number.
  
      Returns
      -------
      iterable[int]
          The nodes permutation.
      """
      pids = metis_partition_assignment(
          g if g.device == F.cpu() else g.to(F.cpu()), k
      )
      pids = F.asnumpy(pids)
      return np.argsort(pids).copy()
  
imports: import copy
  from collections.abc import Iterable, Mapping
  import numpy
  import scipy.sparse
  import scipy.sparse.linalg
  from ..utils import version
  from ..None import backend, batch, convert, function, ndarray, subgraph, utils
  from .._ffi.function import _init_api
  from ..base import dgl_warning, DGLError, EID, NID
  from ..frame import Frame
  from ..heterograph import DGLGraph
  from ..heterograph_index import create_heterograph_from_relations, create_metagraph_index
  from ..partition import metis_partition, metis_partition_assignment, partition_graph_with_halo
  from ..sampling.neighbor import sample_neighbors
label_desc: Use image node_id 32 for calling a global function with example usage: metis_perm(g, k) and returns: np