code: def test_XXM_from_flat_nz(DM):
      T = type(DM([[0]]))
      elements = [ZZ(1), ZZ(2), ZZ(3)]
      indices = ((0, 0), (0, 1), (2, 2))
      data = (indices, (3, 3))
      result = DM([[1, 2, 0], [0, 0, 0], [0, 0, 3]])
      assert T.from_flat_nz(elements, data, ZZ) == result
      raises(
          DMBadInputError,
          lambda: T.from_flat_nz(elements, (indices, (2, 3)), ZZ),
      )
  
imports: from sympy.external.gmpy import GROUND_TYPES
  from sympy import ZZ, QQ, GF, ZZ_I, symbols
  from sympy.polys.matrices.exceptions import DMBadInputError, DMDomainError, DMNonSquareMatrixError, DMNonInvertibleMatrixError, DMShapeError
  from sympy.polys.matrices.domainmatrix import DM, DomainMatrix, DDM, SDM, DFM
  from sympy.testing.pytest import raises, skip
  import pytest
label_desc: Use image node_id 27 for calling a global function with example usage: test_XXM_from_flat_nz(DM) without return types