code: def invariant_factors(m, domain=None):
      """
      Return the tuple of abelian invariants for a matrix `m`
      (as in the Smith-Normal form)
  
      References
      ==========
  
      .. [1] https://en.wikipedia.org/wiki/Smith_normal_form#Algorithm
      .. [2] https://web.archive.org/web/20200331143852/https://sierra.nmsu.edu/morandi/notes/SmithNormalForm.pdf
  
      """
      dM = _to_domain(m, domain)
      factors = _invf(dM)
      factors = tuple(dM.domain.to_sympy(f) for f in factors)
      # XXX: deprecated.
      if hasattr(m, "ring"):
          if m.ring.is_PolynomialRing:
              K = m.ring
              to_poly = lambda f: Poly(f, K.symbols, domain=K.domain)
              factors = tuple(to_poly(f) for f in factors)
      return factors
  
file_path: sympy/sympy/matrices/normalforms.py
imports: from sympy.polys.domains.integerring import ZZ
  from sympy.polys.polytools import Poly
  from sympy.polys.matrices import DomainMatrix
  from sympy.polys.matrices.normalforms import smith_normal_form, invariant_factors, hermite_normal_form
label_desc: Use image node_id 3 for calling a global function with example usage: invariant_factors(m, domain) and returns: factors