code: def dmp_zz_collins_resultant(f, g, u, K):
      """
      Collins's modular resultant algorithm in `Z[X]`.
  
      Examples
      ========
  
      >>> from sympy.polys import ring, ZZ
      >>> R, x,y = ring("x,y", ZZ)
  
      >>> f = x + y + 2
      >>> g = 2*x*y + x + 3
  
      >>> R.dmp_zz_collins_resultant(f, g)
      -2*y**2 - 5*y + 1
  
      """
  
      n = dmp_degree(f, u)
      m = dmp_degree(g, u)
  
      if n < 0 or m < 0:
          return dmp_zero(u - 1)
  
      A = dmp_max_norm(f, u, K)
      B = dmp_max_norm(g, u, K)
  
      a = dmp_ground_LC(f, u, K)
      b = dmp_ground_LC(g, u, K)
  
      v = u - 1
  
      B = K(2) * K.factorial(K(n + m)) * A**m * B**n
      r, p, P = dmp_zero(v), K.one, K.one
  
      from sympy.ntheory import nextprime
  
      while P <= B:
          p = K(nextprime(p))
  
          while not (a % p) or not (b % p):
              p = K(nextprime(p))
  
          F = dmp_ground_trunc(f, p, u, K)
          G = dmp_ground_trunc(g, p, u, K)
  
          try:
              R = dmp_zz_modular_resultant(F, G, p, u, K)
          except HomomorphismFailed:
              continue
  
          if K.is_one(P):
              r = R
          else:
              r = dmp_apply_pairs(r, R, _collins_crt, (P, p, K), v, K)
  
          P *= p
  
      return r
  
imports: from sympy.polys.densearith import dup_sub_mul, dup_neg, dmp_neg, dmp_add, dmp_sub, dup_mul, dmp_mul, dmp_pow, dup_div, dmp_div, dup_rem, dup_quo, dmp_quo, dup_prem, dmp_prem, dup_mul_ground, dmp_mul_ground, dmp_mul_term, dup_quo_ground, dmp_quo_ground, dup_max_norm, dmp_max_norm
  from sympy.polys.densebasic import dup_strip, dmp_raise, dmp_zero, dmp_one, dmp_ground, dmp_one_p, dmp_zero_p, dmp_zeros, dup_degree, dmp_degree, dmp_degree_in, dup_LC, dmp_LC, dmp_ground_LC, dmp_multi_deflate, dmp_inflate, dup_convert, dmp_convert, dmp_apply_pairs
  from sympy.polys.densetools import dup_clear_denoms, dmp_clear_denoms, dup_diff, dmp_diff, dup_eval, dmp_eval, dmp_eval_in, dup_trunc, dmp_ground_trunc, dup_monic, dmp_ground_monic, dup_primitive, dmp_ground_primitive, dup_extract, dmp_ground_extract
  from sympy.polys.galoistools import gf_int, gf_crt
  from sympy.polys.polyconfig import query
  from sympy.polys.polyerrors import MultivariatePolynomialError, HeuristicGCDFailed, HomomorphismFailed, NotInvertible, DomainError
label_desc: Use image node_id 20 for calling a global function with example usage: dmp_zz_collins_resultant(f, g, u, K) and returns: r, dmp_zero