def sanitize_palettization_cluster_dim(self):
        """
        Validates and updates cluster_dim attribute in palettization config for specified parameter.
        If compression should be skipped for param, returns False.
        Else, returns True and updates config inplace.
        """
        if self.config.cluster_dim is None:
            self.config.cluster_dim = 1
            return True

        if self.config.cluster_dim > 1:
            if self.config.channel_axis == 0:
                dim_size = self.param.shape[0]
            else:
                dim_size = self.param.shape[1]
            if dim_size % self.config.cluster_dim != 0:
                _logger.warning(
                    f"{self.param_name}: The number of channels in channel axis dimension: {self.config.channel_axis},"
                    f" {dim_size} is not divisible by cluster_dim={self.config.cluster_dim}"
                )
                return False

        return True

        Validates and updates cluster_dim attribute in palettization config for specified parameter.
        If compression should be skipped for param, returns False.
        Else, returns True and updates config inplace.
        
coremltools/optimize/torch/_utils/validation_utils.py