code: def test_sparse_broadcast_add_sub():
      def check_broadcast_add(mx_lhs, mx_rhs, np_lhs, np_rhs, dtype):
          assert_almost_equal(
              mx.nd.sparse.add(mx_lhs, mx_rhs).asnumpy(),
              np.add(np_lhs, np_rhs),
              atol=1e-4,
          )
  
      def check_broadcast_sub(mx_lhs, mx_rhs, np_lhs, np_rhs, dtype):
          assert_almost_equal(
              mx.nd.sparse.subtract(mx_lhs, mx_rhs).asnumpy(),
              np.subtract(np_lhs, np_rhs),
              atol=1e-4,
          )
  
      stype = "csr"
      shape = rand_shape_2d()
      num_rows = shape[0]
      num_cols = shape[1]
      for density in [0.1 * i for i in range(10)]:
          mx_lhs = rand_ndarray(shape, stype, density)
          np_lhs = mx_lhs.asnumpy()
          mx_rhs_row_2D = rand_ndarray((1, num_cols), "default")
          mx_rhs_row_1D = mx_rhs_row_2D.reshape((num_cols))
          mx_rhs_col = rand_ndarray((num_rows, 1), "default")
          mx_rhs_scalar_2D = rand_ndarray((1, 1), "default")
          mx_rhs_scalar_1D = mx_rhs_scalar_2D.reshape((1,))
          for mx_rhs in [
              mx_rhs_row_2D,
              mx_rhs_row_1D,
              mx_rhs_col,
              mx_rhs_scalar_2D,
              mx_rhs_scalar_1D,
          ]:
              np_rhs = mx_rhs.asnumpy()
              check_broadcast_add(
                  mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32
              )
              check_broadcast_sub(
                  mx_lhs, mx_rhs, np_lhs, np_rhs, np.float32
              )
              check_broadcast_add(
                  mx_rhs, mx_lhs, np_rhs, np_lhs, np.float32
              )
              check_broadcast_sub(
                  mx_rhs, mx_lhs, np_rhs, np_lhs, np.float32
              )
  
imports: from mxnet.test_utils import *
  from mxnet.base import MXNetError
  import pytest
  from common import assertRaises
  import random
  import warnings
label_desc: Use image node_id 31 for calling a global function with example usage: test_sparse_broadcast_add_sub() without return types