class_docstr: Unit tests for the nearest neighbors builder class.
code: def test_set_number_of_neighbors(self):
      builder = self.create_builder()
      self.assertIsNotNone(builder)
  
      builder.set_number_of_neighbors_with_bounds(
          12, allowed_range=(2, 24)
      )
      self.assertEqual(builder.number_of_neighbors, 12)
  
      with self.assertRaises(ValueError):
          builder.set_number_of_neighbors_with_bounds(
              1, allowed_range=(2, 24)
          )
      builder.set_number_of_neighbors_with_bounds(
          4, allowed_range=(2, 24)
      )
      self.assertEqual(builder.number_of_neighbors, 4)
  
      test_set = {3, 5, 7, 9}
      builder.set_number_of_neighbors_with_bounds(
          7, allowed_set=test_set
      )
  
      with self.assertRaises(ValueError):
          builder.set_number_of_neighbors_with_bounds(
              4, allowed_set=test_set
          )
      builder.set_number_of_neighbors_with_bounds(
          5, allowed_set=test_set
      )
      self.assertEqual(builder.number_of_neighbors, 5)
  
imports: import os
  import shutil
  from coremltools.models.utils import _is_macos
  import unittest
  from coremltools.models import MLModel
  from coremltools.models.nearest_neighbors import KNearestNeighborsClassifierBuilder
  from coremltools._deps import _HAS_SKLEARN
label_desc: Use image node_id 14 for calling the NearestNeighborsBuilderTest obj's underlying member method code with example usage: obj.test_set_number_of_neighbors() without return types