code: def _encode_target(data, target, mapping=None):
      """Encode targets to integers in [0, num_classes - 1]"""
      if mapping is None:
          mapping = {
              t: i for i, t in enumerate(sorted(data[target].unique()))
          }
  
      data[target] = data[target].apply(lambda t: mapping[t])
      return data, mapping
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import time
  import six
  from turicreate import SFrame
  import turicreate.toolkits._internal_utils
  from turicreate.toolkits import _coreml_utils
  import turicreate.toolkits._feature_engineering._internal_utils
  from turicreate.toolkits._main import ToolkitError
  from turicreate._deps.minimal_package import _minimal_package_import_check
  from turicreate.toolkits._model import Model
label_desc: Use image node_id 2 for calling a global function with example usage: _encode_target(data, target, mapping) and returns: data,  mapping