code: def swap_leader(self, new_leader):
          
          # 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
docs: Change the preferred leader with one of
          given replicas.
  
          Note: Leaders for all the replicas of current
          partition needs to be changed.