code: def gamma_fixed_taylor(xmpf, x, wp, prec, rnd, type):
      # Determine nearest multiple of N/2
      # n = int(x >> (wp-1))
      # steps = (n-1)>>1
      nearest_int = ((x >> (wp - 1)) + MPZ_ONE) >> 1
      one = MPZ_ONE << wp
      coeffs, cwp = gamma_taylor_coefficients(wp)
      if nearest_int > 0:
          r = one
          for i in xrange(nearest_int - 1):
              x -= one
              r = (r * x) >> wp
          x -= one
          p = MPZ_ZERO
          for c in coeffs:
              p = c + ((x * p) >> wp)
          p >>= cwp - wp
          if type == 0:
              return from_man_exp((r << wp) // p, -wp, prec, rnd)
          if type == 2:
              return mpf_shift(
                  from_rational(p, (r << wp), prec, rnd), wp
              )
          if type == 3:
              return mpf_log(
                  mpf_abs(from_man_exp((r << wp) // p, -wp)), prec, rnd
              )
      else:
          r = one
          for i in xrange(-nearest_int):
              r = (r * x) >> wp
              x += one
          p = MPZ_ZERO
          for c in coeffs:
              p = c + ((x * p) >> wp)
          p >>= cwp - wp
          if wp - bitcount(abs(x)) > 10:
              # pass very close to 0, so do floating-point multiply
              g = mpf_add(xmpf, from_int(-nearest_int))  # exact
              r = from_man_exp(p * r, -wp - wp)
              r = mpf_mul(r, g, wp)
              if type == 0:
                  return mpf_div(fone, r, prec, rnd)
              if type == 2:
                  return mpf_pos(r, prec, rnd)
              if type == 3:
                  return mpf_log(
                      mpf_abs(mpf_div(fone, r, wp)), prec, rnd
                  )
          else:
              r = from_man_exp(x * p * r, -3 * wp)
              if type == 0:
                  return mpf_div(fone, r, prec, rnd)
              if type == 2:
                  return mpf_pos(r, prec, rnd)
              if type == 3:
                  return mpf_neg(mpf_log(mpf_abs(r), prec, rnd))
  
imports: import math
  import sys
  from .backend import xrange
  from .backend import MPZ, MPZ_ZERO, MPZ_ONE, MPZ_THREE, gmpy
  from .libintmath import list_primes, ifac, ifac2, moebius
  from .libmpf import round_floor, round_ceiling, round_down, round_up, round_nearest, round_fast, lshift, sqrt_fixed, isqrt_fast, fzero, fone, fnone, fhalf, ftwo, finf, fninf, fnan, from_int, to_int, to_fixed, from_man_exp, from_rational, mpf_pos, mpf_neg, mpf_abs, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_sqrt, mpf_pow_int, mpf_rdiv_int, mpf_perturb, mpf_le, mpf_lt, mpf_gt, mpf_shift, negative_rnd, reciprocal_rnd, bitcount, to_float, mpf_floor, mpf_sign, ComplexResult
  from .libelefun import constant_memo, def_mpf_constant, mpf_pi, pi_fixed, ln2_fixed, log_int_fixed, mpf_ln2, mpf_exp, mpf_log, mpf_pow, mpf_cosh, mpf_cos_sin, mpf_cosh_sinh, mpf_cos_sin_pi, mpf_cos_pi, mpf_sin_pi, ln_sqrt2pi_fixed, mpf_ln_sqrt2pi, sqrtpi_fixed, mpf_sqrtpi, cos_sin_fixed, exp_fixed
  from .libmpc import mpc_zero, mpc_one, mpc_half, mpc_two, mpc_abs, mpc_shift, mpc_pos, mpc_neg, mpc_add, mpc_sub, mpc_mul, mpc_div, mpc_add_mpf, mpc_mul_mpf, mpc_div_mpf, mpc_mpf_div, mpc_mul_int, mpc_pow_int, mpc_log, mpc_exp, mpc_pow, mpc_cos_pi, mpc_sin_pi, mpc_reciprocal, mpc_square, mpc_sub_mpf
label_desc: Use image node_id 30 for calling a global function with example usage: gamma_fixed_taylor(xmpf, x, wp, prec, rnd, type) and returns: from_man_exp, mpf_shift, mpf_log, mpf_div, mpf_pos, mpf_log, mpf_div, mpf_pos, mpf_neg