code: def _force_revoke_leadership(self, broker):
          
          owned_partitions = list(filter(
              lambda p: broker is p.leader,
              broker.partitions,
          ))
          for partition in owned_partitions:
              if len(partition.replicas) == 1:
                  self.log.error(
                      "Cannot be revoked leadership for broker {b} for partition {p}. Replica count: 1"
                      .format(p=partition, b=broker),
                  )
                  continue
              eligible_followers = [
                  follower for follower in partition.followers
                  if not follower.revoked_leadership
              ]
              if eligible_followers:
                  # Pick follower with least leader-count
                  best_fit_follower = min(
                      eligible_followers,
                      key=lambda follower: follower.count_preferred_replica(),
                  )
                  partition.swap_leader(best_fit_follower)
              else:
                  self.log.error(
                      "All replicas for partition {p} on broker {b} are to be revoked for leadership.".format(
                          p=partition,
                          b=broker,
                      )
                  )
docs: Revoke the leadership of given broker for any remaining partitions.
  
          Algorithm:
          1. Find the partitions (owned_partitions) with given broker as leader.
          2. For each partition find the eligible followers.
             Brokers which are not to be revoked from leadership are eligible followers.
          3. Select the follower who is leader for minimum partitions.
          4. Assign the selected follower as leader.
          5. Notify for any pending owned_partitions whose leader cannot be changed.
          This could be due to replica size 1 or eligible followers are None.