def _to_tuple(in_arg, shape):
    """ Return a number as a tuple repeated according to shape. """
    if isinstance(in_arg, tuple):
        return in_arg
    elif isinstance(in_arg, int):
        shape = _to_tuple(shape, (shape,))
        out = in_arg
        for size in shape:
            out = (out,) * size
        return out