code: def estimator_knn(sagemaker_session, cpu_instance_type):
      knn_image = image_uris.retrieve(
          "knn", sagemaker_session.boto_region_name
      )
  
      estimator = Estimator(
          image_uri=knn_image,
          role=EXECUTION_ROLE,
          instance_count=1,
          instance_type=cpu_instance_type,
          sagemaker_session=sagemaker_session,
      )
  
      estimator.set_hyperparameters(
          k=10,
          sample_size=500,
          feature_dim=784,
          mini_batch_size=100,
          predictor_type="regressor",
      )
      return estimator
  
imports: from __future__ import absolute_import
  import json
  import os
  import pytest
  from sagemaker import image_uris, utils
  from sagemaker.analytics import HyperparameterTuningJobAnalytics
  from sagemaker.deserializers import JSONDeserializer
  from sagemaker.estimator import Estimator
  from sagemaker.serializers import SimpleBaseSerializer
  from sagemaker.tuner import ContinuousParameter, IntegerParameter, HyperparameterTuner
  from tests.integ import datasets, DATA_DIR, TUNING_DEFAULT_TIMEOUT_MINUTES
  from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
label_desc: Use image node_id 3 for calling a global function with example usage: estimator_knn(sagemaker_session, cpu_instance_type) and returns: estimator