code: def _encode_python(values, uniques=None, encode=False):
      # only used in _encode below, see docstring there for details
      if uniques is None:
          uniques = sorted(set(values))
          uniques = np.array(uniques, dtype=values.dtype)
      if encode:
          table = {val: i for i, val in enumerate(uniques)}
          try:
              encoded = np.array([table[v] for v in values])
          except KeyError as e:
              raise ValueError(
                  "y contains previously unseen labels: %s" % str(e)
              )
          return uniques, encoded
      else:
          return uniques
  
imports: import copy
  from numbers import Integral
  import numpy
  from scipy import sparse
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from autogluon.features.generators import LabelEncoderFeatureGenerator
label_desc: Use image node_id 2 for calling a global function with example usage: _encode_python(values, uniques, encode) and returns: uniques,  encoded, uniques