code: def _mathfun_real(f_real, f_complex):
      def f(x, **kwargs):
          if type(x) is float:
              return f_real(x)
          if type(x) is complex:
              return f_complex(x)
          try:
              x = float(x)
              return f_real(x)
          except (TypeError, ValueError):
              x = complex(x)
              return f_complex(x)
  
      f.__name__ = f_real.__name__
      return f
  
imports: import operator
  import math
  import cmath
label_desc: Use image node_id 1 for calling a global function with example usage: _mathfun_real(f_real, f_complex) and returns: f, f_real, f_complex, f_real, f_complex