Returns a dispatch code for calling basic or advanced indexing functions.

def _get_indexing_dispatch_code(key):
    """Returns a dispatch code for calling basic or advanced indexing functions."""
    if isinstance(key, (NDArray, np.ndarray)):
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, list):
        # TODO(junwu): Add support for nested lists besides integer list
        for i in key:
            if not isinstance(i, integer_types):
                raise TypeError('Indexing NDArray only supports a list of integers as index'
                                ' when key is of list type, received element=%s of type=%s'
                                % (str(i), str(type(i))))
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, (integer_types, py_slice)):
        return _NDARRAY_BASIC_INDEXING
    elif isinstance(key, tuple):
        for idx in key:
            if isinstance(idx, (NDArray, np.ndarray, list, tuple)):
                return _NDARRAY_ADVANCED_INDEXING
            elif not isinstance(idx, (py_slice, integer_types)):
                raise ValueError("NDArray does not support slicing with key %s of type %s."
                                 % (str(idx), str(type(idx))))
        return _NDARRAY_BASIC_INDEXING
    else:
        return _NDARRAY_UNSUPPORTED_INDEXING