def sub(x1, x2):
    """Element-wise subtraction of 2 vectors where the second vector is
    subtracted from the first. Return `x1 - x2`.

    Args:
        x1 (list): First vector. 1 or 2 dimensional.
        x2 (list): Second vector. Same dimenions as `x1`.

    Returns:
        list: A element-wise subtracted list. Same dimensions as `x1`.
    """
    assert len(x1) == len(x2)

    if isinstance(x1[0], list):  # 2 dimensional
        assert len(x1[0]) == len(x2[0])
        diff = []

        for x1_i, x2_i in zip(x1, x2):
            diff_i = [x1_ij - x2_ij for x1_ij, x2_ij in zip(x1_i, x2_i)]
            diff.append(diff_i)

        return diff
    else:  # 1 dimensional
        return [x1_i - x2_i for x1_i, x2_i in zip(x1, x2)]