code: def _encode(values, uniques=None, encode=False):
      if isinstance(values, (pd.Series, dd.Series)) and _is_categorical(
          values
      ):
          return _encode_categorical(
              values, uniques=uniques, encode=encode
          )
      elif isinstance(values, da.Array):
          return _encode_dask_array(
              values, uniques=uniques, encode=encode
          )
      else:
          raise ValueError("Unknown type {}".format(type(values)))
  
imports: from __future__ import division
  from operator import getitem
  from typing import Optional, Union
  import dask.array
  import dask.dataframe
  import numpy
  import pandas
  import scipy.sparse
  import sklearn.preprocessing
  from sklearn.utils.validation import check_is_fitted
  from .._typing import ArrayLike, SeriesType
label_desc: Use image node_id 5 for calling a global function with example usage: _encode(values, uniques, encode) and returns: _encode_categorical, _encode_dask_array