code: def _encode(values, uniques=None, encode=False, check_unknown=True):
      """Helper function to factorize (find uniques) and encode values.
  
      Uses pure python method for object dtype, and numpy method for
      all other dtypes.
      The numpy method has the limitation that the `uniques` need to
      be sorted. Importantly, this is not checked but assumed to already be
      the case. The calling method needs to ensure this for all non-object
      values.
  
      Parameters
      ----------
      values : array
          Values to factorize or encode.
      uniques : array, optional
          If passed, uniques are not determined from passed values (this
          can be because the user specified categories, or because they
          already have been determined in fit).
      encode : bool, default False
          If True, also encode the values into integer codes based on `uniques`.
      check_unknown : bool, default True
          If True, check for values in ``values`` that are not in ``unique``
          and raise an error. This is ignored for object dtype, and treated as
          True in this case. This parameter is useful for
          _BaseEncoder._transform() to avoid calling _encode_check_unknown()
          twice.
  
      Returns
      -------
      uniques
          If ``encode=False``. The unique values are sorted if the `uniques`
          parameter was None (and thus inferred from the data).
      (uniques, encoded)
          If ``encode=True``.
  
      """
      if values.dtype == object:
          try:
              res = _encode_python(values, uniques, encode)
          except TypeError:
              types = sorted(
                  t.__qualname__ for t in set(type(v) for v in values)
              )
              raise TypeError(
                  "Encoders require their input to be uniformly "
                  + "strings or numbers. Got "
                  + " ".join(types)
              )
          return res
      else:
          return _encode_numpy(
              values, uniques, encode, check_unknown=check_unknown
          )
  
file_path: h2o-3/h2o-py/tests/pyunit_utils/sklearn_multinomial_auc_method.py
imports: import numpy
  from itertools import combinations
  from functools import partial
  from sklearn.utils import column_or_1d, check_consistent_length, check_array
  from sklearn.preprocessing import label_binarize
  from sklearn.metrics import auc, roc_curve
  from sklearn.utils.multiclass import type_of_target
label_desc: Use image node_id 4 for calling a global function with example usage: _encode(values, uniques, encode, check_unknown) and returns: res, _encode_numpy