code: def _determine_key_type(key):
      """Determine the data type of key.
      Parameters
      ----------
      key : scalar, slice or array-like
          The key from which we want to infer the data type.
      Returns
      -------
      dtype : {'int', 'str', 'bool', None}
          Returns the data type of key.
      """
      err_msg = (
          "No valid specification of the columns. Only a scalar, list or "
          "slice of all integers or all strings, or boolean mask is "
          "allowed"
      )
  
      dtype_to_str = {
          int: "int",
          str: "str",
          bool: "bool",
          np.bool_: "bool",
      }
      array_dtype_to_str = {
          "i": "int",
          "u": "int",
          "b": "bool",
          "O": "str",
          "U": "str",
          "S": "str",
      }
  
      if key is None:
          return None
      if isinstance(key, tuple(dtype_to_str.keys())):
          try:
              return dtype_to_str[type(key)]
          except KeyError:
              raise ValueError(err_msg)
      if isinstance(key, slice):
          if key.start is None and key.stop is None:
              return None
          key_start_type = _determine_key_type(key.start)
          key_stop_type = _determine_key_type(key.stop)
          if key_start_type is not None and key_stop_type is not None:
              if key_start_type != key_stop_type:
                  raise ValueError(err_msg)
          if key_start_type is not None:
              return key_start_type
          return key_stop_type
      if isinstance(key, list):
          unique_key = set(key)
          key_type = {_determine_key_type(elt) for elt in unique_key}
          if not key_type:
              return None
          if len(key_type) != 1:
              raise ValueError(err_msg)
          return key_type.pop()
      if hasattr(key, "dtype"):
          try:
              return array_dtype_to_str[key.dtype.kind]
          except KeyError:
              raise ValueError(err_msg)
  
imports: import copy
  import warnings
  from itertools import compress
  import dask
  import dask.array
  import dask.dataframe
  import numpy
  import packaging.version
  import scipy.sparse
  from dask.base import tokenize
  from dask.delayed import Delayed, delayed
  from sklearn.utils.validation import _is_arraylike, indexable
  from ..utils import _num_samples
label_desc: Use image node_id 10 for calling a global function with example usage: _determine_key_type(key) and returns: None, key_stop_type, key_type, dtype_to_str, None, key_start_type, None, array_dtype_to_str