code: def _encode_check_unknown(values, uniques, return_mask=False):
      """
      Helper function to check for unknowns in values to be encoded.
      Uses pure python method for object dtype, and numpy method for
      all other dtypes.
      Parameters
      ----------
      values : array
          Values to check for unknowns.
      uniques : array
          Allowed uniques values.
      return_mask : bool, default False
          If True, return a mask of the same shape as `values` indicating
          the valid values.
      Returns
      -------
      diff : list
          The unique values present in `values` and not in `uniques` (the
          unknown values).
      valid_mask : boolean array
          Additionally returned if ``return_mask=True``.
      """
      if values.dtype == object:
          uniques_set = set(uniques)
          diff = list(set(values) - uniques_set)
          if return_mask:
              if diff:
                  valid_mask = np.array(
                      [val in uniques_set for val in values]
                  )
              else:
                  valid_mask = np.ones(len(values), dtype=bool)
              return diff, valid_mask
          else:
              return diff
      else:
          unique_values = np.unique(values)
          diff = list(
              np.setdiff1d(unique_values, uniques, assume_unique=True)
          )
          if return_mask:
              if diff:
                  valid_mask = np.in1d(values, uniques)
              else:
                  valid_mask = np.ones(len(values), dtype=bool)
              return diff, valid_mask
          else:
              return diff
  
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 4 for calling a global function with example usage: _encode_check_unknown(values, uniques, return_mask) and returns: diff,  valid_mask, diff, diff,  valid_mask, diff