code: def _encode_dask_array(
      values: da.Array,
      uniques: Optional[np.ndarray] = None,
      encode: bool = False,
      onehot_dtype: Optional[np.dtype] = None,
  ):
      """One-hot or label encode a dask array.
  
      Parameters
      ----------
      values : da.Array, shape [n_samples,]
      uniques : np.ndarray, shape [n_uniques,]
      encode : bool, default False
          Whether to encode the values (True) or just discover the uniques.
      onehot_dtype : np.dtype, optional
          Optional dtype for the resulting one-hot encoded array. This changes
          the shape, dtype, and underlying storage of the returned dask array.
  
          ======= ================= =========================
          thing   onehot_dtype=None onehot_dtype=onehot_dtype
          ======= ================= =========================
          shape   (n_samples,)      (n_samples, len(uniques))
          dtype   np.intp           onehot_dtype
          storage np.ndarray        scipy.sparse.csr_matrix
          ======= ================= =========================
  
      Returns
      -------
      uniques : ndarray
          The discovered uniques (uniques=None) or just `uniques`
      encoded : da.Array, optional
          The encoded values. Only returned when ``encode=True``.
      """
  
      if uniques is None:
          if encode and onehot_dtype:
              raise ValueError(
                  "Cannot use 'encode` and 'onehot_dtype' simultaneously."
              )
          if encode:
              uniques, encoded = da.unique(values, return_inverse=True)
              return uniques, encoded
          else:
              return da.unique(values)
  
      if encode:
          if onehot_dtype:
              dtype = onehot_dtype
              new_axis: Optional[int] = 1
              chunks = values.chunks + (len(uniques),)
          else:
              dtype = np.dtype("int")
              new_axis = None
              chunks = values.chunks
  
          return (
              uniques,
              values.map_blocks(
                  _check_and_search_block,
                  uniques,
                  onehot_dtype=onehot_dtype,
                  dtype=dtype,
                  new_axis=new_axis,
                  chunks=chunks,
              ),
          )
      else:
          return uniques
  
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 4 for calling a global function with example usage: _encode_dask_array(values, uniques, encode, onehot_dtype) and returns: uniques,  values, uniques, uniques,  encoded, da