code: def add_self_loops(a, value=1):
      """
      Sets the inner diagonals of `a` to `value`.
      :param a: a np.array or scipy.sparse matrix, the innermost two dimensions
      must be equal.
      :param value: value to set the diagonals to.
      :return: a np.array or scipy.sparse matrix with the same shape as `a`.
      """
      a = a.copy()
      if len(a.shape) < 2:
          raise ValueError("a must have at least rank 2")
      n = a.shape[-1]
      if n != a.shape[-2]:
          raise ValueError(
              "Innermost two dimensions must be equal. Got {}".format(
                  a.shape
              )
          )
      if sp.issparse(a):
          a = a.tolil()
          a.setdiag(value)
          return a.tocsr()
      else:
          idx = np.arange(n)
          a[..., idx, idx] = value
          return a
  
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 14 for calling a global function with example usage: add_self_loops(a, value) and returns: a, a