code: def _gcdex(a, b):
      r"""
      This supports the functions that compute Hermite Normal Form.
  
      Explanation
      ===========
  
      Let x, y be the coefficients returned by the extended Euclidean
      Algorithm, so that x*a + y*b = g. In the algorithms for computing HNF,
      it is critical that x, y not only satisfy the condition of being small
      in magnitude -- namely that |x| <= |b|/g, |y| <- |a|/g -- but also that
      y == 0 when a | b.
  
      """
      x, y, g = ZZ.gcdex(a, b)
      if a != 0 and b % a == 0:
          y = 0
          x = -1 if a < 0 else 1
      return x, y, g
  
file_path: sympy/sympy/polys/matrices/normalforms.py
imports: from collections import defaultdict
  from .domainmatrix import DomainMatrix
  from .exceptions import DMDomainError, DMShapeError
  from sympy.ntheory.modular import symmetric_residue
  from sympy.polys.domains import QQ, ZZ
label_desc: Use image node_id 4 for calling a global function with example usage: _gcdex(a, b) and returns: x,  y,  g