code: def revoke_leadership(self, broker_ids):
          
          for b_id in broker_ids:
              try:
                  broker = self.cluster_topology.brokers[b_id]
              except KeyError:
                  self.log.error("Invalid broker id %s.", b_id)
                  raise InvalidBrokerIdError(
                      "Broker id {} does not exist in cluster".format(b_id),
                  )
              broker.mark_revoked_leadership()
  
          assert(len(self.cluster_topology.brokers) - len(broker_ids) > 0), "Not " \
              "all brokers can be revoked for leadership"
          opt_leader_cnt = len(self.cluster_topology.partitions) // (
              len(self.cluster_topology.brokers) - len(broker_ids)
          )
          # Balanced brokers transfer leadership to their under-balanced followers
          self.rebalancing_non_followers(opt_leader_cnt)
  
          # If the broker-ids to be revoked from leadership are still leaders for any
          # partitions, try to forcefully move their leadership to followers if possible
          pending_brokers = [
              b for b in six.itervalues(self.cluster_topology.brokers)
              if b.revoked_leadership and b.count_preferred_replica() > 0
          ]
          for b in pending_brokers:
              self._force_revoke_leadership(b)
docs: Revoke leadership for given brokers.
  
          :param broker_ids: List of broker-ids whose leadership needs to be revoked.