def leaf_size(self, leaf_size):
        """
        Set the leaf size for a KNearestNeighborsClassifier model. Only for kd-tree indexes.

        Parameters
        ----------
        leaf_size
                The leaf size.

        Returns
        -------
        None
        """
        if leaf_size <= 0:
            raise ValueError("leaf_size must be > 0")
        self.spec.kNearestNeighborsClassifier.nearestNeighborsIndex.singleKdTreeIndex.leafSize = (
            leaf_size
        )

        Set the leaf size for a KNearestNeighborsClassifier model. Only for kd-tree indexes.

        Parameters
        ----------
        leaf_size
                The leaf size.

        Returns
        -------
        None
        
coremltools/models/nearest_neighbors/builder.py