#Import the NumPy library
import numpy as np
def sum_last_two_axes(A):
A_transposed = np.transpose(A, axes=(-1, -2, *range(A.ndim-2)))
A_reshaped = A_transposed.reshape(-1, A.shape[-2] * A.shape[-1])
sum_array = np.sum(A_reshaped, axis=-1)
return sum_array.reshape(A.shape[:-2])
# example usage
A = np.random.randint(0, 10, (3, 4, 3, 4))
sum_array = sum_last_two_axes(A)
print(sum_array)