code: def test_hermite_normal():
      m = DM(
          [
              [2, 7, 17, 29, 41],
              [3, 11, 19, 31, 43],
              [5, 13, 23, 37, 47],
          ],
          ZZ,
      )
      hnf = DM([[1, 0, 0], [0, 2, 1], [0, 0, 1]], ZZ)
      assert hermite_normal_form(m) == hnf
      assert hermite_normal_form(m, D=ZZ(2)) == hnf
      assert hermite_normal_form(m, D=ZZ(2), check_rank=True) == hnf
  
      m = m.transpose()
      hnf = DM(
          [
              [37, 0, 19],
              [222, -6, 113],
              [48, 0, 25],
              [0, 2, 1],
              [0, 0, 1],
          ],
          ZZ,
      )
      assert hermite_normal_form(m) == hnf
      raises(
          DMShapeError, lambda: _hermite_normal_form_modulo_D(m, ZZ(96))
      )
      raises(
          DMDomainError,
          lambda: _hermite_normal_form_modulo_D(m, QQ(96)),
      )
  
      m = DM(
          [
              [8, 28, 68, 116, 164],
              [3, 11, 19, 31, 43],
              [5, 13, 23, 37, 47],
          ],
          ZZ,
      )
      hnf = DM([[4, 0, 0], [0, 2, 1], [0, 0, 1]], ZZ)
      assert hermite_normal_form(m) == hnf
      assert hermite_normal_form(m, D=ZZ(8)) == hnf
      assert hermite_normal_form(m, D=ZZ(8), check_rank=True) == hnf
  
      m = DM(
          [[10, 8, 6, 30, 2], [45, 36, 27, 18, 9], [5, 4, 3, 2, 1]], ZZ
      )
      hnf = DM([[26, 2], [0, 9], [0, 1]], ZZ)
      assert hermite_normal_form(m) == hnf
  
      m = DM([[2, 7], [0, 0], [0, 0]], ZZ)
      hnf = DM([[1], [0], [0]], ZZ)
      assert hermite_normal_form(m) == hnf
  
      m = DM([[-2, 1], [0, 1]], ZZ)
      hnf = DM([[2, 1], [0, 1]], ZZ)
      assert hermite_normal_form(m) == hnf
  
      m = DomainMatrix([[QQ(1)]], (1, 1), QQ)
      raises(DMDomainError, lambda: hermite_normal_form(m))
      raises(DMDomainError, lambda: _hermite_normal_form(m))
      raises(
          DMDomainError, lambda: _hermite_normal_form_modulo_D(m, ZZ(1))
      )
  
file_path: sympy/sympy/polys/matrices/tests/test_normalforms.py
imports: from sympy.testing.pytest import raises
  from sympy.core.symbol import Symbol
  from sympy.polys.matrices.normalforms import invariant_factors, smith_normal_form, hermite_normal_form, _hermite_normal_form, _hermite_normal_form_modulo_D
  from sympy.polys.domains import ZZ, QQ
  from sympy.polys.matrices import DomainMatrix, DM
  from sympy.polys.matrices.exceptions import DMDomainError, DMShapeError
label_desc: Use image node_id 2 for calling a global function with example usage: test_hermite_normal() without return types