def run_typed_fn(fn, args, backend = None):
  actual_types = tuple(type_conv.typeof(arg) for arg in  args)
  expected_types = fn.input_types
  assert actual_types == expected_types, \
    "Arg type mismatch, expected %s but got %s" % \
    (expected_types, actual_types)

      
  if backend is None:
    backend = config.backend
  
  if backend == 'c':
    return c_backend.run(fn, args)
   
  elif backend == 'openmp':
    return openmp_backend.run(fn, args)
  
  elif backend == 'cuda':
    # only selectively import cuda_backend since it required PyCUDA
    from .. import cuda_backend 
    return cuda_backend.run(fn, args)
  
  elif backend == 'llvm':
    from ..llvm_backend.llvm_context import global_context
    from ..llvm_backend import generic_value_to_python 
    from ..llvm_backend import ctypes_to_generic_value, compile_fn 
    lowered_fn = pipeline.lowering.apply(fn)
    llvm_fn = compile_fn(lowered_fn).llvm_fn

    ctypes_inputs = [t.from_python(v) 
                   for (v,t) 
                   in zip(args, expected_types)]
    gv_inputs = [ctypes_to_generic_value(cv, t) 
                 for (cv,t) 
                 in zip(ctypes_inputs, expected_types)]
    exec_engine = global_context.exec_engine
    gv_return = exec_engine.run_function(llvm_fn, gv_inputs)
    return generic_value_to_python(gv_return, fn.return_type)

  elif backend == "interp":
    from .. import interp 
    fn = pipeline.loopify(fn)
    return interp.eval_fn(fn, args)
  
  else:
    assert False, backend % "Unknown backend %s"
dataset/ETHPy150Open iskandr/parakeet/parakeet/frontend/run_function.py/run_typed_fn/swapped operands of `%`