def add_n_delay(identifier, delay_input, delay_time, initial_value, order,
                subs, subscript_dict):
    """
    Creates code to instantiate a stateful 'Delay' object,
    and provides reference to that object's output.

    The name of the stateful object is based upon the passed in parameters,
    so if there are multiple places where identical delay functions are
    referenced, the translated python file will only maintain one stateful
    object, and reference it multiple times.

    Parameters
    ----------
    identifier: basestring
        the python-safe name of the stock

    delay_input: <string>
        Reference to the model component that is the input to the delay

    delay_time: <string>
        Can be a number (in string format) or a reference to another model
        element which will calculate the delay. This is calculated throughout
        the simulation at runtime.

    initial_value: <string>
        This is used to initialize the stocks that are present in the delay.
        We initialize the stocks with equal values so that the outflow in
        the first timestep is equal to this value.

    order: string
        The number of stocks in the delay pipeline. As we construct the
        delays at build time, this must be an integer and cannot be calculated
        from other model components. Anything else will yield a ValueError.

    subs: list of strings
        List of strings of subscript indices that correspond to the
        list of expressions, and collectively define the shape of the output

    subscript_dict: dictionary
        Dictionary describing the possible dimensions of the stock's subscripts

    Returns
    -------
    reference: basestring
        reference to the delay object `__call__` method, which will return
        the output of the delay process

    new_structure: list
        list of element construction dictionaries for the builder to assemble

    """
    new_structure = []

    if len(subs) == 0:
        stateful_py_expr = 'functions.Delay(lambda: %s, lambda: %s,'\
                           'lambda: %s, lambda: %s)' % (
                               delay_input, delay_time, initial_value, order)

    else:
        stateful_py_expr = 'functions.Delay(lambda: _delinput_%s(),'\
                           'lambda: _deltime_%s(), lambda: _init_%s(),'\
                           'lambda: %s)' % (
                               identifier, identifier, identifier, order)

        # following elements not specified in the model file, but must exist
        # create the delay initialization element
        new_structure.append({
            'py_name': '_init_%s' % identifier,
            'real_name': 'Implicit',
            'kind': 'setup', # not specified in the model file, but must exist
            'py_expr': initial_value,
            'subs': subs,
            'doc': 'Provides initial conditions for %s function' % identifier,
            'unit': 'See docs for %s' % identifier,
            'lims': 'None',
            'eqn': 'None',
            'arguments': ''
        })

        new_structure.append({
            'py_name': '_deltime_%s' % identifier,
            'real_name': 'Implicit',
            'kind': 'component',
            'doc': 'Provides delay time for %s function' % identifier,
            'subs': subs,
            'unit': 'See docs for %s' % identifier,
            'lims': 'None',
            'eqn': 'None',
            'py_expr': delay_time,
            'arguments': ''
        })

        new_structure.append({
            'py_name': '_delinput_%s' % identifier,
            'real_name': 'Implicit',
            'kind': 'component',
            'doc': 'Provides input for %s function' % identifier,
            'subs': subs,
            'unit': 'See docs for %s' % identifier,
            'lims': 'None',
            'eqn': 'None',
            'py_expr': delay_input,
            'arguments': ''
        })

    # describe the stateful object
    stateful = {
        'py_name': '_delay_%s' % identifier,
        'real_name': 'Delay of %s' % delay_input,
        'doc': 'Delay time: %s \n Delay initial value %s \n Delay order %s' % (
            delay_time, initial_value, order),
        'py_expr': stateful_py_expr,
        'unit': 'None',
        'lims': 'None',
        'eqn': 'None',
        'subs': '',
        'kind': 'stateful',
        'arguments': ''
    }
    new_structure.append(stateful)

    return "%s()" % stateful['py_name'], new_structure