code: def root(ctx, x, n, k=0):
      n = int(n)
      x = ctx.convert(x)
      if k:
          # Special case: there is an exact real root
          if (
              (n & 1 and 2 * k == n - 1)
              and (not ctx.im(x))
              and (ctx.re(x) < 0)
          ):
              return -ctx.root(-x, n)
          # Multiply by root of unity
          prec = ctx.prec
          try:
              ctx.prec += 10
              v = ctx.root(x, n, 0) * ctx._rootof1(k, n)
          finally:
              ctx.prec = prec
          return +v
      return ctx._nthroot(x, n)
  
imports: from ..libmp.backend import xrange
  import math
  import cmath
label_desc: Use image node_id 24 for calling a global function with example usage: root(ctx, x, n, k) and returns: ctx, unknown, unknown