<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def all_departed_units(self):
 """ Collection of all units that were previously part of any relation on this endpoint but which have since departed. This collection is persistent and mutable. The departed units will be kept until they are explicitly removed, to allow for reasonable cleanup of units that have left. Example: You need to run a command each time a unit departs the relation. .. code-block:: python @when('endpoint.{endpoint_name}.departed') def handle_departed_unit(self):
 for name, unit in self.all_departed_units.items():
 # run the command to remove `unit` from the cluster # .. self.all_departed_units.clear() clear_flag(self.expand_name('departed')) Once a unit is departed, it will no longer show up in :attr:`all_joined_units`. Note that units are considered departed as soon as the departed hook is entered, which differs slightly from how the Juju primitives behave (departing units are still returned from ``related-units`` until after the departed hook is complete). This collection is a :class:`KeyList`, so can be used as a mapping to look up units by their unit name, or iterated or accessed by index. """

        if self._all_departed_units is None:
            self._all_departed_units = CachedKeyList.load(
                'reactive.endpoints.departed.{}'.format(self.endpoint_name),
                RelatedUnit._deserialize,
                'unit_name')
        return self._all_departed_units