<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_by(self, types=(), units=()):
 """Return list of value labels, filtered by either or both type and unit. An empty sequence for either argument will match as long as the other argument matches any values."""

        if not (isinstance(types, Sequence) and isinstance(units, Sequence)):
            raise TypeError('types/units must be a sequence')
        empty = frozenset()

        if types:
            type_names = set()
            for type_ in types:
                type_names |= self.by_type.get(type_, empty)
            if not units:
                return type_names

        if units:
            unit_names = set()
            for unit in units:
                unit_names |= self.by_unit.get(unit, empty)
            if not types:
                return unit_names

        return (type_names & unit_names) if (types and units) else empty