
{methods}
public static int {method_name}(double[] features) {{
    int n_estimators = {n_estimators};
    int n_classes = {n_classes};

    double[][] preds = new double[n_estimators][];
    {method_calls}

    int i, j;
    double normalizer, sum;
    for (i = 0; i < n_estimators; i++) {{
        normalizer = 0.;
        for (j = 0; j < n_classes; j++) {{
            normalizer += preds[i][j];
        }}
        if (normalizer == 0.) {{
            normalizer = 1.;
        }}
        for (j = 0; j < n_classes; j++) {{
            preds[i][j] = preds[i][j] / normalizer;
            if (preds[i][j] <= 2.2204460492503131e-16) {{
                preds[i][j] = 2.2204460492503131e-16;
            }}
            preds[i][j] = Math.log(preds[i][j]);
        }}
        sum = 0.;
        for (j = 0; j < n_classes; j++) {{
            sum += preds[i][j];
        }}
        for (j = 0; j < n_classes; j++) {{
            preds[i][j] = (n_classes - 1) * (preds[i][j] - (1. / n_classes) * sum);
        }}
    }}
    double[] classes = new double[n_classes];
    for (i = 0; i < n_estimators; i++) {{
        for (j = 0; j < n_classes; j++) {{
            classes[j] += preds[i][j];
        }}
    }}

    return {class_name}.findMax(classes);
}}
