<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _clean_index(key, length):
 """ Validates and normalizes a cell range index. 0 0 Traceback (most recent call last):
 IndexError: Cell index out of range. Traceback (most recent call last):
 IndexError: Cell index out of range. Traceback (most recent call last):
 TypeError: Cell indices must be integers, NoneType given. """

    if not isinstance(key, integer_types):
        raise TypeError('Cell indices must be integers, %s given.' % type(key).__name__)
    if -length <= key < 0:
        return key + length
    elif 0 <= key < length:
        return key
    else:
        raise IndexError('Cell index out of range.')