def arr_as_arr5(arr):
    """Convert an n-tensor to a 5-tensor"""
    depth = len(arr.shape)
    if depth == 1:
        return arr.reshape(1, 1, 1, 1, arr.shape[0])
    if depth == 2:
        return arr.reshape(1, 1, 1, arr.shape[0], arr.shape[1])
    if depth == 3:
        return arr.reshape(1, 1, arr.shape[0], arr.shape[1], arr.shape[2])
    if depth == 4:
        return arr.reshape(1, arr.shape[0], arr.shape[1], arr.shape[2], arr
            .shape[3])
    if depth == 5:
        return arr
    if depth == 6 and arr.shape[0] in [None, 1]:
        return arr.reshape(arr.shape[1:])
    raise ValueError('invalid number of dimensions')
