<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def swap_leader(self, new_leader):
 """Change the preferred leader with one of given replicas. Note: Leaders for all the replicas of current partition needs to be changed. """

        # Replica set cannot be changed
        assert(new_leader in self._replicas)
        curr_leader = self.leader
        idx = self._replicas.index(new_leader)
        self._replicas[0], self._replicas[idx] = \
            self._replicas[idx], self._replicas[0]
        return curr_leader