#Import the NumPy library
import numpy as np

def sum_last_two_axes(arr):
    shape = arr.shape
    product = np.prod(shape[:-2])
    reshaped_arr = arr.reshape((product, -1))
    sum_arr = reshaped_arr.sum(axis=-1)
    return sum_arr.reshape(shape[:-2])

# use the function to get the sum over the last two axes
A = np.random.randint(0,10,(3,4,3,4))
sum_arr = sum_last_two_axes(A)
print(sum_arr)