code: def _map_to_integer(values, uniques, check_unknown=True):
      """Map values based on its position in uniques."""
  
      def mapper(values_data, uniques_data):
          if values_data.dtype.kind in "OUS":
              try:
                  table = _nandict(
                      {val: i for i, val in enumerate(uniques_data)}
                  )
                  return np.array([table[v] for v in values_data])
              except KeyError as e:
                  raise ValueError(
                      f"y contains previously unseen labels: {str(e)}"
                  )
          else:
              if check_unknown:
                  diff = _check_unknown(values_data, uniques_data)
                  if diff:
                      raise ValueError(
                          f"y contains previously unseen labels: {str(diff)}"
                      )
              return np.searchsorted(uniques_data, values_data)
  
      return values.map_chunk(
          mapper,
          args=(uniques,),
          dtype=np.dtype(np.int64),
          shape=values.shape,
      )
  
file_path: mars/mars/learn/utils/_encode.py
imports: import numpy
  from typing import NamedTuple
  from ...None import tensor, dataframe
  from .core import is_scalar_nan
label_desc: Use image node_id 3 for calling a global function with example usage: _map_to_integer(values, uniques, check_unknown) and returns: values, np, np