<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_updates(self, messages: Iterable[CachedMessage], expunged: Iterable[int]) -> None: """Update the messages in the selected mailboxes. The ``messages`` should include non-expunged messages in the mailbox that should be checked for updates. The ``expunged`` argument is the set of UIDs that have been expunged from the mailbox. In an optimized implementation, ``messages`` only includes new messages or messages with metadata updates. This minimizes the comparison needed to determine what untagged responses are necessary. The :attr:`.mod_sequence` attribute may be used to support this optimization. If a backend implementation lacks the ability to determine the subset of messages that have been updated, it should instead use :meth:`.set_messages`. Args: messages: The cached message objects to add. expunged: The set of message UIDs that have been expunged. """

        self._messages._update(messages)
        self._messages._remove(expunged, self._hide_expunged)
        if not self._hide_expunged:
            self._session_flags.remove(expunged)