code: def _encode_numpy(
      values, uniques=None, encode=False, check_unknown=True
  ):
      # only used in _encode below, see docstring there for details
      if uniques is None:
          if encode:
              uniques, encoded = np.unique(values, return_inverse=True)
              return uniques, encoded
          else:
              # unique sorts
              return np.unique(values)
      if encode:
          if check_unknown:
              diff = _encode_check_unknown(values, uniques)
              if diff:
                  raise ValueError(
                      "y contains previously unseen labels: %s"
                      % str(diff)
                  )
          encoded = np.searchsorted(uniques, values)
          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 1 for calling a global function with example usage: _encode_numpy(values, uniques, encode, check_unknown) and returns: uniques,  encoded, uniques, uniques,  encoded, np