code: def create_classification_with_model_selector(
      dataset,
      target,
      model_selector,
      features=None,
      validation_set="auto",
      verbose=True,
  ):
      """
      Create a :class:`~turicreate.toolkits.SupervisedLearningModel`,
  
      This is generic function that allows you to create any model that
      implements SupervisedLearningModel. This function is normally not called, call
      specific model's create function instead.
  
      Parameters
      ----------
      dataset : SFrame
          Dataset for training the model.
  
      target : string
          Name of the column containing the target variable. The values in this
          column must be 0 or 1, of integer type.
  
      model_name : string
          Name of the model
  
      model_selector: function
          Provide a model selector.
  
      features : list[string], optional
          List of feature names used by feature column
  
      verbose : boolean
          whether print out messages during training
  
      """
  
      # Perform error-checking and trim inputs to specified columns
      dataset, validation_set = _validate_data(
          dataset, target, features, validation_set
      )
  
      # Sample the data
      features_sframe = dataset
      if features_sframe.num_rows() > 1e5:
          fraction = 1.0 * 1e5 / features_sframe.num_rows()
          features_sframe = features_sframe.sample(fraction, seed=0)
  
      # Get available models for this dataset
      num_classes = len(dataset[target].unique())
      selected_model_names = model_selector(
          num_classes, features_sframe
      )
  
      # Create a validation set
      if isinstance(validation_set, str):
          if validation_set == "auto":
              if dataset.num_rows() >= 100:
                  if verbose:
                      print_validation_track_notification()
                  dataset, validation_set = dataset.random_split(
                      0.95, exact=True
                  )
              else:
                  validation_set = None
          else:
              raise TypeError("Unrecognized value for validation_set.")
  
      # Match C++ model names with user model names
      python_names = {
          "boosted_trees_classifier": "BoostedTreesClassifier",
          "random_forest_classifier": "RandomForestClassifier",
          "decision_tree_classifier": "DecisionTreeClassifier",
          "classifier_logistic_regression": "LogisticClassifier",
          "classifier_svm": "SVMClassifier",
      }
  
      # Print useful user-facing progress messages
      if verbose:
          print(
              "PROGRESS: The following methods are available for this type of problem."
          )
          print(
              "PROGRESS: "
              + ", ".join(
                  [python_names[x] for x in selected_model_names]
              )
          )
          if len(selected_model_names) > 1:
              print(
                  "PROGRESS: The returned model will be chosen according to validation accuracy."
              )
  
      models = {}
      metrics = {}
      for model_name in selected_model_names:
          # Fit each of the available models
          m = create_selected(
              model_name,
              dataset,
              target,
              features,
              validation_set,
              verbose,
          )
          models[model_name] = m
  
          if "validation_accuracy" in m._list_fields():
              metrics[model_name] = m.validation_accuracy
          elif "training_accuracy" in m._list_fields():
              metrics[model_name] = m.training_accuracy
  
          # Most models have this.
          elif "progress" in m._list_fields():
              prog = m.progress
              validation_column = "Validation Accuracy"
              accuracy_column = "Training Accuracy"
              if validation_column in prog.column_names():
                  metrics[model_name] = float(
                      prog[validation_column].tail(1)[0]
                  )
              else:
                  metrics[model_name] = float(
                      prog[accuracy_column].tail(1)[0]
                  )
          else:
              raise ValueError(
                  "Model does not have metrics that can be used for model selection."
              )
  
      # Choose model based on either validation, if available.
      best_model = None
      best_acc = None
      for model_name in selected_model_names:
          if best_acc is None:
              best_model = model_name
              best_acc = metrics[model_name]
          if best_acc is not None and best_acc < metrics[model_name]:
              best_model = model_name
              best_acc = metrics[model_name]
  
      ret = []
      width = 32
      if len(selected_model_names) > 1:
          ret.append(
              "PROGRESS: Model selection based on validation accuracy:"
          )
          ret.append("---------------------------------------------")
          key_str = "{:<{}}: {}"
          for model_name in selected_model_names:
              name = python_names[model_name]
              row = key_str.format(
                  name, width, str(metrics[model_name])
              )
              ret.append(row)
          ret.append("---------------------------------------------")
          ret.append(
              "Selecting "
              + python_names[best_model]
              + " based on validation set performance."
          )
  
      if verbose:
          print("\nPROGRESS: ".join(ret))
      return models[best_model]
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import turicreate
  from turicreate.toolkits._model import Model
  from turicreate.toolkits._internal_utils import _raise_error_if_not_sframe
  from turicreate.toolkits._internal_utils import _validate_data
  from turicreate.toolkits._main import ToolkitError
  from turicreate._cython.cy_server import QuietProgress
label_desc: Use image node_id 3 for calling a global function with example usage: create_classification_with_model_selector(dataset, target, model_selector, features, validation_set, verbose) and returns: models