class_docstr: Unit tests for the nearest neighbors builder class.
code: def test_index_type(self):
      builder = self.create_builder()
      self.assertIsNotNone(builder)
  
      self.assertEqual(builder.index_type, "linear")
      self.assertEqual(builder.leaf_size, 0)
  
      builder.set_index_type("kd_tree")
      self.assertEqual(
          builder.index_type, "kd_tree"
      )  # test default value
      self.assertEqual(builder.leaf_size, 30)
  
      builder.set_index_type("linear")
      self.assertEqual(builder.index_type, "linear")
      self.assertEqual(builder.leaf_size, 0)
  
      builder.set_index_type(
          "kd_tree", leaf_size=45
      )  # test user-defined value
      self.assertEqual(builder.index_type, "kd_tree")
      self.assertEqual(builder.leaf_size, 45)
  
      builder.set_index_type("linear", leaf_size=37)
      self.assertEqual(builder.index_type, "linear")
      self.assertEqual(builder.leaf_size, 0)
  
      builder.set_index_type(
          "KD_TrEe", leaf_size=22
      )  # test user-defined value
      self.assertEqual(builder.index_type, "kd_tree")
      self.assertEqual(builder.leaf_size, 22)
  
      builder.set_index_type("linEAR")
      self.assertEqual(builder.index_type, "linear")
      self.assertEqual(builder.leaf_size, 0)
  
      with self.assertRaises(TypeError):
          builder.set_index_type("unsupported_index")
  
      with self.assertRaises(TypeError):
          builder.set_index_type("kd_tree", -10)
  
      with self.assertRaises(TypeError):
          builder.set_index_type("kd_tree", 0)
  
imports: import os
  import shutil
  import unittest
  from coremltools._deps import _HAS_SKLEARN
  from coremltools.models import MLModel
  from coremltools.models.nearest_neighbors import KNearestNeighborsClassifierBuilder
  from coremltools.models.utils import _is_macos
label_desc: Use image node_id 10 for calling the NearestNeighborsBuilderTest obj's underlying member method code with example usage: obj.test_index_type() without return types