<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pad_rem(pv, size=None):
 """ Removes linear padding from array This is a convenience function that does the opposite of `pad_add`. Parameters pv : 1D or 2D ndarray The array from which the padding will be removed. size : tuple of length 1 (1D) or 2 (2D), optional The final size of the un-padded array. Defaults to half the size of the input array. Returns ------- pv : 1D or 2D ndarray Padded array `av` with pads appended to right and bottom. """

    if size is None:
        size = list()
        for s in pv.shape:
            assert s % 2 == 0, "Uneven size; specify correct size of output!"
            size.append(int(s/2))
    elif not hasattr(size, "__len__"):
        size = [size]

    assert len(pv.shape) in [1, 2], "Only 1D and 2D arrays!"
    assert len(pv.shape) == len(
        size), "`size` must have same length as `av.shape`!"

    if len(pv.shape) == 2:
        return pv[:size[0], :size[1]]
    else:
        return pv[:size[0]]