class_docstr: Internal class that manages partitioning. The ``FakePalettize`` class base classes the ``_Partitioner`` class
  and all the partitioning logic is controlled by this class.
docstr: Method to create partitions in the weights. These partitions can be used to run channel level palettization.
code: def create_partitions(self, weights: _torch.Tensor):
      """
      Method to create partitions in the weights. These partitions can be used to run channel level palettization.
      """
      num_channels = len(weights)
      numel_per_channel = _torch.numel(weights[0])
      num_channels_per_partition = min(
          num_channels,
          max(1, int(self.partition_size / numel_per_channel)),
      )
  
      self.partitions = [
          (n, min(n + num_channels_per_partition, num_channels))
          for n in range(0, num_channels, num_channels_per_partition)
      ]
      num_partitions = len(self.partitions)
  
      if self.centroids_init[0] == "auto":
          # if auto then pick either init method
          numel_per_partition = (
              numel_per_channel * num_channels_per_partition
          )
          self.centroids_init[0] = (
              "opt1d"
              if (
                  numel_per_partition <= self.n_clusters[0]
                  or numel_per_partition <= self.kmeans_opt1d_threshold
              )
              and self.cluster_dim == 1
              else "cpu.kmeans++"
          )
  
      self.centroids_init = self.centroids_init * num_partitions
      self.n_clusters = self.n_clusters * num_partitions
      self.labels_init = self.labels_init * num_partitions
      self.enforce_zero = self.enforce_zero * num_partitions
  
      assert (
          num_channels_per_partition * numel_per_channel
          >= min(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"
  
file_path: coremltools/coremltools/optimize/torch/palettization/_partitioner.py
imports: from typing import Tuple
  import torch
  from ._efficient_kmeans import _EfficientKMeans
label_desc: Use image node_id 2 for calling the _Partitioner obj's underlying member method code with example usage: obj.create_partitions(weights) without return types