code: def _move_leadership(self, state):
          
          partition = random.randint(0, len(self.cluster_topology.partitions) - 1)
  
          # Moving zero weight partitions will not improve balance for any of the
          # balance criteria. Disallow these movements here to avoid wasted
          # effort.
          if state.partition_weights[partition] == 0:
              return None
          if len(state.replicas[partition]) <= 1:
              return None
          dest_index = random.randint(1, len(state.replicas[partition]) - 1)
          dest = state.replicas[partition][dest_index]
          if (self.args.max_leader_changes is not None and
                  state.leader_movement_count >= self.args.max_leader_changes):
              return None
  
          return state.move_leadership(partition, dest)
docs: Attempt to move a random partition to a random broker. If the
          chosen movement is not possible, None is returned.
  
          :param state: The starting state.
  
          :return: The resulting State object if a leader change is found. None
              if no change is found.