def create_partitions(self, weights) -> None:
        """
        Method to create partitions in the weights. These partitions can be used to run channel level palettization.
        """
        with _torch.no_grad():
            num_channels = len(weights)
            usr_num_channels_per_partition = (
                int(self.group_size) if self.group_size else num_channels
            )
            self.partitions = [
                list(range(i, min(num_channels, i + usr_num_channels_per_partition)))
                for i in range(0, num_channels, usr_num_channels_per_partition)
            ]
            num_partitions = len(self.partitions)
            self.centroids = self.centroids * num_partitions
            self.labels = self.labels * num_partitions
            self.enforce_zero = self.enforce_zero * num_partitions
            self.cum_inertia = [1e9] * num_partitions
            self.partition_numel = _torch.tensor(
                [_torch.numel(weights[p]) for p in self.partitions]
            )
            self.enable_partition = [True] * max(
                1, int(self.percentage_palett_enable * num_partitions)
            )
            self.enable_partition += [False] * (num_partitions - len(self.enable_partition))
            numel_per_partition = max(self.partition_numel)
            assert numel_per_partition
            assert (
                numel_per_partition >= self.n_clusters * self.cluster_dim
            ), f"The number of clusters ({self.n_clusters}) and/or the cluster dim ({self.cluster_dim}) is TOO big"

        Method to create partitions in the weights. These partitions can be used to run channel level palettization.
        
coremltools/optimize/torch/palettization/_partitioner.py