import logging


def _construct_hidden_units(args):
    """ Create the number of hidden units in each layer

    If the args.layer_sizes_scale_factor > 0 then it will use a "decay"
    mechanism
    to define the number of units in each layer. Otherwise, arg.hidden_units
    will be used as-is.

    Args:
      args: experiment parameters.
    Returns:
        list of int
    """
    hidden_units = [int(units) for units in args.hidden_units.split(',')]

    if args.layer_sizes_scale_factor > 0:
        first_layer_size = hidden_units[0]
        scale_factor = args.layer_sizes_scale_factor
        num_layers = args.num_layers

        hidden_units = [
            max(2, int(first_layer_size * scale_factor ** i))
            for i in range(num_layers)
        ]

    logging.info('Hidden units structure: {}'.format(hidden_units))
    return hidden_units