<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reshape_nd(data_or_shape, ndim):
 """Return image array or shape with at least ndim dimensions. Prepend 1s to image shape as necessary. (0,) (1, 1) (1, 2, 3) (3, 4, 5) (1, 2, 3) """

    is_shape = isinstance(data_or_shape, tuple)
    shape = data_or_shape if is_shape else data_or_shape.shape
    if len(shape) >= ndim:
        return data_or_shape
    shape = (1,) * (ndim - len(shape)) + shape
    return shape if is_shape else data_or_shape.reshape(shape)