code: def rs_pow(p1, n, x, prec):
      """
      Return ``p1**n`` modulo ``O(x**prec)``
  
      Examples
      ========
  
      >>> from sympy.polys.domains import QQ
      >>> from sympy.polys.rings import ring
      >>> from sympy.polys.ring_series import rs_pow
      >>> R, x = ring('x', QQ)
      >>> p = x + 1
      >>> rs_pow(p, 4, x, 3)
      6*x**2 + 4*x + 1
      """
      R = p1.ring
      if isinstance(n, Rational):
          np = int(n.p)
          nq = int(n.q)
          if nq != 1:
              res = rs_nth_root(p1, nq, x, prec)
              if np != 1:
                  res = rs_pow(res, np, x, prec)
          else:
              res = rs_pow(p1, np, x, prec)
          return res
  
      n = as_int(n)
      if n == 0:
          if p1:
              return R(1)
          else:
              raise ValueError("0**0 is undefined")
      if n < 0:
          p1 = rs_pow(p1, -n, x, prec)
          return rs_series_inversion(p1, x, prec)
      if n == 1:
          return rs_trunc(p1, x, prec)
      if n == 2:
          return rs_square(p1, x, prec)
      if n == 3:
          p2 = rs_square(p1, x, prec)
          return rs_mul(p1, p2, x, prec)
      p = R(1)
      while 1:
          if n & 1:
              p = rs_mul(p1, p, x, prec)
              n -= 1
              if not n:
                  break
          p1 = rs_square(p1, x, prec)
          n = n // 2
      return p
  
imports: from sympy.polys.domains import QQ, EX
  from sympy.polys.rings import PolyElement, ring, sring
  from sympy.polys.polyerrors import DomainError
  from sympy.polys.monomials import monomial_min, monomial_mul, monomial_div, monomial_ldiv
  from mpmath.libmp.libintmath import ifac
  from sympy.core import PoleError, Function, Expr
  from sympy.core.numbers import Rational
  from sympy.core.intfunc import igcd
  from sympy.functions import sin, cos, tan, atan, exp, atanh, tanh, log, ceiling
  from sympy.utilities.misc import as_int
  from mpmath.libmp.libintmath import giant_steps
  import math
label_desc: Use image node_id 9 for calling a global function with example usage: rs_pow(p1, n, x, prec) and returns: p, res, rs_series_inversion, rs_trunc, rs_square, rs_mul, R