code: def mpf_perturb(x, eps_sign, prec, rnd):
      """
      For nonzero x, calculate x + eps with directed rounding, where
      eps < prec relatively and eps has the given sign (0 for
      positive, 1 for negative).
  
      With rounding to nearest, this is taken to simply normalize
      x to the given precision.
      """
      if rnd == round_nearest:
          return mpf_pos(x, prec, rnd)
      sign, man, exp, bc = x
      eps = (eps_sign, MPZ_ONE, exp + bc - prec - 1, 1)
      if sign:
          away = (rnd in (round_down, round_ceiling)) ^ eps_sign
      else:
          away = (rnd in (round_up, round_ceiling)) ^ eps_sign
      if away:
          return mpf_add(x, eps, prec, rnd)
      else:
          return mpf_pos(x, prec, rnd)
  
imports: import math
  from bisect import bisect
  import sys
  from .backend import MPZ, MPZ_TYPE, MPZ_ZERO, MPZ_ONE, MPZ_TWO, MPZ_FIVE, BACKEND, STRICT, HASH_MODULUS, HASH_BITS, gmpy, sage, sage_utils
  from .libintmath import giant_steps, trailtable, bctable, lshift, rshift, bitcount, trailing, sqrt_fixed, numeral, isqrt, isqrt_fast, sqrtrem, bin_to_radix
label_desc: Use image node_id 52 for calling a global function with example usage: mpf_perturb(x, eps_sign, prec, rnd) and returns: mpf_pos, mpf_add, mpf_pos