<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rebalance_replication_groups(self):
 """Rebalance partitions over replication groups. First step involves rebalancing replica-count for each partition across replication-groups. Second step involves rebalancing partition-count across replication-groups of the cluster. """

        # Balance replicas over replication-groups for each partition
        if any(b.inactive for b in six.itervalues(self.cluster_topology.brokers)):
            self.log.error(
                "Impossible to rebalance replication groups because of inactive "
                "brokers."
            )
            raise RebalanceError(
                "Impossible to rebalance replication groups because of inactive "
                "brokers"
            )

        # Balance replica-count over replication-groups
        self.rebalance_replicas()

        # Balance partition-count over replication-groups
        self._rebalance_groups_partition_cnt()