<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def handle_subports(self, subports, event_type):
 """Subport data model change from the server."""


        LOG.debug("Subports event received: %(event_type)s. "
                  "Subports: %(subports)s",
                  {'event_type': event_type, 'subports': subports})

        # update the cache.
        if event_type == events.CREATED:
            for subport in subports:
                trunk = self._trunks.get(subport['trunk_id'])
                if trunk:
                    trunk.sub_ports.append(subport)
        elif event_type == events.DELETED:
            for subport in subports:
                trunk = self._trunks.get(subport['trunk_id'])
                if trunk and subport in trunk.sub_ports:
                    trunk.sub_ports.remove(subport)

        # update the bound trunks.
        affected_trunk_ids = set([s['trunk_id'] for s in subports])
        for trunk_id in affected_trunk_ids:
            trunk = self._trunks.get(trunk_id)
            if trunk:
                self._setup_trunk(trunk)