<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_macro(macro_name, filename, arg_names, arg_vals):
 """ Constructs a stateful object instantiating a 'Macro' Parameters macro_name: basestring python safe name for macro filename: basestring filepath to macro definition func_args: dict dictionary of values to be passed to macro {key: function} Returns ------- reference: basestring reference to the Initial object `__call__` method, which will return the first calculated value of `initial_input` new_structure: list list of element construction dictionaries for the builder to assemble """

    func_args = '{ %s }' % ', '.join(["'%s': lambda: %s" % (key, val) for key, val in
                                      zip(arg_names, arg_vals)])

    stateful = {
        'py_name': '_macro_' + macro_name + '_' + '_'.join(
            [utils.make_python_identifier(f)[0] for f in arg_vals]),
        'real_name': 'Macro Instantiation of ' + macro_name,
        'doc': 'Instantiates the Macro',
        'py_expr': "functions.Macro('%s', %s, '%s', time_initialization=lambda: __data['time'])" % (filename, func_args, macro_name),
        'unit': 'None',
        'lims': 'None',
        'eqn': 'None',
        'subs': '',
        'kind': 'stateful',
        'arguments': ''
    }

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