code: def khop_adj(g, k):
      """Return the matrix of :math:`A^k` where :math:`A` is the adjacency matrix of the graph
      :math:`g`.
  
      The returned matrix is a 32-bit float dense matrix on CPU. The graph must be homogeneous.
  
      Parameters
      ----------
      g : DGLGraph
          The input graph.
      k : int
          The :math:`k` in :math:`A^k`.
  
      Returns
      -------
      Tensor
          The returned tensor.
  
      Examples
      --------
      >>> import dgl
      >>> g = dgl.graph(([0,1,2,3,4,0,1,2,3,4], [0,1,2,3,4,1,2,3,4,0]))
      >>> dgl.khop_adj(g, 1)
      tensor([[1., 1., 0., 0., 0.],
              [0., 1., 1., 0., 0.],
              [0., 0., 1., 1., 0.],
              [0., 0., 0., 1., 1.],
              [1., 0., 0., 0., 1.]])
      >>> dgl.khop_adj(g, 3)
      tensor([[1., 3., 3., 1., 0.],
              [0., 1., 3., 3., 1.],
              [1., 0., 1., 3., 3.],
              [3., 1., 0., 1., 3.],
              [3., 3., 1., 0., 1.]])
      """
      assert g.is_homogeneous, "only homogeneous graph is supported"
      adj_k = (
          g.adj_external(
              transpose=False, scipy_fmt=g.formats()["created"][0]
          )
          ** k
      )
      return F.tensor(adj_k.todense().astype(np.float32))
  
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 11 for calling a global function with example usage: khop_adj(g, k) and returns: F