code: def degree_power(A, k):
      r"""
      Computes \(\D^{k}\) from the given adjacency matrix. Useful for computing
      normalised Laplacian.
      :param A: rank 2 array or sparse matrix.
      :param k: exponent to which elevate the degree matrix.
      :return: if A is a dense array, a dense array; if A is sparse, a sparse
      matrix in DIA format.
      """
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          degrees = np.power(np.array(A.sum(1)), k).ravel()
      degrees[np.isinf(degrees)] = 0.0
      if sp.issparse(A):
          D = sp.diags(degrees)
      else:
          D = np.diag(degrees)
      return D
  
imports: import copy
  import warnings
  from functools import partial
  import numpy
  import tensorflow
  from scipy import linalg
  from scipy import sparse
  from scipy.sparse.linalg import ArpackNoConvergence
label_desc: Use image node_id 2 for calling a global function with example usage: degree_power(A, k) and returns: D