<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _legislator_objects(self):
        '''A cache of dereferenced legislator objects.
        '''
        kwargs = {}

        id_getter = operator.itemgetter('leg_id')
        ids = []
        for k in ('yes', 'no', 'other'):
            ids.extend(map(id_getter, self[k + '_votes']))
        objs = db.legislators.find({'_all_ids': {'$in': ids}}, **kwargs)

        # Handy to keep a reference to the vote on each legislator.
        objs = list(objs)
        id_cache = {}
        for obj in objs:
            obj.vote = self
            for _id in obj['_all_ids']:
                id_cache[_id] = obj

        return id_cache