def _reconstruct_flattened_structure(structure, flattened):
if isinstance(structure, list):<EOL><INDENT>return list(_reconstruct_flattened_structure(x, flattened) for x in structure)<EOL><DEDENT>elif isinstance(structure, tuple):<EOL><INDENT>return tuple(_reconstruct_flattened_structure(x, flattened) for x in structure)<EOL><DEDENT>elif isinstance(structure, dict):<EOL><INDENT>return {k: _reconstruct_flattened_structure(v, flattened) for k, v in structure.items()}<EOL><DEDENT>elif isinstance(structure, int):<EOL><INDENT>return flattened[structure]<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>
Reconstruct the flattened list back to (possibly) nested structure.

    Parameters
    ----------
    structure : An integer or a nested container with integers.
        The extracted structure of the container of `data`.
    flattened : list or None
        The container thats holds flattened result.
    Returns
    -------
    data : A single NDArray/Symbol or nested container with NDArrays/Symbol.
        The nested container that was flattened.