def get_compound_coeff_func(phi=1.0, max_cost=2.0):
    """
    Cost function from the EfficientNets paper
    to compute candidate values for alpha, beta
    and gamma parameters respectively.

    These values are then used to train models,
    and the validation accuracy is used to select
    the best base parameter set at phi = 1.

    # Arguments:
        phi: The base power of the parameters. Kept as 1
            for initial search of base parameters.
        max_cost: The maximum cost of permissible. User
            defined constant generally set to 2.

    # Returns:
        A function which accepts a numpy vector of 3 values,
        and computes the mean squared error between the
        `max_cost` value and the cost computed as
        `cost = x[0] * (x[1] ** 2) * (x[2] ** 2)`.

    # References:
        - [EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946)
    """
    def compound_coeff(x):
        depth = alpha = x[0]
        width = beta = x[1]
        resolution = gamma = x[2]

        # scale by power. Phi is generally kept as 1.0 during search.
        alpha = alpha ** phi
        beta = beta ** phi
        gamma = gamma ** phi

        # compute the cost function
        cost = alpha * (beta ** 2) * (gamma ** 2)
        return (cost - max_cost) ** 2

    return compound_coeff