code: def coerce_indexer_dtype(indexer, categories):
      
      length = len(categories)
      if length < _int8_max:
          return ensure_int8(indexer)
      elif length < _int16_max:
          return ensure_int16(indexer)
      elif length < _int32_max:
          return ensure_int32(indexer)
      return ensure_int64(indexer)
docs: coerce the indexer input array to the smallest dtype possible