def as_index(keys, axis=semantics.axis_default, base=False, stable=True, lex_as_struct=False):
    if isinstance(keys, Index):
        if type(keys) is BaseIndex and base==False:
            keys = keys.keys
        else:
            return keys
    if isinstance(keys, tuple):
        if lex_as_struct:
            keys = as_struct_array(*keys)
        else:
            return LexIndex(keys, stable)
    try:
        keys = np.asarray(keys)
    except:
        raise TypeError('Given object does not form a valid set of keys')
    if axis is None:
        keys = keys.flatten()
    if keys.ndim==1:
        if base:
            return BaseIndex(keys)
        else:
            return Index(keys, stable=stable)
    else:
        return ObjectIndex(keys, axis, stable=stable)