For any three-dimensional array $A$ of size $n_1 \times n_2 \times n_3$ let $P(A)$ be the product of all its elements, i.e. $$P(A) = \prod_{i_1 = 1}^{n_1} \prod_{i_2 = 1}^{n_2} \prod_{i_3 = 1}^{n_3} a_{i_1,i_2,i_3}.$$
A subarray (cf. submatrix) of $A$ is given deleting rows in any of the tree dimensions. For e.g. the $3 \times 3 \times 3$ array $B$ with elements $b_{ijk}$: $$B = \left( \begin{array}{ccc} \left( \begin{array}{c} b_{1,1,1} \\ b_{1,1,2} \\ b_{1,1,3} \end{array} \right) & \left( \begin{array}{c} b_{1,2,1} \\ b_{1,2,2} \\ b_{1,2,3} \end{array} \right) & \left( \begin{array}{c} b_{1,3,1} \\ b_{1,3,2} \\ b_{1,3,3} \end{array} \right) \\ \left( \begin{array}{c} b_{2,1,1} \\ b_{2,1,2} \\ b_{2,1,3} \end{array} \right) & \left( \begin{array}{c} b_{2,2,1} \\ b_{2,2,2} \\ b_{2,2,3} \end{array} \right) & \left( \begin{array}{c} b_{2,3,1} \\ b_{2,3,2} \\ b_{2,3,3} \end{array} \right) \\ \left( \begin{array}{c} b_{3,1,1} \\ b_{3,1,2} \\ b_{3,1,3} \end{array} \right) & \left( \begin{array}{c} b_{3,2,1} \\ b_{3,2,2} \\ b_{3,2,3} \end{array} \right) & \left( \begin{array}{c} b_{3,3,1} \\ b_{3,3,2} \\ b_{3,3,3} \end{array} \right) \end{array} \right)$$ one can form a subarray $B'$ of $B$ by deleting the first row in the first dimension, the second row in the second dimension, and keeping all of the third dimension: $$B' = \left( \begin{array}{cc} \left( \begin{array}{c} b_{2,1,1} \\ b_{2,1,2} \\ b_{2,1,3} \end{array} \right) & \left( \begin{array}{c} b_{2,3,1} \\ b_{2,3,2} \\ b_{2,3,3} \end{array} \right) \\ \left( \begin{array}{c} b_{3,1,1} \\ b_{3,1,2} \\ b_{3,1,3} \end{array} \right) & \left( \begin{array}{c} b_{3,3,1} \\ b_{3,3,2} \\ b_{3,3,3} \end{array} \right) \end{array} \right).$$
For a given three-dimensional array $A$ with elements only being $1$ or $-1$, I want to compute the sum of $P(A')$ for all subarrays $A'$ of $A$: $$\sum_{A' \text{ subarray of } A} P(A').$$
Is there a clever way to do this? Can it be done in polynomial time?
In other words, I want to compute
$$\sum_{S_1,S_2,S_3} \prod_{i_1 \in S_1} \prod_{i_2 \in S_2} \prod_{i_3 \in S_3} a_{i_1,i_2,i_3},$$
where $S_i$ ranges over all non-empty subsets of $[n_i] = \{1,\dots,n_i\}$
Some observations I have made: A subarray is uniquely determined by which rows are kept from the original array. For example, in the case above $B'$ is determined by saying that we keep rows $2,3$ in the first dimension, rows $1,3$ in the second dimension and rows $1,2,3$ in the third dimension. So, for a $n_1 \times n_2 \times n_3$ array $A$, we get one subarray for each triple of subsets $(l_1,l_2,l_3)$, where $l_1 \subset \{1, \dots, n_1\}$ and so on. This gives a total of $(2^{n_1} - 1)(2^{n_2} -1)(2^{n_3} -1)$ subarrays, so a naive approach is out of the question if we want to compute the sum in polynomial time.
If a subarray is given by $(l_1,l_2,l_3)$ then another subarray is given by $(l_1 \setminus [n_1], l_2 \setminus [n_2], l_3 \setminus [n_3])$, so if you compute $P$ for one subarray, you get the other one "for free", if you know what $P$ for the whole array is. Maybe this can be used to do some clever thing, but I can't see it.
Here is a table of the products for the $2 \times 2 \times 2$ case, each row are the elements we want to multiply together in one product, and the result will be the sum of the products: $$\begin{array}{llllllll} b_{1,1,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,2,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,1,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,2,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{2,1,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,2} & b_{1,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,2} & b_{2,1,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,1} & b_{1,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,1} & b_{2,2,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,2} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,1} & b_{2,1,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,1} & b_{2,2,1} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,2} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{2,2,1} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,1,2} & b_{1,2,1} & b_{1,2,2} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,1,2} & b_{2,1,1} & b_{2,1,2} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,2,1} & b_{2,1,1} & b_{2,2,1} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,2} & b_{1,2,2} & b_{2,1,2} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} \\ b_{1,2,1} & b_{1,2,2} & b_{2,2,1} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} \\ b_{2,1,1} & b_{2,1,2} & b_{2,2,1} & b_{2,2,2} & \text{} & \text{} & \text{} & \text{} \\ b_{1,1,1} & b_{1,1,2} & b_{1,2,1} & b_{1,2,2} & b_{2,1,1} & b_{2,1,2} & b_{2,2,1} & b_{2,2,2} \end{array}$$
The one-dimensional case
If we have a one-dimensional array $A$, we can just as well consider $A$ to be a set and compute: $$\sum_{A' \subseteq A} \prod_{x \in A'} x$$ which can be computed by considering the polynomial $$p(x) = \prod_{a \in A} (x-a)$$ and if we expand this polynomial to $$p(x) = \sum_{j=0}^n \alpha_j x^j$$ the coefficient $\alpha_j$ is the sum of all products of $n - j$ elements in $A$, so to get total sum we just need to sum the $\alpha$. Computing the coefficients $\alpha_j$ can be done in polynomial time.