human
Complete this python program:
def key_kind_n(index):
assistant
#Here is the Python code you requested.

    """Pull out the nth (0-based) key kind from a key which has parents.
    This is a useful complement to create_deep_key.
    Args:
    index: The depth of the id or name to extract. Zero is the root key.
    Negative one is the leaf key.
    Returns:
    Function returning the kind of the key at depth index, or raising
    IndexError if the key is not as deep as described.
    """
    @empty_if_none
    def transform_function(key):
        path = key.to_path()
        path_index = (index * 2)
        return unicode(path[path_index])
    return transform_function