code: def degrees(A):
      """
      Computes the degrees of each node in A, dealing with sparse A and batch mode
      automatically.
      :param A: Tensor or SparseTensor with rank k = {2, 3}.
      :return: Tensor or SparseTensor of rank k - 1.
      """
      if K.is_sparse(A):
          D = tf.sparse.reduce_sum(A, axis=-1)
      else:
          D = tf.reduce_sum(A, axis=-1)
  
      return D
  
imports: import tensorflow
  from tensorflow.keras import backend
  from .None import ops
label_desc: Use image node_id 2 for calling a global function with example usage: degrees(A) and returns: D