def merge_partial_elements(element_list):
    """
    Merges model elements which collectively all define the model component,
    mostly for multidimensional subscripts

    Parameters
    ----------
    element_list: list
        List of all the elements.

    Returns
    -------
    list:
        List of merged elements.

    """
    outs = dict()  # output data structure

    for element in element_list:
        if element["py_expr"] != "None":  # for
            name = element["py_name"]
            if name not in outs:

                # Use 'expr' for Vensim models, and 'eqn' for Xmile
                # (This makes the Vensim equation prettier.)
                eqn = element["expr"] if "expr" in element else element["eqn"]
                outs[name] = {
                    "py_name": element["py_name"],
                    "real_name": element["real_name"],
                    "doc": element["doc"],
                    "py_expr": [element["py_expr"]],  # in a list
                    "unit": element["unit"],
                    "subs": [element["subs"]],
                    "merge_subs": element["merge_subs"]
                    if "merge_subs" in element else None,
                    "lims": element["lims"],
                    "eqn": [eqn.replace(r"\ ", "")],
                    "kind": element["kind"],
                    "arguments": element["arguments"],
                }

            else:
                eqn = element["expr"] if "expr" in element else element["eqn"]

                outs[name]["doc"] = outs[name]["doc"] or element["doc"]
                outs[name]["unit"] = outs[name]["unit"] or element["unit"]
                outs[name]["lims"] = outs[name]["lims"] or element["lims"]
                outs[name]["eqn"] += [eqn.replace(r"\ ", "")]
                outs[name]["py_expr"] += [element["py_expr"]]
                outs[name]["subs"] += [element["subs"]]
                outs[name]["arguments"] = element["arguments"]

    return list(outs.values())