import random


def gen_individual(toolbox, config, out_type='out'):
    """
    Generates a random tree individual using the toolbox and arity and height configuration.
    The ``ou_type`` parameter specifies the output type of the root of the tree.

    :param toolbox: Toolbox which contains methods to create the individual.
    :param GenensConfig config: Configuration of Genens
    :param out_type: Output type of the root of the tree individual.
    :return: A new random tree individual.
    """
    arity = random.randint(config.min_arity, config.max_arity)  # randint is inclusive for both limits
    height = random.randint(config.min_height, config.max_height)

    return toolbox.individual(max_height=height, max_arity=arity, first_type=out_type)