code: def dirichlet(ctx, s, chi=[1], derivative=0):
      s = ctx.convert(s)
      q = len(chi)
      d = int(derivative)
      if d > 2:
          raise NotImplementedError("arbitrary order derivatives")
      prec = ctx.prec
      try:
          ctx.prec += 10
          if s == 1:
              have_pole = True
              for x in chi:
                  if x and x != 1:
                      have_pole = False
                      h = +ctx.eps
                      ctx.prec *= 2 * (d + 1)
                      s += h
              if have_pole:
                  return +ctx.inf
          z = ctx.zero
          for p in range(1, q + 1):
              if chi[p % q]:
                  if d == 1:
                      z += chi[p % q] * (
                          ctx.zeta(s, (p, q), 1)
                          - ctx.zeta(s, (p, q)) * ctx.log(q)
                      )
                  else:
                      z += chi[p % q] * ctx.zeta(s, (p, q))
          z /= q**s
      finally:
          ctx.prec = prec
      return +z
  
imports: from __future__ import print_function
  from ..libmp.backend import xrange
  from .functions import defun, defun_wrapped, defun_static
label_desc: Use image node_id 28 for calling a global function with example usage: dirichlet(ctx, s, chi, derivative) and returns: unknown, unknown