code: def dup_trunc(f, p, K):
      """
      Reduce a ``K[x]`` polynomial modulo a constant ``p`` in ``K``.
  
      Examples
      ========
  
      >>> from sympy.polys import ring, ZZ
      >>> R, x = ring("x", ZZ)
  
      >>> R.dup_trunc(2*x**3 + 3*x**2 + 5*x + 7, ZZ(3))
      -x**3 - x + 1
  
      """
      if K.is_ZZ:
          g = []
  
          for c in f:
              c = c % p
  
              if c > p // 2:
                  g.append(c - p)
              else:
                  g.append(c)
      elif K.is_FiniteField:
          # XXX: python-flint's nmod does not support %
          pi = int(p)
          g = [K(int(c) % pi) for c in f]
      else:
          g = [c % p for c in f]
  
      return dup_strip(g)
  
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 17 for calling a global function with example usage: dup_trunc(f, p, K) and returns: dup_strip