code: def decommission_brokers(self, broker_ids):
          
          decommission_brokers = []
          for broker_id in broker_ids:
              try:
                  broker = self.cluster_topology.brokers[broker_id]
                  broker.mark_decommissioned()
                  decommission_brokers.append(broker)
              except KeyError:
                  raise InvalidBrokerIdError(
                      "No broker found with id {broker_id}".format(broker_id=broker_id)
                  )
  
          partitions = defaultdict(int)
  
          # Remove all partitions from decommissioned brokers.
          for broker in decommission_brokers:
              broker_partitions = list(broker.partitions)
              for partition in broker_partitions:
                  broker.remove_partition(partition)
                  partitions[partition.name] += 1
  
          active_brokers = self.cluster_topology.active_brokers
  
          # Create state from the initial cluster topology.
          self.state = _State(self.cluster_topology, brokers=active_brokers)
  
          # Add partition replicas to active brokers one-by-one.
          for partition_name in sorted(six.iterkeys(partitions)):  # repeatability
              partition = self.cluster_topology.partitions[partition_name]
              replica_count = partitions[partition_name]
              try:
                  self.add_replica(partition_name, replica_count)
              except InvalidReplicationFactorError:
                  raise BrokerDecommissionError(
                      "Not enough active brokers in the cluster. "
                      "Partition {partition} has replication-factor {rf}, "
                      "but only {brokers} active brokers remain."
                      .format(
                          partition=partition_name,
                          rf=partition.replication_factor + replica_count,
                          brokers=len(active_brokers)
                      )
                  )
docs: Decommissioning brokers is done by removing all partitions from
          the decommissioned brokers and adding them, one-by-one, back to the
          cluster.
  
          :param broker_ids: List of broker ids that should be decommissioned.