docs: def _key_to_index(keys, key, single_only=False):
      'convert ``key`` of various types to int or list of int'
      if isinstance(key, int): # validate the int index
          try:
              keys[key]
          except IndexError:
              raise KeyError('Index out of range of keys: %s' % (key,))
          if key < 0:
              key += len(keys) # always positive index
          return key
  #    keys = d.keys()
      if not single_only:
          if isinstance(key, (tuple, list)):
              return [_key_to_index_single(keys, k) for k in key]
  
          if isinstance(key, slice):
              start, stop, step = key.start, key.stop, key.step
              try:
                  MI_check_index_name(start)
                  start = keys.index(start)
              except TypeError:
                  pass
              try:
                  MI_check_index_name(stop)
                  stop = keys.index(stop)
              except TypeError:
                  pass
  #            return slice(start, stop, step)
              args = slice(start, stop, step).indices(len(keys))
              return force_list(range(*args)) # list of indices
      try:
          return keys.index(key)
      except ValueError: # not IndexError
          raise KeyError('Key not found: %s' % (key,))