<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def divide(elements, by, translate=False, sep=' '):
 """Divide lists `elements` and `by`. All elements are grouped into N bins, where N denotes the elements in `by` list. Parameters elements: list of dict Elements to be grouped into bins. by: list of dict Elements defining the bins. translate: bool (default: False) When dividing, also translate start and end positions of elements. sep: str (default ' ') In case of multispans, what is the default text separator. This is required in order to tag correct start, end positions of elements. """

    outer_spans = [spans(elem) for elem in by]
    return divide_by_spans(elements, outer_spans, translate=translate, sep=sep)