code: def dup_real_imag(f, K):
      """
      Return bivariate polynomials ``f1`` and ``f2``, such that ``f = f1 + f2*I``.
  
      Examples
      ========
  
      >>> from sympy.polys import ring, ZZ
      >>> R, x,y = ring("x,y", ZZ)
  
      >>> R.dup_real_imag(x**3 + x**2 + x + 1)
      (x**3 + x**2 - 3*x*y**2 + x - y**2 + 1, 3*x**2*y + 2*x*y - y**3 + y)
  
      """
      if not K.is_ZZ and not K.is_QQ:
          raise DomainError(
              "computing real and imaginary parts is not supported over %s"
              % K
          )
  
      f1 = dmp_zero(1)
      f2 = dmp_zero(1)
  
      if not f:
          return f1, f2
  
      g = [[[K.one, K.zero]], [[K.one], []]]
      h = dmp_ground(f[0], 2)
  
      for c in f[1:]:
          h = dmp_mul(h, g, 2, K)
          h = dmp_add_term(h, dmp_ground(c, 1), 0, 2, K)
  
      H = dup_to_raw_dict(h)
  
      for k, h in H.items():
          m = k % 4
  
          if not m:
              f1 = dmp_add(f1, h, 1, K)
          elif m == 1:
              f2 = dmp_add(f2, h, 1, K)
          elif m == 2:
              f1 = dmp_sub(f1, h, 1, K)
          else:
              f2 = dmp_sub(f2, h, 1, K)
  
      return f1, f2
  
imports: from sympy.polys.densearith import dup_add_term, dmp_add_term, dup_lshift, dup_add, dmp_add, dup_sub, dmp_sub, dup_mul, dmp_mul, dup_sqr, dup_div, dup_rem, dmp_rem, dmp_expand, dup_mul_ground, dmp_mul_ground, dup_quo_ground, dmp_quo_ground, dup_exquo_ground, dmp_exquo_ground
  from sympy.polys.densebasic import dup_strip, dmp_strip, dup_convert, dmp_convert, dup_degree, dmp_degree, dmp_to_dict, dmp_from_dict, dup_LC, dmp_LC, dmp_ground_LC, dup_TC, dmp_TC, dmp_zero, dmp_ground, dmp_zero_p, dup_to_raw_dict, dup_from_raw_dict, dmp_zeros
  from sympy.polys.polyerrors import MultivariatePolynomialError, DomainError
  from sympy.utilities import variations
  from math import ceil, log
label_desc: Use image node_id 28 for calling a global function with example usage: dup_real_imag(f, K) and returns: f1,  f2, f1,  f2