code: def test_check_formal_conditions_for_maximal_order():
      T = Poly(cyclotomic_poly(5, x))
      A = PowerBasis(T)
      B = A.submodule_from_matrix(2 * DomainMatrix.eye(4, ZZ))
      C = B.submodule_from_matrix(3 * DomainMatrix.eye(4, ZZ))
      D = A.submodule_from_matrix(DomainMatrix.eye(4, ZZ)[:, :-1])
      # Is a direct submodule of a power basis, but lacks 1 as first generator:
      raises(
          StructureError,
          lambda: _check_formal_conditions_for_maximal_order(B),
      )
      # Is not a direct submodule of a power basis:
      raises(
          StructureError,
          lambda: _check_formal_conditions_for_maximal_order(C),
      )
      # Is direct submod of pow basis, and starts with 1, but not sq/max rank/HNF:
      raises(
          StructureError,
          lambda: _check_formal_conditions_for_maximal_order(D),
      )
  
imports: from math import prod
  from sympy import QQ, ZZ
  from sympy.abc import x, theta
  from sympy.ntheory import factorint
  from sympy.ntheory.residue_ntheory import n_order
  from sympy.polys import Poly, cyclotomic_poly
  from sympy.polys.matrices import DomainMatrix
  from sympy.polys.numberfields.basis import round_two
  from sympy.polys.numberfields.exceptions import StructureError
  from sympy.polys.numberfields.modules import PowerBasis, to_col
  from sympy.polys.numberfields.primes import prime_decomp, _two_elt_rep, _check_formal_conditions_for_maximal_order
  from sympy.testing.pytest import raises
label_desc: Use image node_id 1 for calling a global function with example usage: test_check_formal_conditions_for_maximal_order() without return types