#NEWLINE# def code_gen_ensemble( trees , individual_learner_weight , initial_value , gen = None , n_jobs = 1 ) : #NEWLINE# #INDENT# '\n    Writes code similar to:\n\n    ```\n    extern "C" {\n      __attribute__((__always_inline__)) float evaluate_partial_0(float* f) {\n        if (f[4] <= 0.662200987339) {\n          return 1.0;\n        }\n        else {\n          if (f[8] <= 0.804652512074) {\n            return 0.0;\n          }\n          else {\n            return 1.0;\n          }\n        }\n      }\n    }\n    extern "C" {\n      __attribute__((__always_inline__)) float evaluate_partial_1(float* f) {\n        if (f[4] <= 0.694428026676) {\n          return 1.0;\n        }\n        else {\n          if (f[7] <= 0.4402526021) {\n            return 1.0;\n          }\n          else {\n            return 0.0;\n          }\n        }\n      }\n    }\n\n    extern "C" {\n      float evaluate(float* f) {\n        float result = 0.0;\n        result += evaluate_partial_0(f) * 0.1;\n        result += evaluate_partial_1(f) * 0.1;\n        return result;\n      }\n    }\n    ```\n\n    to the given CodeGenerator object.\n    ' #NEWLINE# if ( tree_files is None ) : #NEWLINE# #INDENT# gen = CodeGenerator ( ) #NEWLINE# #UNINDENT# tree_files = [ _gen_tree ( i , tree ) for ( i , tree ) in enumerate ( trees ) ] #NEWLINE# with gen . bracketed ( 'extern "C" {' , '}' ) : #NEWLINE# #INDENT# for ( i , tree ) in enumerate ( trees ) : #NEWLINE# #INDENT# name = '{name}_{index}' . format ( name = EVALUATE_FN_NAME , index = i ) #NEWLINE# gen . write ( 'float {name}(float* f);' . format ( name = name ) ) #NEWLINE# #UNINDENT# fn_decl = 'float {name}(float* f) {{' . format ( name = EVALUATE_FN_NAME ) #NEWLINE# with gen . bracketed ( fn_decl , '}' ) : #NEWLINE# #INDENT# gen . write ( 'float result = {0}f;' . format ( initial_value ) ) #NEWLINE# for ( i , _ ) in enumerate ( trees ) : #NEWLINE# #INDENT# increment = 'result += {name}_{index}(f) * {weight}f;' . format ( name = EVALUATE_FN_NAME , index = i , weight = individual_learner_weight ) #NEWLINE# gen . write ( increment ) #NEWLINE# #UNINDENT# gen . write ( 'return result;' ) #NEWLINE# #UNINDENT# #UNINDENT# return ( tree_files + [ gen . file ] )