'Creates valid inputs for the given unit from the outputs in `results`.
Args:
unit: The `Pipeline` to create inputs for.
results: A database of computed unit outputs. A dictionary mapping
Pipeline to list of objects.
list_operation: A function that maps lists of inputs to a single list of
tuples, where each tuple is an input. This is used when `unit` takes
a dictionary as input. Each tuple is used as the values for a
dictionary input. This can be thought of as taking a sort of
transpose of a ragged 2D array.
The default is `itertools.product` which takes the cartesian product
of the input lists.
Returns:
If `unit` takes a single input, a list of objects.
If `unit` takes a dictionary input, a list of dictionaries each mapping
string name to object.'

def _get_inputs_for_unit(self, unit, results, list_operation=itertools.product):

    previous_outputs = self._get_outputs_as_signature(self.dag[unit], results)
    if isinstance(previous_outputs, dict):
        names = list(previous_outputs.keys())
        lists = [previous_outputs[name] for name in names]
        stack = list_operation(*lists)
        return [dict(zip(names, values)) for values in stack]
    else:
        return previous_outputs
