

def intersection(lhs: "Data", rhs: "Data", duplicates: bool = False) -> "Data":
    """(Multi)set intersection of two datasets.

    This intersection method does not retain duplicates by default.
    For multiset behaviour, specify 'duplicates=True'.

    Parameters:
        lhs: one of the two datasets to intersect ('left hand side')
        rhs: one of the two datasets to intersect ('right hand side')
        duplicates: if False (default), the returned data do not contain
            duplicate entries; if True, duplicates are taken into account.
            Both inputs and labels have to match for duplicates.