def _lower_non_trivial_reduce(parfor, lowerer, thread_count_var, reduce_info):
    """Lower non-trivial reduction such as call to `functools.reduce()`.
    """
    init_name = f"{reduce_info.redvar_name}#init"
    # The init_name variable is not defined at this point.
    lowerer.fndesc.typemap.setdefault(init_name, reduce_info.redvar_typ)
    # Emit a sequence of the reduction operation for each intermediate result
    # of each thread.
    num_thread_llval = lowerer.loadvar(thread_count_var.name)
    with cgutils.for_range(lowerer.builder, num_thread_llval) as loop:
        tid = loop.index
        for inst in reduce_info.redvar_info.reduce_nodes:
            # Var assigns to Var?
            if _lower_var_to_var_assign(lowerer, inst):
                pass
            # The reduction operation?
            elif (isinstance(inst, ir.Assign)
                    and any(var.name == init_name for var in inst.list_vars())):
                elem = _emit_getitem_call(tid, lowerer, reduce_info)
                lowerer.storevar(elem, init_name)
                lowerer.lower_inst(inst)

            # Otherwise?
            else:
                raise ParforsUnexpectedReduceNodeError(inst)

            # XXX: This seems like a hack to stop the loop with this condition.
            if _fix_redvar_name_ssa_mismatch(parfor, lowerer, inst,
                                       reduce_info.redvar_name):
                break

    if config.DEBUG_ARRAY_OPT_RUNTIME:
        varname = reduce_info.redvar_name
        lowerer.print_variable(
            f"{parfor.loc}: parfor non-trivial reduction {varname} =",
            varname,
        )
Lower non-trivial reduction such as call to `functools.reduce()`.
    
numba/parfors/parfor_lowering.py