code: def _construct_auto_distance(features, column_types):
      """
      Construct a composite distance function for a set of features, based on the
      types of those features.
  
      NOTE: This function is very similar to
      `:func:_nearest_neighbors.choose_auto_distance`. The function is separate
      because the auto-distance logic different than for each nearest
      neighbors-based toolkit.
  
      Parameters
      ----------
      features : list[str]
          Names of for which to construct a distance function.
  
      column_types : dict(string, type)
          Names and types of all columns.
  
      Returns
      -------
      dist : list[list]
          A composite distance function. Each element of the inner list has three
          elements: a list of feature names (strings), a distance function name
          (string), and a weight (float).
      """
  
      ## Put input features into buckets based on type.
      numeric_ftrs = []
      string_ftrs = []
      dict_ftrs = []
  
      for ftr in features:
          try:
              ftr_type = column_types[ftr]
          except:
              raise ValueError(
                  "The specified feature does not exist in the "
                  + "input data."
              )
  
          if ftr_type == str:
              string_ftrs.append(ftr)
  
          elif ftr_type == dict:
              dict_ftrs.append(ftr)
  
          elif ftr_type in [int, float, _array.array]:
              numeric_ftrs.append(ftr)
  
          else:
              raise TypeError(
                  "Unable to automatically construct a distance "
                  + "function for feature '{}'. ".format(ftr)
                  + "For the nearest neighbor classifier, features "
                  + "must be of type integer, float, string, dictionary, "
                  + "or array.array."
              )
  
      ## Construct the distance function
      dist = []
  
      for ftr in string_ftrs:
          dist.append([[ftr], "levenshtein", 1])
  
      if len(dict_ftrs) > 0:
          dist.append([dict_ftrs, "weighted_jaccard", len(dict_ftrs)])
  
      if len(numeric_ftrs) > 0:
          dist.append([numeric_ftrs, "euclidean", len(numeric_ftrs)])
  
      return dist
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import time
  import copy
  import array
  import logging
  import turicreate
  from turicreate.toolkits._model import CustomModel
  from turicreate.toolkits._internal_utils import _toolkit_repr_print
  from turicreate.toolkits._internal_utils import _raise_error_if_sframe_empty
  from turicreate.toolkits._internal_utils import _raise_error_if_not_sframe
  from turicreate.toolkits._internal_utils import _raise_error_if_column_exists
  from turicreate.toolkits._internal_utils import _raise_error_evaluation_metric_is_valid
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits import evaluation
  from turicreate.toolkits._model import PythonProxy
label_desc: Use image node_id 2 for calling a global function with example usage: _construct_auto_distance(features, column_types) and returns: dist