code: def degree_matrix(A):
      """
      Computes the degree matrix of the given adjacency matrix.
      :param A: rank 2 array or sparse matrix.
      :return: if A is a dense array, a dense array; if A is sparse, a sparse
      matrix in DIA format.
      """
      degrees = np.array(A.sum(1)).flatten()
      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 1 for calling a global function with example usage: degree_matrix(A) and returns: D