I want to create a custom array of arrays (each array is called a “block”) indexed by a list of 0 and 1’s. For example, suppose the array has 4 dimensions; then.

- The arrays are indexed by (0,0,0,0), (0,0,0,1), (0,0,1,0), etc.
- The size (shape) of each block depends on whether the index is 0 or 1: for example, the block at (0,1,1,0) has size (d0, d1, d1, d0), and the block at (1,0,0,1) has size (d1, d0, d0, d1).
- Sometimes I require that if the sum of the index array is odd (e.g. (0,0,0,1), (0,1,1,1), (1,0,0,0)), then the corresponding block must be zero.

In more mathematical jargons, the array is a tensor on the tensor product of 4 copies of a vector space V that can be decomposed as the direct sum V_0 \oplus V_1, with \dim V_0 = d_0 and \dim V_1 = d_1.

The array can also possibly be 0-dimensional, i.e. reduce to a single number. How to construct such an array in Julia? Originally I implemented it in Python using a dictionary, but since Julia supports more flexible array indexing, there may be a better implementation of such a structure.